i need convert a value of type generic.. but i need get the type of a property for convert... how i can do this ?
public static T ConvertToClass<T>(this Dictionary<string, string> model)
{
Type type = typeof(T);
var obj = Activator.CreateInstance(type);
foreach (var item in model)
{
type.GetProperty(item.Key).SetValue(obj, item.Value.DynamicType</*TYPE OF PROPERTY*/>());
}
return (T)obj;
}
public static T DynamicType<T>(this string value)
{
return (T)Convert.ChangeType(value, typeof(T));
}