private void WriteSingleSecurityAttributes(SecurityAttribute attribute)
 {
     this.WriteType(attribute.get_AttributeType(), 2);
     if (attribute.get_HasProperties())
     {
         this.WriteSpace();
         this.Write("=");
         this.WriteLine();
         this.WriteOpenBreckets();
         this.WriteLine();
         this.Indent();
         V_0 = attribute.get_Properties().GetEnumerator();
         try
         {
             while (V_0.MoveNext())
             {
                 V_1 = V_0.get_Current();
                 this.WriteKeyword("property");
                 this.WriteSpace();
                 V_2 = V_1.get_Argument();
                 this.WriteType(V_2.get_Type(), 2);
                 this.WriteSpace();
                 this.WriteLiteral("'");
                 this.WriteLiteral(V_1.get_Name());
                 this.WriteLiteral("'");
                 this.WriteSpace();
                 this.Write("=");
                 this.WriteSpace();
                 V_2 = V_1.get_Argument();
                 this.WriteType(V_2.get_Type(), 2);
                 this.WriteSpace();
                 this.Write("(");
                 if (V_1.get_Argument().get_Value() as Boolean == false)
                 {
                     if (V_1.get_Argument().get_Value() as String == null)
                     {
                         V_2 = V_1.get_Argument();
                         this.WriteLiteral(V_2.get_Value().ToString());
                     }
                     else
                     {
                         V_2 = V_1.get_Argument();
                         this.WriteStringLiteral((String)V_2.get_Value());
                     }
                 }
                 else
                 {
                     V_2 = V_1.get_Argument();
                     this.WriteBooleanLiteral((Boolean)V_2.get_Value());
                 }
                 this.Write(")");
                 this.WriteLine();
             }
         }
         finally
         {
             V_0.Dispose();
         }
         this.Outdent();
         this.WriteEndBreckets();
     }
     return;
 }
示例#2
0
 private bool WriteSecurityAttribute(ModuleDefinition module, bool isAssemblyDeclaration, SecurityAttribute attribute, SecurityDeclaration securityDeclaration, out bool wroteArgument, bool skipTheNewLine = false, bool isReturnValueAttribute = false)
 {
     this.genericWriter.WriteToken(this.get_OpeningBracket());
     if (!isAssemblyDeclaration)
     {
         if (isReturnValueAttribute)
         {
             this.WriteReturnValueAttributeKeyword();
         }
     }
     else
     {
         this.genericWriter.WriteKeyword(this.genericWriter.get_KeyWordWriter().get_Assembly());
         this.genericWriter.Write(":");
         this.genericWriter.WriteSpace();
     }
     if (attribute.get_AttributeType().get_Name().EndsWith("Attribute"))
     {
         stackVariable19 = attribute.get_AttributeType().get_Name().Remove(attribute.get_AttributeType().get_Name().LastIndexOf("Attribute"));
     }
     else
     {
         stackVariable19 = attribute.get_AttributeType().get_Name();
     }
     V_0 = stackVariable19;
     this.genericWriter.WriteNamespaceIfTypeInCollision(attribute.get_AttributeType());
     this.genericWriter.WriteReference(V_0, attribute.get_AttributeType());
     this.genericWriter.WriteToken("(");
     V_1 = securityDeclaration.GetSecurityActionTypeReference(module);
     if (V_1.get_IsDefinition())
     {
         stackVariable38 = V_1 as TypeDefinition;
     }
     else
     {
         stackVariable38 = V_1.Resolve();
     }
     V_2 = stackVariable38;
     if (V_2 != null && V_2.get_IsEnum())
     {
         V_3 = EnumValueToFieldCombinationMatcher.GetEnumFieldDefinitionByValue(V_2.get_Fields(), (Int32)securityDeclaration.get_Action(), V_2.get_CustomAttributes());
         if (V_3.get_Count() == 0)
         {
             this.WriteSecurityAttributeAction(securityDeclaration.get_Action());
         }
         else
         {
             V_4 = 0;
             while (V_4 < V_3.get_Count())
             {
                 this.genericWriter.WriteReferenceAndNamespaceIfInCollision(V_3.get_Item(V_4).get_DeclaringType());
                 this.genericWriter.WriteToken(".");
                 this.genericWriter.WriteEnumValueField(V_3.get_Item(V_4));
                 if (V_4 + 1 < V_3.get_Count())
                 {
                     this.genericWriter.WriteSpace();
                     this.genericWriter.WriteBitwiseOr();
                     this.genericWriter.WriteSpace();
                 }
                 V_4 = V_4 + 1;
             }
         }
     }
     wroteArgument = true;
     if (attribute.get_HasFields() || attribute.get_HasProperties())
     {
         V_5 = attribute.get_AttributeType().Resolve();
         if (attribute.get_HasProperties())
         {
             wroteArgument = this.WriteAttributeNamedArgs(V_5, attribute.get_Properties(), false, wroteArgument);
         }
         if (attribute.get_HasFields())
         {
             dummyVar0 = this.WriteAttributeNamedArgs(V_5, attribute.get_Fields(), true, wroteArgument);
         }
     }
     this.genericWriter.WriteToken(")");
     this.genericWriter.WriteToken(this.get_ClosingBracket());
     if (!skipTheNewLine)
     {
         this.genericWriter.WriteLine();
     }
     return(wroteArgument);
 }