Home All Groups Group Topic Archive Search About

Get properties on interface (runtime/reflection)

Author
9 Dec 2006 3:10 PM
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

Author
10 Dec 2006 12:44 AM
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());



Show quote
"Anderskj" <anders> skrev i en meddelelse
news:uCiDwQ6GHHA.3292@TK2MSFTNGP02.phx.gbl...
> 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
>
>
>
>
>
>

AddThis Social Bookmark Button