Home All Groups Group Topic Archive Search About

how do I search inherit generic Class?

Author
27 Dec 2005 8:19 AM
ken
hellow , all

I want  list of Generic inherited Type in DesignTime

It is as follows to try.
-----------------------------------------------------------------------------------------------
I made two of the following.
public interface ITest<T>
public class TestImplement : ITest<Somthing>


I wrote following Code in TypeConverter Class

ITypeDiscoveryService typeDiscoveryService =
                context.GetService(typeof(ITypeDiscoveryService)) as
ITypeDiscoveryService;

Ilist genericInheritList = typeDiscoveryService.GetTypes(typeof(ITest<>));
-----------------------------------------------------------------------------------------------

The result of the expectation  I want , is genericInheritList  has
TestImplement class type.

but genericInheritList  has no Type.

how do I search inherit generic Class?

Thank you for your help!
Sorry, for my bad english

Ken

Author
27 Dec 2005 8:55 AM
Frans Bouma [C# MVP]
ken wrote:

Show quote
> hellow , all
>
> I want  list of Generic inherited Type in DesignTime
>
> It is as follows to try.
>
> ----------------------------------------------------------------------
> ------------------------- I made two of the following.
>  public interface ITest<T>
>  public class TestImplement : ITest<Somthing>
>
>
> I wrote following Code in TypeConverter Class
>
> ITypeDiscoveryService typeDiscoveryService =
>                 context.GetService(typeof(ITypeDiscoveryService)) as
> ITypeDiscoveryService;
>
> Ilist genericInheritList =
> typeDiscoveryService.GetTypes(typeof(ITest<>));
>
> ----------------------------------------------------------------------
> -------------------------
>
> The result of the expectation  I want , is genericInheritList  has
> TestImplement class type.
>
> but genericInheritList  has no Type.
>
> how do I search inherit generic Class?

    You could try (haven't tested it):
IList types =
typeDiscoveryService.GetTypes(Type.ReflectionOnlyGetType("ITest`1",
false, true));

        FB, who thanks you for mentioning ITypeDiscoveryService, as I needed
that interface but couldn't find it :)

--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------

AddThis Social Bookmark Button