internal static CustomAttributeValue <TypeDescription>?FindAssemblyAttribute(this MetadataReader reader, AttributeDescription attributeDescription, IEnumerable <KnownEnumType> knownEnumTypes)
        {
            foreach (CustomAttribute attribute in reader.CustomAttributes.Select(reader.GetCustomAttribute))
            {
                var actualName = MetadataTypeIdentifier.GetFrom(reader, attribute);
                if (actualName.FullName.Equals(attributeDescription.TypeName.FullName))
                {
                    var attributeData = attribute.DecodeValue(new TypeDescriptionCustomAttributeProvider(knownEnumTypes));

                    if (attributeDescription.Signatures.Any(signature => signature.SequenceEqual(attributeData.FixedArguments.Select(arg => arg.Type))))
                    {
                        return(attributeData);
                    }
                }
            }

            return(null);
        }
Пример #2
0
        public TypeDescription GetTypeFromSerializedName(string name)
        {
            var type = Type.GetType(name, false).GetTypeInfo();

            if (type != null)
            {
                var typeDesc = PrimitiveTypeDescription.TryGetFrom(type);
                if (typeDesc != null)
                {
                    return(typeDesc);
                }

                if (type.Equals(typeof(Type)))
                {
                    return(SystemTypeDescription.Instance);
                }
            }

            return(new TypeHandleTypeDescription(MetadataTypeIdentifier.GetFrom(name)));
        }
 public AttributeDescription(string fullTypeName, params IReadOnlyList <TypeDescription>[] signatures)
     : this(MetadataTypeIdentifier.GetFrom(fullTypeName), signatures)
 {
 }
Пример #4
0
 public TypeHandleTypeDescription(MetadataReader reader, EntityHandle handle)
 {
     TypeName = MetadataTypeIdentifier.GetFrom(reader, handle);
 }