예제 #1
0
 public static int CompareToSecurityAttribute(this SecurityAttribute first, SecurityAttribute second, SecurityDeclaration firstDeclaration, SecurityDeclaration secondDeclaration)
 {
     if ((object)first == (object)second)
     {
         return(0);
     }
     V_0 = firstDeclaration.get_Action().ToString();
     V_1 = secondDeclaration.get_Action().ToString();
     if (String.op_Inequality(V_0, V_1))
     {
         return(V_0.CompareTo(V_1));
     }
     V_2 = Math.Max(first.get_Properties().get_Count(), second.get_Properties().get_Count());
     V_5 = 0;
     while (V_5 < V_2)
     {
         if (V_5 >= first.get_Properties().get_Count())
         {
             return(1);
         }
         if (V_5 >= second.get_Properties().get_Count())
         {
             return(-1);
         }
         V_6 = first.get_Properties().get_Item(V_5);
         V_7 = second.get_Properties().get_Item(V_5);
         if (!String.op_Equality(V_6.get_Name(), V_7.get_Name()))
         {
             return(V_6.get_Name().CompareTo(V_7.get_Name()));
         }
         V_10 = V_6.get_Argument();
         V_8  = V_10.get_Value().ToString();
         V_10 = V_7.get_Argument();
         V_9  = V_10.get_Value().ToString();
         if (String.op_Inequality(V_8, V_9))
         {
             return(V_8.CompareTo(V_9));
         }
         V_5 = V_5 + 1;
     }
     V_3  = Math.Max(first.get_Fields().get_Count(), second.get_Fields().get_Count());
     V_11 = 0;
     while (V_11 < V_3)
     {
         if (V_11 >= first.get_Fields().get_Count())
         {
             return(1);
         }
         if (V_11 >= second.get_Fields().get_Count())
         {
             return(-1);
         }
         V_12 = first.get_Fields().get_Item(V_11);
         V_13 = second.get_Fields().get_Item(V_11);
         if (!String.op_Equality(V_12.get_Name(), V_13.get_Name()))
         {
             return(V_12.get_Name().CompareTo(V_13.get_Name()));
         }
         V_10 = V_12.get_Argument();
         V_14 = V_10.get_Value().ToString();
         V_10 = V_13.get_Argument();
         V_15 = V_10.get_Value().ToString();
         if (String.op_Inequality(V_14, V_15))
         {
             return(V_14.CompareTo(V_15));
         }
         V_11 = V_11 + 1;
     }
     return(0);
 }
예제 #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);
 }