private static IEnumerable <IValidationRule> ValidationRulesFor(RuntimePlatform platform, params object[] options)
 {
     return(from t in AssemblyValidation.ValidationRuleTypesFor(platform)
            select AssemblyValidation.CreateValidationRuleWithOptions(t, options) into v
                where v != null
            select v);
 }
 internal static void RegisterValidationRule(System.Type type)
 {
     foreach (AssemblyValidationRule assemblyValidationRule in AssemblyValidation.ValidationRuleAttributesFor(type))
     {
         AssemblyValidation.RegisterValidationRuleForPlatform(assemblyValidationRule.Platform, type);
     }
 }
    private static IValidationRule CreateValidationRuleWithOptions(System.Type type, params object[] options)
    {
        List <object> objectList = new List <object>((IEnumerable <object>)options);

        object[]        array;
        ConstructorInfo constructorInfo;

        while (true)
        {
            array           = objectList.ToArray();
            constructorInfo = AssemblyValidation.ConstructorFor(type, (IEnumerable <object>)array);
            if (constructorInfo == null)
            {
                if (objectList.Count != 0)
                {
                    objectList.RemoveAt(objectList.Count - 1);
                }
                else
                {
                    goto label_4;
                }
            }
            else
            {
                break;
            }
        }
        return((IValidationRule)constructorInfo.Invoke(array));

label_4:
        return((IValidationRule)null);
    }
 private static IEnumerable <IValidationRule> ValidationRulesFor(RuntimePlatform platform, params object[] options)
 {
     // ISSUE: object of a compiler-generated type is created
     // ISSUE: reference to a compiler-generated method
     return(AssemblyValidation.ValidationRuleTypesFor(platform).Select <System.Type, IValidationRule>(new Func <System.Type, IValidationRule>(new AssemblyValidation.\u003CValidationRulesFor\u003Ec__AnonStorey69()
     {
         options = options
     }.\u003C\u003Em__E0)).Where <IValidationRule>((Func <IValidationRule, bool>)(v => v != null)));
 }
 private static int PriorityFor(System.Type type, RuntimePlatform platform)
 {
     // ISSUE: object of a compiler-generated type is created
     // ISSUE: reference to a compiler-generated method
     return(AssemblyValidation.ValidationRuleAttributesFor(type).Where <AssemblyValidationRule>(new Func <AssemblyValidationRule, bool>(new AssemblyValidation.\u003CPriorityFor\u003Ec__AnonStorey6B()
     {
         platform = platform
     }.\u003C\u003Em__E4)).Select <AssemblyValidationRule, int>((Func <AssemblyValidationRule, int>)(attr => attr.Priority)).FirstOrDefault <int>());
 }
    internal static int CompareValidationRulesByPriority(System.Type a, System.Type b, RuntimePlatform platform)
    {
        int num1 = AssemblyValidation.PriorityFor(a, platform);
        int num2 = AssemblyValidation.PriorityFor(b, platform);

        if (num1 == num2)
        {
            return(0);
        }
        return(num1 < num2 ? -1 : 1);
    }
 private static void WarmUpRulesCache()
 {
     if (AssemblyValidation._rulesByPlatform != null)
     {
         return;
     }
     AssemblyValidation._rulesByPlatform = new Dictionary <RuntimePlatform, List <System.Type> >();
     foreach (System.Type type in ((IEnumerable <System.Type>) typeof(AssemblyValidation).Assembly.GetTypes()).Where <System.Type>(new Func <System.Type, bool>(AssemblyValidation.IsValidationRule)))
     {
         AssemblyValidation.RegisterValidationRule(type);
     }
 }
    private static void WarmUpRulesCache()
    {
        if (AssemblyValidation._rulesByPlatform != null)
        {
            return;
        }
        AssemblyValidation._rulesByPlatform = new Dictionary <RuntimePlatform, List <Type> >();
        Assembly assembly = typeof(AssemblyValidation).Assembly;

        foreach (Type current in assembly.GetTypes().Where(new Func <Type, bool>(AssemblyValidation.IsValidationRule)))
        {
            AssemblyValidation.RegisterValidationRule(current);
        }
    }
Esempio n. 9
0
 private static void WarmUpRulesCache()
 {
     if (AssemblyValidation._rulesByPlatform == null)
     {
         AssemblyValidation._rulesByPlatform = new Dictionary <RuntimePlatform, List <Type> >();
         Assembly           assembly = typeof(AssemblyValidation).Assembly;
         IEnumerable <Type> arg_4E_0 = assembly.GetTypes();
         if (AssemblyValidation.< > f__mg$cache0 == null)
         {
             AssemblyValidation.< > f__mg$cache0 = new Func <Type, bool>(AssemblyValidation.IsValidationRule);
         }
         foreach (Type current in arg_4E_0.Where(AssemblyValidation.< > f__mg$cache0))
         {
             AssemblyValidation.RegisterValidationRule(current);
         }
     }
 }
Esempio n. 10
0
 public static ValidationResult Validate(RuntimePlatform platform, IEnumerable <string> userAssemblies, params object[] options)
 {
     AssemblyValidation.WarmUpRulesCache();
     string[] array = (userAssemblies as string[]) ?? userAssemblies.ToArray <string>();
     if (array.Length != 0)
     {
         foreach (IValidationRule current in AssemblyValidation.ValidationRulesFor(platform, options))
         {
             ValidationResult result = current.Validate(array, options);
             if (!result.Success)
             {
                 return(result);
             }
         }
     }
     return(new ValidationResult
     {
         Success = true
     });
 }
 public static ValidationResult Validate(RuntimePlatform platform, IEnumerable <string> userAssemblies, params object[] options)
 {
     AssemblyValidation.WarmUpRulesCache();
     string[] strArray = userAssemblies as string[] ?? userAssemblies.ToArray <string>();
     if (strArray.Length != 0)
     {
         foreach (IValidationRule validationRule in AssemblyValidation.ValidationRulesFor(platform, options))
         {
             ValidationResult validationResult = validationRule.Validate((IEnumerable <string>)strArray, options);
             if (!validationResult.Success)
             {
                 return(validationResult);
             }
         }
     }
     return(new ValidationResult()
     {
         Success = true
     });
 }
Esempio n. 12
0
 private static bool IsValidationRule(Type type)
 {
     return(AssemblyValidation.ValidationRuleAttributesFor(type).Any <AssemblyValidationRule>());
 }