Exemple #1
0
        static void Main(string[] args)
        {
            LogManager.Configure(new TraceLogger());
            IComponentsConfig     config = ConfigurationSettings.GetConfig("components") as IComponentsConfig;
            INamedServiceProvider srvPrv = new NReco.Winter.ServiceProvider(config);

            var zz = ConvertManager.ChangeType <IOperation <object> >(srvPrv.GetService("ZZ"));

            IOperation <IDictionary <string, object> > a = srvPrv.GetService("A") as IOperation <IDictionary <string, object> >;
            NameValueContext c = new NameValueContext();

            Console.WriteLine("NReco 'hello world' sample. Try to type 'hello' or 'what is your name', 'die' for exit");

            while (true)
            {
                Console.Write("you> ");
                c["msg"] = Console.ReadLine();
                Console.Write("nreco> ");
                a.Execute(c);
                if (c.ContainsKey("state") && Convert.ToString(c["state"]) == "exit")
                {
                    return;
                }
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            LogManager.Configure( new TraceLogger() );
            IComponentsConfig config = ConfigurationSettings.GetConfig("components") as IComponentsConfig;
            INamedServiceProvider srvPrv = new NReco.Winter.ServiceProvider(config);

            var zz = ConvertManager.ChangeType<IOperation<object>>( srvPrv.GetService("ZZ") );

            IOperation<IDictionary<string,object>> a = srvPrv.GetService("A") as IOperation<IDictionary<string,object>>;
            NameValueContext c = new NameValueContext();
            Console.WriteLine("NReco 'hello world' sample. Try to type 'hello' or 'what is your name', 'die' for exit");

            while (true) {
                Console.Write("you> ");
                c["msg"] = Console.ReadLine();
                Console.Write("nreco> ");
                a.Execute(c);
                if (c.ContainsKey("state") && Convert.ToString( c["state"] )=="exit")
                    return;
            }
        }
Exemple #3
0
        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;
        }