0
I have a Resource File
with the following values:
Name: Value:
Teste1 TesteUm
Teste2 TesteDois
And I read it like this:
ResourceManager rm = new ResourceManager("MyResource",
Assembly.GetExecutingAssembly());
var value = rm.GetString("Teste1");
However I would like to generate a dynamic object with the values something that I could access as follows:
Resource.Teste1
// retorno TesteUm
Without having to log in by the string name of the value I want to pick up.
Is there any way? whether with Reflection or any other technology ?
And what would be the reason? What advantage do you expect to have?
– Maniero
Dude, I’m running a bunch of constants that are scattered and repeated in the classes, to a Source file, and I want to prevent another programmer from having to go into this file and keep looking for any constant that he’s looking for, the idea was to return the object with the data of this file and treat it as if it were an ENUM, and in case more data is added to the Source it would already fill my object dynamically, ie avoid maintenance.
– Jhonatan Jorge de Lima
unco job would be to add a new record in my Resource file and so it would be reflected directly in my object.
– Jhonatan Jorge de Lima
To do it right I think only with generation of code, you read the file and generate the party class of it. You can use a
ExpandoObjeto
, but it only gets cuter, the advantage is minimal. https://answall.com/q/68085/101 ehttps://answall.com/a/265893/101– Maniero
Properties.Resources.Teste1
– Jéf Bueno