How can i call and then use (set value) for member of the class, when i do not know class name?
For best understanding let me show example, what i mean:
for example i have class:
static class ClassA {
public static string Property1;
public static bool Property2;
public static async Task<bool> Method () {
// ...
await Worker.Do();
return true;
}
}
static class Worked {
public static async Task<bool> Do() {
// ...
var CallerClassName = new StackTrace().GetFrame(1).GetMethod().ReflectedType.Name;
// setup value for caller class Property 1 = "test";
// Like ClassA.Property1 = "test"; but using dynamic name;
// setup value for caller class Property 2 = true;
// Like ClassA.Property2 = true; but using dynamic name;
}
}
i should say, that i know that those properties exists in Caller class, i do not know how to set up their name dynamicly if i do not know its class caller name. Also i should say that all this methods, property and classes are static.
Thanks for help!
Aucun commentaire:
Enregistrer un commentaire