Пример #1
0
        public override object?GetValue(object?obj)
        {
            INVOCATION_FLAGS invocationFlags = InvocationFlags;
            RuntimeType?     declaringType   = DeclaringType as RuntimeType;

            if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NO_INVOKE) != 0)
            {
                if (declaringType != null && DeclaringType !.ContainsGenericParameters)
                {
                    throw new InvalidOperationException(SR.Arg_UnboundGenField);
                }

                throw new FieldAccessException();
            }

            CheckConsistency(obj);

            RuntimeType fieldType = (RuntimeType)FieldType;

            bool domainInitialized = false;

            if (declaringType == null)
            {
                return(RuntimeFieldHandle.GetValue(this, obj, fieldType, null, ref domainInitialized));
            }
            else
            {
                domainInitialized = declaringType.DomainInitialized;
                object?retVal = RuntimeFieldHandle.GetValue(this, obj, fieldType, declaringType, ref domainInitialized);
                declaringType.DomainInitialized = domainInitialized;
                return(retVal);
            }
        }
Пример #2
0
        internal object UnsafeGetValue(object obj)
        {
            RuntimeType declaringType      = this.DeclaringType as RuntimeType;
            RuntimeType fieldType          = (RuntimeType)this.FieldType;
            bool        domainInitialized1 = false;

            if (declaringType == (RuntimeType)null)
            {
                return(RuntimeFieldHandle.GetValue(this, obj, fieldType, (RuntimeType)null, ref domainInitialized1));
            }
            bool   domainInitialized2 = declaringType.DomainInitialized;
            object obj1 = RuntimeFieldHandle.GetValue(this, obj, fieldType, declaringType, ref domainInitialized2);

            declaringType.DomainInitialized = domainInitialized2;
            return(obj1);
        }
        internal object UnsafeGetValue(object obj)
        {
            RuntimeType runtimeType       = this.DeclaringType as RuntimeType;
            RuntimeType fieldType         = (RuntimeType)this.FieldType;
            bool        domainInitialized = false;

            if (runtimeType == null)
            {
                return(RuntimeFieldHandle.GetValue(this, obj, fieldType, null, ref domainInitialized));
            }
            domainInitialized = runtimeType.DomainInitialized;
            object value = RuntimeFieldHandle.GetValue(this, obj, fieldType, runtimeType, ref domainInitialized);

            runtimeType.DomainInitialized = domainInitialized;
            return(value);
        }
Пример #4
0
        internal Object UnsafeGetValue(Object obj)
        {
            RuntimeType declaringType = DeclaringType as RuntimeType;

            RuntimeType fieldType = (RuntimeType)FieldType;

            bool domainInitialized = false;
            if (declaringType == null)
            {
                return RuntimeFieldHandle.GetValue(this, obj, fieldType, null, ref domainInitialized);
            }
            else
            {
                domainInitialized = declaringType.DomainInitialized;
                object retVal = RuntimeFieldHandle.GetValue(this, obj, fieldType, declaringType, ref domainInitialized);
                declaringType.DomainInitialized = domainInitialized;
                return retVal;
            }
        }
Пример #5
0
        internal object InternalGetValue(object obj, bool doVisibilityCheck, bool doCheckConsistency)
        {
            INVOCATION_FLAGS invocationFlags = this.InvocationFlags;
            RuntimeType      declaringType   = this.DeclaringType as RuntimeType;

            if ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NO_INVOKE) != INVOCATION_FLAGS.INVOCATION_FLAGS_UNKNOWN)
            {
                if ((declaringType != null) && this.DeclaringType.ContainsGenericParameters)
                {
                    throw new InvalidOperationException(Environment.GetResourceString("Arg_UnboundGenField"));
                }
                if (((declaringType != null) || !this.Module.Assembly.ReflectionOnly) && !(declaringType is ReflectionOnlyType))
                {
                    throw new FieldAccessException();
                }
                throw new InvalidOperationException(Environment.GetResourceString("Arg_ReflectionOnlyField"));
            }
            if (doCheckConsistency)
            {
                this.CheckConsistency(obj);
            }
            RuntimeType fieldType = (RuntimeType)this.FieldType;

            if (doVisibilityCheck && ((invocationFlags & INVOCATION_FLAGS.INVOCATION_FLAGS_NEED_SECURITY) != INVOCATION_FLAGS.INVOCATION_FLAGS_UNKNOWN))
            {
                PerformVisibilityCheckOnField(this.m_fieldHandle, obj, base.m_declaringType, this.m_fieldAttributes, (uint)(this.m_invocationFlags & ~INVOCATION_FLAGS.INVOCATION_FLAGS_IS_CTOR));
            }
            bool domainInitialized = false;

            if (declaringType == null)
            {
                return(RuntimeFieldHandle.GetValue(this, obj, fieldType, null, ref domainInitialized));
            }
            domainInitialized = declaringType.DomainInitialized;
            object obj2 = RuntimeFieldHandle.GetValue(this, obj, fieldType, declaringType, ref domainInitialized);

            declaringType.DomainInitialized = domainInitialized;
            return(obj2);
        }