public object GetValue(object target) { EnsureResolved(); var field = ResolvedMemberInfo as FieldInfo; if (field != null) { return(field.GetValue(target)); } var property = ResolvedMemberInfo as PropertyInfo; if (property != null) { if (!checkedNativeProperty) { checkedNativeProperty = true; nativePropertyError = NativeHelper.SharedInstance.CheckProperty( property, target, DeclaringType); } if (nativePropertyError != null) { throw new Exception(nativePropertyError); } return(property.GetValue(target)); } throw new NotImplementedException("should not be reached; " + $"unsupported MemberInfo {ResolvedMemberInfo.GetType ()}"); }
public void SetValue(object target, object value) { EnsureResolved(); var field = ResolvedMemberInfo as FieldInfo; if (field != null) { field.SetValue(target, value); return; } var property = ResolvedMemberInfo as PropertyInfo; if (property != null) { property.SetValue(target, value); return; } throw new NotImplementedException("should not be reached; " + $"unsupported MemberInfo {ResolvedMemberInfo.GetType ()}"); }