After lots of looking around (including SIMILAR but not same questions), I hope my question will make sense and someone could help me resolve this.
I have many classes, say ClassA, ClassB, ClassC etc and they all exist for specific reasons. I have another Class which is being used for testing purposes and this includes two properties, set as follows:
public class Test : Countable<TestScenario>
{
//test completed
public bool completed { get; set; } = false;
//break or error (stop further execution) or not
public bool breakOnError { get; set; } = true;
//test result
public bool success { get; set; } = false;
//what did we test
public string testCase { get; set; } = string.Empty;
//what data we got as result
public object testDataResult { get; set; }
public Test()
{
}
}
My problem is this: I instantiate the class, i.e. Test myTest = new Test(); etc and I need to assign a class, say myResult (containing dozens of properties with values).
I need to do (something like) this:
Test myTest = new Test();
myTest.testDataResult = myResult;
It is safe to assume that later, if for example there's a myResult.SomeProperty with value 18, I would like to see it from myTest.testDataResult.SomeProperty I.e.
Console.WriteLine(myTest.testDataResult.SomeProperty.ToString());
//18
Is this possible? Being looking all around Binaryformatters and Reflection, one example seemed also good (https://www.codeproject.com/Articles/1111658/Fast-Deep-Copy-by-Expression-Trees-C-Sharp) mentioned as link here in SO (Faster deep cloning) but I couldn't make it, is above my experience level.
Could someone help me please with a working example?