lundi 19 juin 2017

Divide a c# class into it's parts

if I have a Portable Class Library with a class

public class Class1
: EntityBaseClass
{
    public string Property1{get;set;}
    public string Property2{get;set;}
}

and a second class that contains an instance of class 1

public class Class2
: EntityBaseClass
{
    public string Property1{get;set;}

    public Class1 Property2{get;set;}
}

How can I devide class 2 so that I can get a dictionary in form of

Dictionary<Type, object>

where 'Type' is the type of Class1 and 'object' is the instance of class 1?

For persistence reasons I have to break a class into it's parts and have to save each instance separatly.

The plan is to implement a Save<T>(T entity) methode. This method picks out properties that derive from a special baseclass an save it into the datastore.

Because of the pcl library type there is no complete reflection subset of the .net Framework.

I tryed to do it with reflection and serialization without success but a lot of head aches. Attributes don't work too. Any hints how to start?





Aucun commentaire:

Enregistrer un commentaire