Пример #1
0
        } // Read

        public static uint Read(this NativeReader reader, uint offset, out FixedArgumentHandle[] values)
        {
            uint count;
            offset = reader.DecodeUnsigned(offset, out count);
            if (count == 0)
            {
                values = s_emptyFixedArgumentHandleArray;
            }
            else
            {
                values = new FixedArgumentHandle[count];
                for (uint i = 0; i < count; ++i)
                {
                    FixedArgumentHandle tmp;
                    offset = reader.Read(offset, out tmp);
                    values[i] = tmp;
                }
            }
            return offset;
        } // Read
        // Equals/GetHashCode no need to override (they just implement reference equality but desktop never unified these things.)

        //
        // Helper for parsing custom attribute arguments.
        //
        // If throwIfMissingMetadata is false, returns default(CustomAttributeTypedArgument) rather than throwing a MissingMetadataException.
        //
        private CustomAttributeTypedArgument ParseFixedArgument(MetadataReader reader, FixedArgumentHandle fixedArgumentHandle, bool throwIfMissingMetadata, Func<RuntimeTypeInfo> getTypeFromConstructor)
        {
            FixedArgument fixedArgument = fixedArgumentHandle.GetFixedArgument(reader);
            RuntimeTypeInfo argumentType = null;
            if (fixedArgument.Type.IsNull(reader))
            {
                argumentType = getTypeFromConstructor();
                if (argumentType == null)
                {
                    Debug.Assert(!throwIfMissingMetadata);
                    return default(CustomAttributeTypedArgument);
                }
            }
            else
            {
                Exception exception = null;
                argumentType = fixedArgument.Type.TryResolve(reader, new TypeContext(null, null), ref exception);
                if (argumentType == null)
                {
                    if (throwIfMissingMetadata)
                        throw exception;
                    else
                        return default(CustomAttributeTypedArgument);
                }
            }

            Object value;
            Exception e = fixedArgument.Value.TryParseConstantValue(reader, out value);
            if (e != null)
            {
                if (throwIfMissingMetadata)
                    throw e;
                else
                    return default(CustomAttributeTypedArgument);
            }
            return WrapInCustomAttributeTypedArgument(value, argumentType);
        }
Пример #3
0
        } // Read

        public static uint Read(this NativeReader reader, uint offset, out FixedArgumentHandle handle)
        {
            uint value;
            offset = reader.DecodeUnsigned(offset, out value);
            handle = new FixedArgumentHandle((int)value);
            handle._Validate();
            return offset;
        } // Read
Пример #4
0
        } // IsNull

        internal bool IsNull(FixedArgumentHandle handle)
        {
            return (handle._value & 0x00FFFFFF) == 0;
        } // IsNull
Пример #5
0
        } // ToHandle

        internal Handle ToHandle(FixedArgumentHandle handle)
        {
            return new Handle(handle._value);
        } // ToHandle
Пример #6
0
        } // GetFieldSignature

        public FixedArgument GetFixedArgument(FixedArgumentHandle handle)
        {
            var record = new FixedArgument() { _reader = this, _handle = handle };
            var offset = (uint)handle.Offset;
            offset = _streamReader.Read(offset, out record._flags);
            offset = _streamReader.Read(offset, out record._type);
            offset = _streamReader.Read(offset, out record._value);
            return record;
        } // GetFixedArgument
Пример #7
0
        } // Equals

        public bool Equals(FixedArgumentHandle handle)
        {
            return _value == handle._value;
        } // Equals
Пример #8
0
        } // Read

        public static uint Read(this NativeReader reader, uint offset, out FixedArgumentHandle[] values)
        {
            uint count;
            offset = reader.DecodeUnsigned(offset, out count);
            #if !NETFX_45
            if (count == 0)
            {
                values = Array.Empty<FixedArgumentHandle>();
            }
            else
            #endif
            {
                values = new FixedArgumentHandle[count];
                for (uint i = 0; i < count; ++i)
                {
                    FixedArgumentHandle tmp;
                    offset = reader.Read(offset, out tmp);
                    values[i] = tmp;
                }
            }
            return offset;
        } // Read