how do I search inherit generic Class?

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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 :)

--
 
Back
Top