Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / May 2004

Tip: Looking for answers? Try searching our database.

Finding Implemented Interfaces with Reflection

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rick Strahl [MVP] - 04 May 2004 11:28 GMT
Does anybody know how to retrieve only the implemented interfaces of a
specific, class, not those that are implemented by inherited classes?

Type.GetInterfaces() gets me everything, but I'm only interested in the
immediately implemented interfaces.

It looks like GetInterfaces() returns the interfaces in order of the
implementation hierarchy more or less, but I still can't tell from there
where my top level implementation stops and the inherited interfaces begin.

Any ideas how to do this?

TIA,

+++ Rick ---

Signature

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
----------------------------------
Making waves on the Web

cody - 04 May 2004 12:39 GMT
> Does anybody know how to retrieve only the implemented interfaces of a
> specific, class, not those that are implemented by inherited classes?
[quoted text clipped - 5 lines]
> implementation hierarchy more or less, but I still can't tell from there
> where my top level implementation stops and the inherited interfaces begin.

You could retrieve all interfaces of the baseclass and then subract them
from the list.
But this only works if not both the class and its baseclass implemtent both
the same interface twice:

interface I{}
class A:I{}
class B:A,I{}

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu  || http://www.deutronium.tk
cody - 04 May 2004 12:44 GMT
> Does anybody know how to retrieve only the implemented interfaces of a
> specific, class, not those that are implemented by inherited classes?
[quoted text clipped - 7 lines]
>
> Any ideas how to do this?

in the case I mentioned you can regognize a doubly implemented interface if
you find some method of the interface in the class which has the NewSlot
flag set.

--
cody

Freeware Tools, Games and Humour
http://www.deutronium.de.vu  || http://www.deutronium.tk

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.