so i am correct in believing that only one class within the hierachy needs to be 
processed?

what about using the GetInterfaces method until the interface of concern is not 
included in the collection.  when you reach that class you know the child is the one 
with the marker.

but for the purpose you describe why not define a the ProcessClassAttribute class.  
the attribute can be defined so that it is not inherited, then as you go through the 
base classes just look for you ProcessClassAttribute

seems to me that would solve the problem, but maybe i still don't really understand

have fun
-joe

-----Original Message-----
From: Thomas Tomiczek [mailto:[EMAIL PROTECTED]
Sent: Thursday, June 26, 2003 12:15 PM
To: [EMAIL PROTECTED]
Subject: Re: [ADVANCED-DOTNET] Type class - finding out whether a
specific interface is iplemented in the type on THIS inheritance
level...


Well, I can tell you excactly what I am looking for :-)

Ok, I have an inheritance hierarchy from which I ge t the last type.

I need to run this upwards (basetype, basetype, basetype) and process CERTAIN of these 
types ONLY :-)

So I had the idea of putting a marker interface on these, but - according to normal 
inheritance rules, the marker interface would also be visible on the baseclasses.

A STATIC method (which I could find) could work, too, though, now that I think of it. 
I could just reflect on whether the static method is available.

Thomas Tomiczek
THONA Consulting Ltd.
(Microsoft MVP C#/.NET) 

> 
> -----Original Message-----
> From: Moderated discussion of advanced .NET topics. 
> [mailto:[EMAIL PROTECTED] On Behalf Of 
> Emilio D'Angelo Yofre
> Sent: Donnerstag, 26. Juni 2003 20:09
> To: [EMAIL PROTECTED]
> 
> I don't know if this is what you are looking for, but the 
> following code shows where an interface's method is declared:
> 
> using System;
> using System.Reflection;
> 
> interface I
> {
>         void Foo();
> }
> 
> class A : I
> {
>         public void Foo() {}
> }
> 
> class B : A {}
> 
> class C : B {}
> 
> class InterfaceReflection
> {
>         static void Main(string[] args)
>         {
>                 Type t = typeof(C);
>                 MethodInfo mi = t.GetMethod("Foo");
>                 Console.WriteLine("{0} is declared in {1}",
>                         mi.ToString(),
>                         mi.DeclaringType.FullName);
>         }
> }
> 
> Hope this help.
> 
> 
> Emilio D'Angelo
> 
> -----Mensaje original-----
> De: Thomas Tomiczek [mailto:[EMAIL PROTECTED]
> Enviado el: mi�rcoles, 25 de junio de 2003 15:45
> Para: [EMAIL PROTECTED]
> Asunto: [ADVANCED-DOTNET] Type class - finding out whether a 
> specific interface is iplemented in the type on THIS 
> inheritance level...
> 
> Possible?
> 
>  
> 
> I have an inheritance hierarchy like this:
> 
>  
> 
> As, implements I
> 
> A
> 
> Bs, implements I
> 
> B
> 
> Cs, implements I
> 
> C
> 
>  
> 
> Given a Type T, is there any way for me to find out whether 
> the given type has the implements clause explicitly given? 
> Means, is As, Bs or Cs?
> 
>  
> 
> Or is I available everywhere starting from As down and this 
> information is not accessible anymore?
> 
>  
> 
> Regards
> 
>  
> 
> Thomas Tomiczek
> 
> THONA Consulting Ltd.
> 
> (Microsoft MVP C#/.NET)
> 
> 

Reply via email to