예제 #1
0
        static void CheckRules(Database database)
        {
            RuleVisitor visitor = new RuleVisitor();

            Assembly thisAssembly = Assembly.GetExecutingAssembly();

            PopulateRuleVisitorFromAssembly(visitor, thisAssembly);

            database.Visit(visitor);
        }
예제 #2
0
        private static void PopulateRuleVisitorFromAssembly(RuleVisitor visitor, Assembly assembly)
        {
            Type[] types = assembly.GetExportedTypes();

            foreach (Type type in types)
            {
                if (type.IsSubclassOf(typeof(Rule)) && type != typeof(Rule))
                {
                    ConstructorInfo constructor = type.GetConstructor(new Type[0]);

                    Rule rule = constructor.Invoke(new object[0]) as Rule;

                    visitor.AddRule(rule);
                }
            }
        }