public static DefaultRuleProvider Create(Settings settings)
        {
            var result = new DefaultRuleProvider();

            // Inject rules using MEF
            var config = new ContainerConfiguration();
            var assemblyPath = Assembly.LoadFrom(ConfigManager.Current.RuleLibraryPath);
            config.WithAssembly(assemblyPath);

            using (var container = config.CreateContainer())
            {
                container.SatisfyImports(result);
            }

            // Set rules settings
            foreach (var rule in result.Rules)
            {
                rule.Settings = settings;
            }

            return result;
        }
        public static DefaultRuleProvider Create(Settings settings)
        {
            var result = new DefaultRuleProvider();

            // Inject rules using MEF
            var config       = new ContainerConfiguration();
            var assemblyPath = Assembly.LoadFrom(ConfigManager.Current.RuleLibraryPath);

            config.WithAssembly(assemblyPath);

            using (var container = config.CreateContainer())
            {
                container.SatisfyImports(result);
            }

            // Set rules settings
            foreach (var rule in result.Rules)
            {
                rule.Settings = settings;
            }

            return(result);
        }
示例#3
0
 public Critic(RuleContext context, Settings settings = null, IRuleProvider ruleProvider = null)
 {
     Context      = context;
     Settings     = settings ?? new Settings();
     RuleProvider = ruleProvider ?? DefaultRuleProvider.Create(Settings);
 }