Ejemplo n.º 1
0
        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 ()}");
        }
Ejemplo n.º 2
0
        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 ()}");
        }