C# Instantiate class which implements generic interface
Posted
by Martijn B
on Stack Overflow
See other posts from Stack Overflow
or by Martijn B
Published on 2010-05-18T15:18:20Z
Indexed on
2010/05/18
15:20 UTC
Read the original article
Hit count: 799
c#
|reflection
Hi there,
I have some business classes which implements IBusinessRequest
for example:
public class PersonBusiness : IBusinessRequest<Person>
{ }
Besides this I have a function:
TypeHelper.CreateBusinessInstance(Type businessType, Type businessRequestType)
A requirement of a business class is that they must have a parameterless constructor, which I check in the TypeHelper.CreateBusinessInstance function.
I want to create a instance of type businessType (which is i.e PersonBusiness) with the generic value businessRequestType for IBusinessRequest<>.
How can I get this done?
Thanks in Advance.
Gr
Martijn
© Stack Overflow or respective owner