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

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

            offset = reader.DecodeUnsigned(offset, out value);
            handle = new ConstantStringValueHandle((int)value);
            handle._Validate();
            return(offset);
        } // Read
Пример #2
0
        public static bool GetAttributeNamespaceAndName(this MetadataReader metadataReader, CustomAttributeHandle attributeHandle,
            out string namespaceString, out ConstantStringValueHandle nameHandle)
        {
            Handle attributeType, attributeCtor;
            if (!GetAttributeTypeAndConstructor(metadataReader, attributeHandle, out attributeType, out attributeCtor))
            {
                namespaceString = null;
                nameHandle = default(ConstantStringValueHandle);
                return false;
            }

            return GetAttributeTypeNamespaceAndName(metadataReader, attributeType, out namespaceString, out nameHandle);
        }
Пример #3
0
        public static bool GetAttributeTypeNamespaceAndName(this MetadataReader metadataReader, Handle attributeType,
            out string namespaceString, out ConstantStringValueHandle nameHandle)
        {
            namespaceString = null;
            nameHandle = default(ConstantStringValueHandle);

            if (attributeType.HandleType == HandleType.TypeReference)
            {
                TypeReference typeRefRow = metadataReader.GetTypeReference(attributeType.ToTypeReferenceHandle(metadataReader));
                HandleType handleType = typeRefRow.ParentNamespaceOrType.HandleType;

                // Nested type?
                if (handleType == HandleType.TypeReference || handleType == HandleType.TypeDefinition)
                    return false;

                nameHandle = typeRefRow.TypeName;
                namespaceString = metadataReader.GetNamespaceName(typeRefRow.ParentNamespaceOrType.ToNamespaceReferenceHandle(metadataReader));
                return true;
            }
            else if (attributeType.HandleType == HandleType.TypeDefinition)
            {
                var def = metadataReader.GetTypeDefinition(attributeType.ToTypeDefinitionHandle(metadataReader));

                // Nested type?
                if (IsNested(def.Flags))
                    return false;

                nameHandle = def.Name;
                namespaceString = metadataReader.GetNamespaceName(def.NamespaceDefinition);
                return true;
            }
            else
            {
                // unsupported metadata
                return false;
            }
        }
Пример #4
0
 internal bool StringEquals(ConstantStringValueHandle handle, string value)
 {
     return(_streamReader.StringEquals((uint)handle.Offset, value));
 }
Пример #5
0
 public static string GetString(this MetadataReader reader, ConstantStringValueHandle handle)
 {
     return(reader.GetConstantStringValue(handle).Value);
 }
Пример #6
0
 internal bool StringEquals(ConstantStringValueHandle handle, string value)
 {
     return _streamReader.StringEquals((uint)handle.Offset, value);
 }
Пример #7
0
 public static string GetString(this MetadataReader reader, ConstantStringValueHandle handle)
 {
     return reader.GetConstantStringValue(handle).Value;
 }
        private static RuntimeAssemblyName CreateRuntimeAssemblyNameFromMetadata(
            MetadataReader reader,
            ConstantStringValueHandle name,
            ushort majorVersion,
            ushort minorVersion,
            ushort buildNumber,
            ushort revisionNumber,
            ConstantStringValueHandle culture,
            IEnumerable<byte> publicKeyOrToken,
            AssemblyFlags assemblyFlags)
        {
            AssemblyNameFlags assemblyNameFlags = AssemblyNameFlags.None;
            if (0 != (assemblyFlags & AssemblyFlags.PublicKey))
                assemblyNameFlags |= AssemblyNameFlags.PublicKey;
            if (0 != (assemblyFlags & AssemblyFlags.Retargetable))
                assemblyNameFlags |= AssemblyNameFlags.Retargetable;
            int contentType = ((int)assemblyFlags) & 0x00000E00;
            assemblyNameFlags |= (AssemblyNameFlags)contentType;

            return new RuntimeAssemblyName(
                name.GetString(reader),
                new Version(majorVersion, minorVersion, buildNumber, revisionNumber),
                culture.GetStringOrNull(reader),
                assemblyNameFlags,
                publicKeyOrToken.ToArray()
                );
        }
Пример #9
0
 public sealed override bool Matches(ConstantStringValueHandle stringHandle, MetadataReader reader) => stringHandle.GetConstantStringValue(reader).Value.Equals(ExpectedName, StringComparison.OrdinalIgnoreCase);
Пример #10
0
 public sealed override bool Matches(ConstantStringValueHandle stringHandle, MetadataReader reader) => stringHandle.StringEquals(ExpectedName, reader);
Пример #11
0
 public abstract bool Matches(ConstantStringValueHandle stringHandle, MetadataReader reader);
Пример #12
0
        } // IsNull

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

        internal Handle ToHandle(ConstantStringValueHandle handle)
        {
            return new Handle(handle._value);
        } // ToHandle
Пример #14
0
        } // GetConstantStringArray

        public ConstantStringValue GetConstantStringValue(ConstantStringValueHandle handle)
        {
            if (IsNull(handle))
                return new ConstantStringValue();
            var record = new ConstantStringValue() { _reader = this, _handle = handle };
            var offset = (uint)handle.Offset;
            offset = _streamReader.Read(offset, out record._value);
            return record;
        } // GetConstantStringValue
Пример #15
0
        } // Equals

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

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

        public static uint Read(this NativeReader reader, uint offset, out ConstantStringValueHandle[] values)
        {
            uint count;
            offset = reader.DecodeUnsigned(offset, out count);
            if (count == 0)
            {
                values = s_emptyConstantStringValueHandleArray;
            }
            else
            {
                values = new ConstantStringValueHandle[count];
                for (uint i = 0; i < count; ++i)
                {
                    ConstantStringValueHandle tmp;
                    offset = reader.Read(offset, out tmp);
                    values[i] = tmp;
                }
            }
            return offset;
        } // Read
Пример #18
0
        } // Read

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