PerformVisibilityCheckOnField() private method

private PerformVisibilityCheckOnField ( IntPtr field, Object target, IntPtr declaringType, FieldAttributes attr, uint invocationFlags ) : void
field System.IntPtr
target Object
declaringType System.IntPtr
attr FieldAttributes
invocationFlags uint
return void
コード例 #1
0
ファイル: 2fieldinfo.cs プロジェクト: wwkkww1983/ZJCredit
        internal object InternalGetValue(object obj, ref StackCrawlMark stackMark)
        {
            INVOCATION_FLAGS invocationFlags = this.InvocationFlags;
            RuntimeType      runtimeType1    = this.DeclaringType as RuntimeType;

            if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NO_INVOKE) != INVOCATION_FLAGS.INVOCATION_FLAGS_UNKNOWN)
            {
                if (runtimeType1 != (RuntimeType)null && this.DeclaringType.ContainsGenericParameters)
                {
                    throw new InvalidOperationException(Environment.GetResourceString("Arg_UnboundGenField"));
                }
                if (runtimeType1 == (RuntimeType)null && this.Module.Assembly.ReflectionOnly || runtimeType1 is ReflectionOnlyType)
                {
                    throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyField"));
                }
                throw new FieldAccessException();
            }
            this.CheckConsistency(obj);
            if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != INVOCATION_FLAGS.INVOCATION_FLAGS_UNKNOWN)
            {
                RuntimeAssembly executingAssembly = RuntimeAssembly.GetExecutingAssembly(ref stackMark);
                if ((Assembly)executingAssembly != (Assembly)null && !executingAssembly.IsSafeForReflection())
                {
                    throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", (object)this.FullName));
                }
            }
            RuntimeType runtimeType2 = (RuntimeType)this.FieldType;

            if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY) != INVOCATION_FLAGS.INVOCATION_FLAGS_UNKNOWN)
            {
                RtFieldInfo.PerformVisibilityCheckOnField(this.m_fieldHandle, obj, this.m_declaringType, this.m_fieldAttributes, (uint)(this.m_invocationFlags & ~INVOCATION_FLAGS.INVOCATION_FLAGS_IS_CTOR));
            }
            return(this.UnsafeGetValue(obj));
        }
コード例 #2
0
        internal void InternalSetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture, ref StackCrawlMark stackMark)
        {
            INVOCATION_FLAGS invocationFlags = this.InvocationFlags;
            RuntimeType      runtimeType     = this.DeclaringType as RuntimeType;

            if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NO_INVOKE) != INVOCATION_FLAGS.INVOCATION_FLAGS_UNKNOWN)
            {
                if (runtimeType != null && runtimeType.ContainsGenericParameters)
                {
                    throw new InvalidOperationException(Environment.GetResourceString("Arg_UnboundGenField"));
                }
                if ((runtimeType == null && this.Module.Assembly.ReflectionOnly) || runtimeType is ReflectionOnlyType)
                {
                    throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyField"));
                }
                throw new FieldAccessException();
            }
            else
            {
                this.CheckConsistency(obj);
                RuntimeType runtimeType2 = (RuntimeType)this.FieldType;
                value = runtimeType2.CheckValue(value, binder, culture, invokeAttr);
                if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NON_W8P_FX_API) != INVOCATION_FLAGS.INVOCATION_FLAGS_UNKNOWN)
                {
                    RuntimeAssembly executingAssembly = RuntimeAssembly.GetExecutingAssembly(ref stackMark);
                    if (executingAssembly != null && !executingAssembly.IsSafeForReflection())
                    {
                        throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_APIInvalidForCurrentContext", new object[]
                        {
                            this.FullName
                        }));
                    }
                }
                if ((invocationFlags & (INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY | INVOCATION_FLAGS.INVOCATION_FLAGS_IS_CTOR)) != INVOCATION_FLAGS.INVOCATION_FLAGS_UNKNOWN)
                {
                    RtFieldInfo.PerformVisibilityCheckOnField(this.m_fieldHandle, obj, this.m_declaringType, this.m_fieldAttributes, (uint)this.m_invocationFlags);
                }
                bool domainInitialized = false;
                if (runtimeType == null)
                {
                    RuntimeFieldHandle.SetValue(this, obj, value, runtimeType2, this.m_fieldAttributes, null, ref domainInitialized);
                    return;
                }
                domainInitialized = runtimeType.DomainInitialized;
                RuntimeFieldHandle.SetValue(this, obj, value, runtimeType2, this.m_fieldAttributes, runtimeType, ref domainInitialized);
                runtimeType.DomainInitialized = domainInitialized;
                return;
            }
        }