I am having a hard time in figuring out how to convert strings (generally speaking) into actual code.
The first thing I have tried (and succeeded) was to convert a string containing a "Property name" into an actual useful property and then modify the property value.
For those interested, here is how I came up with that. ie. Making the string "PropertyName" an actual property:
typeof(IModule).GetProperty("PropertyName").SetValue(SomeModule, true, null);
Now, the second thing was to figure out how to do the same thing with "IModule" (I so far failed miserably in finding a way to do this).
I have tried Type.GetType("IModule"), but it returns a null. I also tried providing the path to the actual dll (assembly), which also did not work. Reason for it not to work might be something to do with Interops.
In order to summarize, how can I do the following thing out of strings:
"IModule" SomeModule = ("Imodule").DoSomething;
Finally, I would like to do the same thing with "SomeModule".
Aucun commentaire:
Enregistrer un commentaire