mercredi 11 mai 2016

Design pattern for translating data

I am working on a C# project and I need to manage a local cache of data and present it on a GUI.

For example I have:

    public class DataFromOtherLibrary

Now I want make a class to help translate the information I need out of it

    public class MyDataModel
    {
            private DataFromOtherLibrary cache;
            public MyDataModel ( DataFromOtherLibrary Source)
            {
                    cache = Source;
            }
            public long Field1 { get { return cache.SomeField; } }
            public long Field2 { get { return cache.OtherFiled; } }
     }

Now the issue I have is I need to create a MyDataModel for every DataFromOtherLibrary it would be nice to have a single translator class. I'm not sure how to do it and still implement properties (which I need to data-bind to).

Thanks Matt

Aucun commentaire:

Enregistrer un commentaire