I am attempting to use a Type as a generic. Essentially, I'm able to find a Type based off it's signature using reflection. I now need to do something like this:
Type theType = this.getMyType(mySignature);
string convertedData = mappingObj.mapIt<DataBase, theType>(myData);
However, I cannot use theType
as a generic. Is there a way to do this?
EDIT: Following suggestion by Sohaib Jundi, I run into the following (the non simplified code is working with Automapper's Map method):
typeof(IMapper).GetMethod("Map")
That line yields this error:
'typeof(IMapper).GetMethod("Map")' threw an exception of type 'System.Reflection.AmbiguousMatchException'
The method I'm attempting to get with GetMethod is Map<TDestination, TSource>(TSource source)
, but I cannot determine the method signature to call to get that method. For reference, here is the link to automappers IMapper class, where the Map method lives.