I need to change the string that the client sends to the values from the class property.
At the moment, it works for me until I get a class that does not support the following entry:
Working example (we start from the payout class):
The customer sends: "Employee.Name" in string
My code:
List <string> parametrs = ClientTxT.Split('.'). ToList();
dynamic MyDynamicObject = payout;
for (int y = 0; y <parametrs.Count; y ++)
MyDynamicObject = MyDynamicObject [parametrs [y], RowVersion.Current];
I enter the Employee and take the Name property. Everything is OK because the Employee class is compatible with this entry:
object ObjectIRecived = myClass[propertyNameInString, RowVersion];
Example not working: I have a problem when the class is not compatible with this entry, e.g. Number. The Number class has only two property: "Full" and "Simple".
If the customer sends "Number.Full" I got an error:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException
HResult = 0x80131500
Message = Cannot apply indexing with [] to an expression of type 'Soneta.Core.CoreModule.NumerDokumentuRecord'
Source = <Cannot evaluate the exception source>
StackTrace:
<Cannot evaluate the exception stack trace>
My guess is that in this case I have to refer directly to Number.Full but I don't know how to do it in the code, since the propertyname is in string