Say I have the following classes.
public class MyClass { public string Data1 { get; set; } public MyOtherClass Data2 { get; set; }
There is somecode that initializes this class and fills it with all the data. I would like to use this object for my test. I could just serialize the structure to XML and reload it later. However, I would like the entire tree of objects to be built in the code. In other words:
MyClass myClass = new MyClass { Data1 = "Hello", Data2 = new MyOtherClass { OtherData1 = "World",
I could write all this myself, but it will take several hours and be error prone since there are a large number of properties and subclasses. Here's my question: an object is asked, how would you generate code that populates this object?
source share