/// <summary> /// Create a dynamic type representation of a getter /// </summary> public static DynamicGetter CreateDynamicGetter(this FieldInfo fieldInfo) { if (fieldInfo == null) { throw new ArgumentNullException(nameof(fieldInfo)); } var getterDelegate = FluentIl.CreateGetter(fieldInfo); if (getterDelegate == null) { return(null); } var access = GetAccessModifiers(fieldInfo); var visibility = GetVisibilityModifiers(fieldInfo); return(new DynamicGetter(access, visibility, getterDelegate)); }
/// <summary> /// Create a dynamic type representation of a getter /// </summary> public static DynamicGetter CreateDynamicGetter(this PropertyInfo propertyInfo) { if (propertyInfo == null) { throw new ArgumentNullException(nameof(propertyInfo)); } var getterDelegate = FluentIl.CreateGetter(propertyInfo); if (getterDelegate == null) { return(null); } var getMethod = propertyInfo.GetGetMethod(true); var access = GetAccessModifiers(getMethod); var visibility = GetVisibilityModifiers(getMethod); return(new DynamicGetter(access, visibility, getterDelegate)); }
private static GetterDelegate CreateAccessor(Type taskType) { var propertyInfo = taskType.GetProperty("Result"); return(propertyInfo != null?FluentIl.CreateGetter(propertyInfo) : null); }