possible to reflect an interface type?

  • Thread starter Thread starter n_o_s_p_a__m
  • Start date Start date
N

n_o_s_p_a__m

ok, I call the following:

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

// but mi has length of 0

How can I iterate over the members of this interface?

Thanks
-KJ
 
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.
 
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,

IElementInstanceControlAPI,

IInstanceControlAPI,

IWorkItemAPI,

IWorkListAPI

{}


Nicholas Paldino said:
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]
- (e-mail address removed)

n_o_s_p_a__m said:
ok, I call the following:

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

// but mi has length of 0

How can I iterate over the members of this interface?

Thanks
-KJ
 
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);
 
Back
Top