Get properties on interface (runtime/reflection)

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
 
A

Anderskj

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());
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top