mardi 22 mai 2018

C# parsing to object definition in runtime

This is a somewhat hard understand question, maybe I'm thinking also wrong, don't downvote me for making this question. If you want me to delete this, just comment.

I'm reading some CSV's and trying to convert them to C# objects.

The objects I'm converting need to implement IResult

interface IResult
{
    String TestName { get; set; }
}

class Result : DynamicObject, IResult
{
    public string TestName { get; set; }

}

The Result class has several properties containing results, could be all Objects. Each tested item has one result with it's Properties, which is used to generate the CSV.

Now I need to do the opposite, read the CSV's and convert back to objects. but I want to do it so that I can use one method to load all kinds of items (with different IResult implementations).

So I thought of ExpandoObject or DynamicObject so that I could create the properties and set the values in Runtime.

Is this possible?





Aucun commentaire:

Enregistrer un commentaire