Esempio n. 1
0
        private AttributeNode GetPermissionAttribute2(MemoryCursor/*!*/ sigReader, System.Security.Permissions.SecurityAction action)
        {
            int typeNameLength = sigReader.ReadCompressedInt();
            string serializedTypeName = sigReader.ReadUTF8(typeNameLength);
            TypeNode attrType = null;
            try
            {
                attrType = this.GetTypeFromSerializedName(serializedTypeName);
            }
            catch (InvalidMetadataException) { }
            if (attrType == null)
            {
                HandleError(this.module, String.Format(CultureInfo.CurrentCulture, ExceptionStrings.CouldNotResolveType, serializedTypeName));
                return null;
            }
            InstanceInitializer cons = attrType.GetConstructor(CoreSystemTypes.SecurityAction);
            if (cons == null)
            {
                HandleError(this.module, String.Format(CultureInfo.CurrentCulture,
                ExceptionStrings.SecurityAttributeTypeDoesNotHaveADefaultConstructor, serializedTypeName));
                return null;
            }

            sigReader.ReadCompressedInt(); //caBlobLength

            int numProps = sigReader.ReadCompressedInt(); //Skip over the number of properties in the CA blob

            ExpressionList arguments = new ExpressionList();

            arguments.Add(new Literal(action, CoreSystemTypes.SecurityAction));

            this.GetCustomAttributeNamedArguments(arguments, (ushort)numProps, sigReader);

            return new AttributeNode(new MemberBinding(null, cons), arguments);
        }
Esempio n. 2
0
 private static string ReadSerString(MemoryCursor/*!*/ sigReader)
 {
     int n = sigReader.ReadCompressedInt();
     if (n < 0) return null;
     return sigReader.ReadUTF8(n);
 }
Esempio n. 3
0
 private AttributeNode GetPermissionAttribute(MemoryCursor/*!*/ sigReader)
 {
     sigReader.ReadInt32(); //Skip over index
     int typeNameLength = sigReader.ReadInt32();
     sigReader.ReadUTF8(typeNameLength); //Skip over type name
     int constructorToken = sigReader.ReadInt32();
     sigReader.ReadInt32(); //Skip over attribute type token
     sigReader.ReadInt32(); //Skip over assembly ref token
     int caBlobLength = sigReader.ReadInt32();
     sigReader.ReadInt32(); //Skip over the number of parameters in the CA blob
     TypeNodeList varArgTypes; //Ignored because vararg constructors are not allowed in Custom Attributes
     Method cons = this.GetConstructorDefOrRef(constructorToken, out varArgTypes);
     if (cons == null) cons = new Method();
     return this.GetCustomAttribute(cons, sigReader, caBlobLength);
 }