Код: Выделить всё
internal class DataTypeDemo
{
public TestEnum Enum { get; set; }
public TestEnum? Enum2 { get; set; }
}
Код: Выделить всё
internal enum TestEnum : int
{
Age = 1,
Name,
Address,
CellPhone,
Max = 500
}
Это выражение
Код: Выделить всё
public static void RetrieveGetterSetter(PropertyInfo property, out Func getter, out Action setter) where T : class
{
var userDataExp = Expression.Parameter(typeof(T));
if (property.PropertyType.IsNullableType(out var rootType))
{
// something about nullable
}
var setMethod = property.GetSetMethod();
var inValue = Expression.Parameter(Types.Object);
var destValueExp = Expression.Convert(inValue, setMethod.GetParameters()[0].ParameterType);
var call = Expression.Call(userDataExp, setMethod, destValueExp);
setter = Expression.Lambda(call, userDataExp, inValue).CompileFast();
}
Как решить проблему?
Подробнее здесь: https://stackoverflow.com/questions/790 ... e-property