Is there a way to populate the properties of an object from a string at runtime? Any library that can help? Exemplifying, I have this class:
public class TestObject
{
public string Property1 { get; set; }
public int Property2 { get; set; }
public TestObject2 TestObject2 { get; set; }
}
public class TestObject2
{
public string Property1 { get; set; }
}
In my real case, the class has several other sub-classes, arrays and others data types. I need to populate the properties from a text, file, list, with content like this:
TestObject.Property1 = "String Value"
TestObject.Property2 = 5
TestObject.TestObject2.Property1 = "Sub Property String"
One possibility I see is sweeping the text and assigning values/objects using Reflection. But before I'm looking for something already existing.