lundi 20 mars 2017

Get text property of all forms in an assembly via reflection

I'm trying to iterate over all assemblies in my solution, get all forms and retrieve the text property of each form but I don't really know how to get the value. Here is my code:

 Type formType = typeof(Form);

 var assemblies =
            AppDomain.CurrentDomain.GetAssemblies();

 foreach (var assembly in assemblies)
 {
    var types = assembly.GetTypes();

    foreach (var type in types)
    {
       if (formType.IsAssignableFrom(type))
       {
          var properties = type.GetProperties().Where(x => x.Name == "Text");
       }
    }
 }

I'm not able to retrieve the concrete value of the form text property. I also tried

var property = type.GetProperty("Text").GetValue(???, null);

but don't know how to get the current class. Any ideas? Thank you!





Aucun commentaire:

Enregistrer un commentaire