Get properties on interface (runtime/reflection)

  • Thread starter Thread starter Anderskj
  • Start date Start date
A

Anderskj

Hi!

I am developing a c# application. I have an interface (which can change
therefore my problem)

If i do like this:

List<PropertyInfo> properties = new List<PropertyInfo>();
properties.AddRange(typeof(app.IView).GetProperties());

I get the correct properties on the interface (9 pcs)

Now i want to dynamically load the interface by textstring (comming from
config file) and do like this.

Type viewInterface = Type.GetType("app.IView");

properties.AddRange(typeof(app.IView).GetProperties());

I now get 57 properties!. These i guess comes from the Type class.

How do i Achive my goal to load the interface by textstring name and the get
the properties on the interface?

Thanks in regards
Anders Jacobsen, Denmark
 
I got an anwere in another group:

It looks like you are somehow getting the type viewInterface again and
getting the properties over the Type objcet. I have this snippet:
List<PropertyInfo> properties = new List<PropertyInfo>();
properties.AddRange(typeof(IFoo).GetProperties());
List<PropertyInfo> properties2 = new List<PropertyInfo>();
Type fooInterface = Type.GetType("ConsoleApplication1.IFoo");
properties2.AddRange(fooInterface.GetProperties());
 
Back
Top