public UnresolvedSecurityDeclarationBlob(int securityAction, byte[] blob)
        {
            BlobReader reader = new BlobReader(blob, null);

            this.securityAction = new SimpleConstantValue(securityActionTypeReference, securityAction);
            this.blob           = blob;
            if (reader.ReadByte() == '.')
            {
                // binary attribute
                uint attributeCount = reader.ReadCompressedUInt32();
                for (uint i = 0; i < attributeCount; i++)
                {
                    unresolvedAttributes.Add(new UnresolvedSecurityAttribute(this, (int)i));
                }
            }
            else
            {
                // for backward compatibility with .NET 1.0: XML-encoded attribute
                var attr = new DefaultUnresolvedAttribute(permissionSetAttributeTypeReference);
                attr.ConstructorParameterTypes.Add(securityActionTypeReference);
                attr.PositionalArguments.Add(this.securityAction);
                string xml = System.Text.Encoding.Unicode.GetString(blob);
                attr.AddNamedPropertyArgument("XML", new SimpleConstantValue(KnownTypeReference.String, xml));
                unresolvedAttributes.Add(attr);
            }
        }
            public DefaultResolvedAttribute(DefaultUnresolvedAttribute unresolved, ITypeResolveContext context)
            {
                this.unresolved = unresolved;
                this.context    = context;

                this.attributeType       = unresolved.AttributeType.Resolve(context);
                this.positionalArguments = unresolved.PositionalArguments.Resolve(context);
            }
        bool ISupportsInterning.EqualsForInterning(ISupportsInterning other)
        {
            DefaultUnresolvedAttribute o = other as DefaultUnresolvedAttribute;

            return(o != null && attributeType == o.attributeType &&
                   ListEquals(constructorParameterTypes, o.constructorParameterTypes) &&
                   ListEquals(positionalArguments, o.positionalArguments) &&
                   ListEquals(namedArguments ?? EmptyList <KeyValuePair <IMemberReference, IConstantValue> > .Instance,
                              o.namedArguments ?? EmptyList <KeyValuePair <IMemberReference, IConstantValue> > .Instance));
        }
        /// <summary>
        /// Adds a type forwarder.
        /// This adds both an assembly attribute and an internal forwarder entry, which will be used
        /// by the resolved assembly to provide the forwarded types.
        /// </summary>
        /// <param name="typeName">The name of the type.</param>
        /// <param name="referencedType">The reference used to look up the type in the target assembly.</param>
        public void AddTypeForwarder(TopLevelTypeName typeName, ITypeReference referencedType)
        {
            if (referencedType == null)
            {
                throw new ArgumentNullException("referencedType");
            }
            FreezableHelper.ThrowIfFrozen(this);
            var attribute = new DefaultUnresolvedAttribute(typeForwardedToAttributeTypeRef, new[] { KnownTypeReference.Type });

            attribute.PositionalArguments.Add(new TypeOfConstantValue(referencedType));
            assemblyAttributes.Add(attribute);

            typeForwarders[typeName] = referencedType;
        }