possible to reflect an interface type?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • n_o_s_p_a__m

    #1

    possible to reflect an interface type?

    ok, I call the following:

    Type t = typeof(ISomethi ng); // some interface
    MemberInfo[] mi = t.GetMembers();

    // but mi has length of 0

    How can I iterate over the members of this interface?

    Thanks
    -KJ
  • Nicholas Paldino [.NET/C# MVP]

    #2
    Re: possible to reflect an interface type?

    KJ,

    When doing this for myself, I can get the members of an interface. The
    only way it doesn't work is if ISomething has no methods on it (perhaps just
    properties?).

    What is the definition of ISomething? Can you post your code?

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    - mvp@spam.guard. caspershouse.co m

    "n_o_s_p_a_ _m" <n_o_s_p_a__m@m ail.com> wrote in message
    news:1faa8782.0 311180804.6d252 272@posting.goo gle.com...[color=blue]
    > ok, I call the following:
    >
    > Type t = typeof(ISomethi ng); // some interface
    > MemberInfo[] mi = t.GetMembers();
    >
    > // but mi has length of 0
    >
    > How can I iterate over the members of this interface?
    >
    > Thanks
    > -KJ[/color]


    Comment

    • Mattias Sjögren

      #3
      Re: possible to reflect an interface type?

      [color=blue]
      >How can I iterate over the members of this interface?[/color]

      Can you post the actual interface? It does have methods, right?



      Mattias

      --
      Mattias Sjögren [MVP] mattias @ mvps.org

      Please reply only to the newsgroup.

      Comment

      • Yura2000

        #4
        RE: possible to reflect an interface type?

        Pls, check access level for members of your interface
        Are there any public members?

        Comment

        • KJ

          #5
          Re: possible to reflect an interface type?

          Actually, all it does is inherit 5 other interfaces (all of which do have
          methods); maybe this is the catch.

          It looks like:
          public interface IWFEXAPI :

          IAuditingAPI,

          IElementInstanc eControlAPI,

          IInstanceContro lAPI,

          IWorkItemAPI,

          IWorkListAPI

          {}


          "Nicholas Paldino [.NET/C# MVP]" <mvp@spam.guard .caspershouse.c om> wrote in
          message news:ea1XXRfrDH A.1872@TK2MSFTN GP09.phx.gbl...[color=blue]
          > KJ,
          >
          > When doing this for myself, I can get the members of an interface.[/color]
          The[color=blue]
          > only way it doesn't work is if ISomething has no methods on it (perhaps[/color]
          just[color=blue]
          > properties?).
          >
          > What is the definition of ISomething? Can you post your code?
          >
          > Hope this helps.
          >
          >
          > --
          > - Nicholas Paldino [.NET/C# MVP]
          > - mvp@spam.guard. caspershouse.co m
          >
          > "n_o_s_p_a_ _m" <n_o_s_p_a__m@m ail.com> wrote in message
          > news:1faa8782.0 311180804.6d252 272@posting.goo gle.com...[color=green]
          > > ok, I call the following:
          > >
          > > Type t = typeof(ISomethi ng); // some interface
          > > MemberInfo[] mi = t.GetMembers();
          > >
          > > // but mi has length of 0
          > >
          > > How can I iterate over the members of this interface?
          > >
          > > Thanks
          > > -KJ[/color]
          >
          >[/color]


          Comment

          • Ken

            #6
            Re: possible to reflect an interface type?

            Yura2000, All members in an interface have to be public.

            "Yura2000" <yurig@clal-ins.co.il> wrote in message
            news:133F038D-FFFE-4C0A-A9E3-29A57E7E25D3@mi crosoft.com...[color=blue]
            > Pls, check access level for members of your interface.
            > Are there any public members?[/color]


            Comment

            • n_o_s_p_a__m

              #7
              Re: possible to reflect an interface type?

              Ok, found the answer:

              Type[] nestedTypes = typeof(IWFEXAPI ).GetInterfaces ();
              ArrayList mis = new ArrayList();
              foreach(Type t in nestedTypes) {
              mis.AddRange(t. GetMethods());
              }
              mi = new MethodInfo[mis.Count];
              mis.CopyTo(mi);

              "Ken" <anotherlooney@ verizon.net> wrote in message news:<GGHub.798 39$E9.40781@nwr ddc01.gnilink.n et>...[color=blue]
              > Yura2000, All members in an interface have to be public.
              >
              > "Yura2000" <yurig@clal-ins.co.il> wrote in message
              > news:133F038D-FFFE-4C0A-A9E3-29A57E7E25D3@mi crosoft.com...[color=green]
              > > Pls, check access level for members of your interface.
              > > Are there any public members?[/color][/color]

              Comment

              Working...