示例#1
0
        private void WriteSecurityAttribute(SecurityAttribute attribute)
        {
            this.WriteTypeReference(attribute.AttributeType);
            int namedArgumentCount = SignatureWriter.GetNamedArgumentCount(attribute);

            if (namedArgumentCount == 0)
            {
                base.WriteCompressedUInt32(1u);
                base.WriteCompressedUInt32(0u);
                return;
            }
            SignatureWriter signatureWriter = new SignatureWriter(this.metadata);

            signatureWriter.WriteCompressedUInt32((uint)namedArgumentCount);
            signatureWriter.WriteICustomAttributeNamedArguments(attribute);
            base.WriteCompressedUInt32((uint)signatureWriter.length);
            base.WriteBytes(signatureWriter);
        }
示例#2
0
        private static string GetXmlSecurityDeclaration(SecurityDeclaration declaration)
        {
            if (declaration.security_attributes == null || declaration.security_attributes.Count != 1)
            {
                return(null);
            }
            SecurityAttribute securityAttribute = declaration.security_attributes[0];

            if (!securityAttribute.AttributeType.IsTypeOf("System.Security.Permissions", "PermissionSetAttribute"))
            {
                return(null);
            }
            if (securityAttribute.properties == null || securityAttribute.properties.Count != 1)
            {
                return(null);
            }
            CustomAttributeNamedArgument customAttributeNamedArgument = securityAttribute.properties[0];

            if (customAttributeNamedArgument.Name != "XML")
            {
                return(null);
            }
            return((string)customAttributeNamedArgument.Argument.Value);
        }