Skip to content
Popular Data Conversion Helpers
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Castr.Test
Castr
.gitignore
Castr.sln
LICENSE
README.md
azure-pipelines.yml

README.md

Castr

Popular Data Conversion Helpers

Usage

To convert a class to child class

var parentClass = new SimpleTestClass();
parentClass.Property1 = "test";
var castrClass = new CastrClass<SimpleTestClass>(
    parentClass, new Options.ClassOptions()
    {
        IsStrict = true
    });

var childClass = castrClass.CastAsClass<SimpleTestSubClass>();

Turning Strict off enables this to be used between any two classes that share property names.

Convert a CSV to a class (singular)

string csvData = File.ReadAllText(@"c:\txt.csv");
var csv = new CastrCSV(csvData, ",", true);

// Act
var newClass = csv.CastAsClass<SimpleTestClass>();

Convert a multi line CSV to a class list)

string csvData = File.ReadAllText(@"c:\txt.csv");
var csv = new CastrCSVMulti(csvData, ",", true);

// Act
var newClassEnumerable = csv.CastAsClassMulti<SimpleTestClass>();
You can’t perform that action at this time.