Beispiel #1
0
 private static void RegisterAssemblyThresholds(System.Reflection.Assembly assembly)
 {
     // does the loaded assembly refer to this one (if it doesn't, it can't have the stuff we're looking for)
     if (assembly.DoesAssemblyReferToAssembly(System.Reflection.Assembly.GetExecutingAssembly()))
     {
         // loop through all the types looking for types that are not abstract, inherit from StatusNode (directly or indirectly) and have a public empty constructor
         foreach (Type type in assembly.GetLoadableTypes())
         {
             if (Status.IsTestableStatusCheckerClass(type))
             {
                 foreach (KeyValuePair <string, StatusPropertyThresholds> kvp in GetThresholds(type))
                 {
                     _thresholds.TryAdd(kvp.Key.ToUpperInvariant(), kvp.Value);
                 }
             }
         }
     }
 }
        private static void FilterTypes(Assembly assembly, SystemTypeAttribute filter, ICollection <Type> excludedTypes, List <Type> output)
        {
            foreach (var type in assembly.GetLoadableTypes())
            {
                bool isValid = type.IsValueType && !type.IsEnum || type.IsClass;
                if (!type.IsVisible || !isValid)
                {
                    continue;
                }

                if (filter != null && !filter.IsConstraintSatisfied(type))
                {
                    continue;
                }

                if (excludedTypes != null && excludedTypes.Contains(type))
                {
                    continue;
                }

                output.Add(type);
            }
        }