I have a Type TDestination with Name, FullName, etc. The method recieves a generic type TSource
I convert from one to another like this:
private static Type ConvertTypes<TSource>()
{
var mytype = typeof(TSource);
var newName = string.Format("{0}.{1}", Assembly.GetAssembly(typeof(Plugin)).FullName.Split(',')[0].ToString(), mytype .Name);
var newFullName = Assembly.GetAssembly(typeof(Plugin)).GetType(newName).FullName;
var TDestination = Type.GetType(newFullName);
return TDestination;
}
I need to use it in a Generic Method like Method<T>()
;
I tried some coding but I was unable to convert the Type to it's generic version.
It all begun when I needed to create a method that recieves Func<TSource, bool>
and this func needs to be mapped to Func<TDestination, bool>
.
I recieve a Model class and must convert the func to TDestination that is an Entity Framework class.
Until now, no success.
Anyone?