jeudi 5 mars 2015

c# - Best method to read costumizable texts

I have a program that needs to send emails. This emails may need to send some object information.


Example 1



"[ObjectA.Param1][newLine]
[newLine]
fixed text : [ObjectA.Param2][newLine]
more fixed text."


In this example i could make a replace for [newLine] (since this never changes) but i can't do the same for the rest, since the message tomorrow could be


Example 2



"[ObjectA.Param1][newLine]
[newLine]
fixed text : [ObjectB.Param5][newLine]
[newLine]
more fixed text and yet another fixed text bláblá."


Even if the object i want to access is always of the same class, i would like to avoid a replace because if this same class is added a new parameter and that gets configured in the text i would need to change the code.


What is the best approach for this? I'll probably need to use reflection in order to be able to get the value from ObjectX.ParamY but first i need to know what i have to evaluate.






Aucun commentaire:

Enregistrer un commentaire