protected IModifyXmlDocumentHandler GetPreprocessor(string sectionName, IFileManager fileMgr) { // lets check for custom rule config processor configuration string ruleConfigSectionName = sectionName + ".ruleprocessor"; object ruleConfigObj = ConfigurationSettings.GetConfig(ruleConfigSectionName); if (ruleConfigObj != null) { if (!(ruleConfigObj is IComponentsConfig)) { throw new ConfigurationException(String.Format("Invalid configuration section '{0}': expected IComponentsConfig")); } if (log.IsEnabledFor(LogEvent.Debug)) { log.Write(LogEvent.Debug, new{ Action = "get rule processor", Msg = "found custom config", ConfigSectionName = ruleConfigSectionName }); } IComponentsConfig ruleConfig = (IComponentsConfig)ruleConfigObj; IServiceProvider srvPrv = new NReco.Winter.ServiceProvider(ruleConfig); XmlConfigRuleProcessor preprocessor = srvPrv.GetService(typeof(XmlConfigRuleProcessor)) as XmlConfigRuleProcessor; if (preprocessor != null) { preprocessor.FileManager = fileMgr; return(preprocessor); } else { log.Write(LogEvent.Warn, new{ Action = "get rule processor from custom config", Msg = "RuleConfigProcessor instance not found", ConfigSectionName = ruleConfigSectionName }); } } XmlConfigRuleProcessor defaultPreprocessor = new XmlConfigRuleProcessor(fileMgr); defaultPreprocessor.Rules = new IXmlConfigRule[] { new NReco.Transform.XslTransformXmlConfigRule() }; if (log.IsEnabledFor(LogEvent.Debug)) { log.Write(LogEvent.Debug, new{ Action = "get rule processor", Msg = "default rule processor is used" }); } return(defaultPreprocessor); }
protected IModifyXmlDocumentHandler GetPreprocessor(string sectionName, IFileManager fileMgr) { // lets check for custom rule config processor configuration string ruleConfigSectionName = sectionName + ".ruleprocessor"; object ruleConfigObj = ConfigurationSettings.GetConfig(ruleConfigSectionName); if (ruleConfigObj!=null) { if (!(ruleConfigObj is IComponentsConfig)) throw new ConfigurationException(String.Format("Invalid configuration section '{0}': expected IComponentsConfig")); if (log.IsEnabledFor(LogEvent.Debug)) log.Write(LogEvent.Debug, new{Action="get rule processor",Msg="found custom config",ConfigSectionName=ruleConfigSectionName}); IComponentsConfig ruleConfig = (IComponentsConfig)ruleConfigObj; IServiceProvider srvPrv = new NReco.Winter.ServiceProvider(ruleConfig); XmlConfigRuleProcessor preprocessor = srvPrv.GetService(typeof(XmlConfigRuleProcessor)) as XmlConfigRuleProcessor; if (preprocessor!=null) { preprocessor.FileManager = fileMgr; return preprocessor; } else log.Write(LogEvent.Warn, new{Action="get rule processor from custom config", Msg="RuleConfigProcessor instance not found", ConfigSectionName=ruleConfigSectionName}); } XmlConfigRuleProcessor defaultPreprocessor = new XmlConfigRuleProcessor(fileMgr); defaultPreprocessor.Rules = new IXmlConfigRule[] { new NReco.Transform.XslTransformXmlConfigRule() }; if (log.IsEnabledFor(LogEvent.Debug)) { log.Write(LogEvent.Debug, new{Action="get rule processor",Msg="default rule processor is used"}); } return defaultPreprocessor; }