reflection - How can I read attributes of a class in an external dll file in c#? -
i have following block of code. how can attribute names specific dll file? currently, can class names, namespace not know how attributes in class. thank you,
foreach (type type in myassambly.gettypes()) { propertyinfo mypi = type.getproperty("defaultmodifiers"); system.reflection.propertyattributes mypa = mypi.attributes; messagebox.show(mypa.tostring()); }
it sounds you're interested in properties:
foreach (type type in myassembly.gettypes()) { foreach (propertyinfo property in type.getproperties()) { messagebox.show(property.name + " - " + property.propertytype); } }
edit: okay, sounds really really want fields:
foreach (type type in myassembly.gettypes()) { foreach (fieldinfo field in type.getfields(bindingflags.instance | bindingflags.static | bindingflags.public | bindingflags.nonpublic)) { messagebox.show(field.name + " - " + field.fieldtype); } }
Comments
Post a Comment