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

        public static uint Read(this NativeReader reader, uint offset, out ConstantEnumArrayHandle handle)
        {
            uint value;

            offset = reader.DecodeUnsigned(offset, out value);
            handle = new ConstantEnumArrayHandle((int)value);
            handle._Validate();
            return(offset);
        } // Read
Пример #2
0
        private static Array TryParseConstantEnumArray(this ConstantEnumArrayHandle handle, MetadataReader reader, out Exception exception)
        {
            exception = null;

            ConstantEnumArray enumArray = handle.GetConstantEnumArray(reader);
            Type elementType            = enumArray.ElementType.TryResolve(reader, new TypeContext(null, null), ref exception);

            if (exception != null)
            {
                return(null);
            }

            switch (enumArray.Value.HandleType)
            {
            case HandleType.ConstantByteArray:
                return(enumArray.Value.ToConstantByteArrayHandle(reader).GetConstantByteArray(reader).Value.ToArray(elementType));

            case HandleType.ConstantSByteArray:
                return(enumArray.Value.ToConstantSByteArrayHandle(reader).GetConstantSByteArray(reader).Value.ToArray(elementType));

            case HandleType.ConstantInt16Array:
                return(enumArray.Value.ToConstantInt16ArrayHandle(reader).GetConstantInt16Array(reader).Value.ToArray(elementType));

            case HandleType.ConstantUInt16Array:
                return(enumArray.Value.ToConstantUInt16ArrayHandle(reader).GetConstantUInt16Array(reader).Value.ToArray(elementType));

            case HandleType.ConstantInt32Array:
                return(enumArray.Value.ToConstantInt32ArrayHandle(reader).GetConstantInt32Array(reader).Value.ToArray(elementType));

            case HandleType.ConstantUInt32Array:
                return(enumArray.Value.ToConstantUInt32ArrayHandle(reader).GetConstantUInt32Array(reader).Value.ToArray(elementType));

            case HandleType.ConstantInt64Array:
                return(enumArray.Value.ToConstantInt64ArrayHandle(reader).GetConstantInt64Array(reader).Value.ToArray(elementType));

            case HandleType.ConstantUInt64Array:
                return(enumArray.Value.ToConstantUInt64ArrayHandle(reader).GetConstantUInt64Array(reader).Value.ToArray(elementType));

            default:
                throw new BadImageFormatException();
            }
        }