samedi 28 août 2021

Parsing string for object property

I'm attempting to parse a string and replace values in a string with object properties.

Currently I'm using a code in the string {value=x; id=y ;property=z} and running that through a switch case to convert it into an object. Then replacing the {} with the object properties.

for example "some random string {value=1; id=1; property=Name} continued random string"

I parse the string to locate {value=, on a hit it runs through a switch case, where on case 1: return Account(ID = 1). The I grab Account.Name

Once I have that I put it in a text box so the user can validate that it is correct before generating a final document to be sent out.

Is there a way to have {Object.Property} in the string then use reflection to convert that string value to the object value?

Get property value from string using reflection

I used the above in other instances, but that requires that I have the object.

How do I convert "Account" in to

<Account>




Aucun commentaire:

Enregistrer un commentaire