473,406 Members | 2,769 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

possible to reflect an interface type?

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
Nov 15 '05 #1
6 1128
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]
- mv*@spam.guard.caspershouse.com

"n_o_s_p_a__m" <n_**********@mail.com> wrote in message
news:1f**************************@posting.google.c om...
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

Nov 15 '05 #2
How can I iterate over the members of this interface?


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

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #3
Pls, check access level for members of your interface
Are there any public members?
Nov 15 '05 #4
KJ
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 [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:ea**************@TK2MSFTNGP09.phx.gbl...
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]
- mv*@spam.guard.caspershouse.com

"n_o_s_p_a__m" <n_**********@mail.com> wrote in message
news:1f**************************@posting.google.c om...
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


Nov 15 '05 #5
Ken
Yura2000, All members in an interface have to be public.

"Yura2000" <yu***@clal-ins.co.il> wrote in message
news:13**********************************@microsof t.com...
Pls, check access level for members of your interface.
Are there any public members?

Nov 15 '05 #6
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" <an***********@verizon.net> wrote in message news:<GG******************@nwrddc01.gnilink.net>.. .
Yura2000, All members in an interface have to be public.

"Yura2000" <yu***@clal-ins.co.il> wrote in message
news:13**********************************@microsof t.com...
Pls, check access level for members of your interface.
Are there any public members?

Nov 15 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Maurice Ling | last post by:
Hi, I have read that this had been asked before but there's no satisfactory replies then. I have a module (pA) written in python, which originally is called by another python module (pB), and...
0
by: lothar.behrens | last post by:
Hi, a long time ago I had implemented my version - or attempt - of a smart pointer. It is not well and most books I have read afterwards are using templates :-( It is macro based and now I...
8
by: McKirahan | last post by:
Firefox does not reflect selected option via innerHTML How do I get Firefox to reflect selected option values? <html> <head> <title>FFinner.htm</title> <script type="text/javascript">...
4
by: Bon | last post by:
Hello all Would it be possible to migrate the MS Access 2000 to MS SQL Server 2000? My application is using MS Access 2000 as database and as user interface such as forms. Now, I want to...
4
by: Dietmar Kuehl | last post by:
Hi, after reading the documentation on C# generics from several sources, I'm still unclear whether it is possible to infer associated types from a type argument. For example, if I have an...
3
by: KK | last post by:
Hello all, I have several classes binded by one common interface - say 'sum' interface which calculates the sum of all the class elements of type 'int'. class Alphabet { int _a; int _b; int...
2
by: Philip Daniels | last post by:
I am doing some work with a client API via COM interop. I have reached the situation where after this call to their API: object someObj = con.Peek(1); "someObj" contains some type of COM...
2
by: Mikhail Teterin | last post by:
Hello! I'm going through the fields of a class one at a time and need to handle differently depending on whether they are arrays or scalars. What's the right way to make the distinction? The...
10
by: lpinho | last post by:
Hi all, I have a class (named for the example myObject) that can be of several types (int, string, float, etc), instead of using a object to define it's type I used a generic. public class...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.