I have a method that has a constraint like this:
public class MappingTransformation
{
public static ClassMapped<T> Convert<T>(Mapping<T> source) where T : class
{
return ClassMapped<T>.GetInstance(source);
}
}
This T MUST be reference type because it will be passed to EntityTypeConfiguration.
But, when consuming MappingTransformation.Convert<>(Mapping source) I only have a Type and don't know how to convert this Type into the needed "reference type".
Here is how I'm trying to consume it:
#region Test
foreach (var item in mappingAssembly.GetTypes())
{
var mappingObj = Activator.CreateInstance(item);
var modelName = mappingObj.GetType().GetProperty("ModelName").GetValue(mappingObj);
var modelTypeEquivalent = modelAssembly.GetTypes().First(x => x.Name.Equals(modelName));
var convertido = MappingTransformation.Convert<Model.Clientes>((Mapping<Model.Clientes>)mappingObj);
var breakpoint = true;
}
#endregion
How to achieve this?