how do I search inherit generic Class?

G

Guest

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
 
F

Frans Bouma [C# MVP]

ken said:
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 :)

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top