Exemple #1
0
        internal ServerNode(MongoClient client, Node node) : base(client)
        {
            m_Client = client;
            m_Node   = node;

            var cfg = client.ConfigRoot//1. Try to find the SERVER section with name equals this node
                      .Children
                      .FirstOrDefault(c => c.IsSameName(CONFIG_SERVER_SECTION) && c.IsSameNameAttr(node.ConnectString));

            if (cfg == null)
            {
                cfg = client.ConfigRoot //2. If not found, try to find SERVER section without name attr
                      .Children
                      .FirstOrDefault(c => c.IsSameName(CONFIG_SERVER_SECTION) && !c.AttrByName(Configuration.CONFIG_NAME_ATTR).Exists);
            }

            if (cfg != null)
            {
                ConfigAttribute.Apply(this, client.ConfigRoot);
            }
        }
        void IConfigurable.Configure(IConfigSectionNode node)
        {
            lock (m_Lock)
            {
                if (node == null || !node.Exists)
                {
                    node = App.ConfigRoot[WebSettings.CONFIG_WEBSETTINGS_SECTION][WebSettings.CONFIG_SERVICEPOINTMANAGER_SECTION];
                }

                if (!node.Exists)
                {
                    return;
                }

                ConfigAttribute.Apply(this, node);

                configureRoot(node);

                ServicePointManager.ServerCertificateValidationCallback += onServerCertificateValidationCallback;
            }
        }
Exemple #3
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            if (node == null || !node.Exists)
            {
                node = App.ConfigRoot[DataAccess.Cache.CacheStore.CONFIG_CACHE_SECTION]
                       .Children
                       .FirstOrDefault(s => s.IsSameName(DataAccess.Cache.CacheStore.CONFIG_STORE_SECTION) && s.IsSameNameAttr(Name));
                if (node == null)
                {
                    node = App.ConfigRoot[DataAccess.Cache.CacheStore.CONFIG_CACHE_SECTION]
                           .Children
                           .FirstOrDefault(s => s.IsSameName(DataAccess.Cache.CacheStore.CONFIG_STORE_SECTION) && !s.AttrByName(Configuration.CONFIG_NAME_ATTR).Exists);
                    if (node == null)
                    {
                        return;
                    }
                }
            }

            ConfigAttribute.Apply(this, node);

            m_TableOptions = new Registry <TableOptions>();
            foreach (var tn in node.Children.Where(cn => cn.IsSameName(DataAccess.Cache.CacheStore.CONFIG_TABLE_SECTION)))
            {
                var tbl = new TableOptions(tn);
                m_TableOptions.Register(tbl);
            }

            var dton = node[DEFAULT_TABLE_OPTIONS_SECTION];

            if (dton.Exists)
            {
                m_DefaultTableOptions = new TableOptions(dton, false);
            }

            if (m_Pile.ComponentDirector == this)
            {
                m_Pile.Configure(node[DefaultPile.CONFIG_PILE_SECTION]);
            }
        }
Exemple #4
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            if (node == null)
            {
                node = App.ConfigRoot[CONFIG_SHIPPING_PROCESSING_SECTION];
                if (!node.Exists)
                {
                    return;
                }

                //1 try to find the server with the same name as this instance
                var snode = node.Children.FirstOrDefault(cn => cn.IsSameName(CONFIG_SHIPPING_SYSTEM_SECTION) && cn.IsSameNameAttr(Name));

                //2 try to find a server without a name
                if (snode == null)
                {
                    snode = node.Children.FirstOrDefault(cn => cn.IsSameNameAttr(CONFIG_SHIPPING_SYSTEM_SECTION) && cn.AttrByName(Configuration.CONFIG_NAME_ATTR).Value.IsNullOrWhiteSpace());
                }

                if (snode == null)
                {
                    return;
                }

                node = snode;
            }

            ConfigAttribute.Apply(this, node);

            var carriers = new Registry <ShippingCarrier>();

            var snodes = node[CONFIG_CARRIERS_SECTION].Children.Where(n => n.IsSameName(CONFIG_CARRIER_SECTION));

            foreach (var snode in snodes)
            {
                var carrier = FactoryUtils.MakeAndConfigure <ShippingCarrier>(snode, typeof(ShippingCarrier), new object[] { this });
                carriers.Register(carrier);
            }
            m_PreconfiguredShippingCarriers = carriers;
        }
        public void ConfigAttributeApplyToExtendedClassWithRootOverride()
        {
            var conf = Azos.Conf.XMLConfiguration.CreateFromXML(xml);

            var cl = new MyClassExtended2();

            ConfigAttribute.Apply(cl, conf.Root);

            Aver.AreEqual("protected", cl.getProtectedName());
            Aver.AreEqual("public", cl.m_PublicName);

            Aver.AreEqual(199, cl.Age);
            Aver.IsTrue(MyEnum.C == cl.MyEnumField);

            Aver.AreEqual(1, cl.When.Month);
            Aver.AreEqual(1, cl.When.Day);
            Aver.AreEqual(1944, cl.When.Year);

            Aver.AreEqual(false, cl.Fuzzy.Value);

            Aver.AreEqual(false, cl.Jazzy.HasValue);
        }
Exemple #6
0
        public virtual void Configure(IConfigSectionNode config)
        {
            if (config == null)
            {
                return;
            }
            ConfigAttribute.Apply(this, config);

            var loc = config[TimeLocation.CONFIG_TIMELOCATION_SECTION];

            if (loc.Exists)
            {
                m_TimeLocation = FactoryUtils.MakeAndConfigure <TimeLocation>(loc, typeof(TimeLocation));
            }

            var ehnode = config[CONFIG_HANDLER_SECTION];

            if (ehnode.Exists)
            {
                EventHandler = FactoryUtils.MakeUsingCtor <IEventHandler>(ehnode);
            }
        }
Exemple #7
0
        public void Configure(IConfigSectionNode node)
        {
            ConfigAttribute.Apply(this, node);

            var mnodes = node[CONFIG_METHODS_SECTION].Children.Where(n => n.IsSameName(CONFIG_METHOD_SECTION));

            foreach (var mnode in mnodes)
            {
                var method = FactoryUtils.MakeAndConfigure <Method>(mnode, typeof(Method), new object[] { this });
                m_Methods.Register(method);
            }

            var templates = new List <Package>();
            var tnodes    = node[CONFIG_PACKAGES_SECTION].Children.Where(n => n.IsSameName(CONFIG_PACKAGE_SECTION));

            foreach (var tnode in tnodes)
            {
                var template = FactoryUtils.MakeAndConfigure <Package>(tnode, typeof(Package), new object[] { this });
                m_Packages.Register(template);
            }

            NLSName = new NLSMap(node[CONFIG_NLS_SECTION]);
        }
Exemple #8
0
                          protected virtual void DoInitApplication()
                          {
                              ConfigAttribute.Apply(this, m_ConfigRoot);

                              m_Name = m_ConfigRoot.AttrByName(CONFIG_APP_NAME_ATTR).ValueAsString(GetType().FullName);

                              Debugging.DefaultDebugAction = Debugging.ReadDefaultDebugActionFromConfig();
                              Debugging.TraceDisabled      = Debugging.ReadTraceDisableFromConfig();

                              //the order of root component boot is important:

                              InitLog();                //1.  must be the first one so others can log
                              InitModule();             //2.  other services may use module references
                              InitTimeSource();         //3.  start accurate time asap
                              InitSecurityManager();    //4.  security context
                              InitEventTimer();         //5.  event scheduler/bg jobs
                              InitInstrumentation();    //6.  instrumentation
                              InitDataStore();          //7.  data store
                              InitObjectStore();        //8.  object store
                              InitGlue();               //9.  glue
                              InitDependencyInjector(); //10.  custom dep injector last



                              //After all inits apply the behavior top the root
                              try
                              {
                                  Behavior.ApplyConfiguredBehaviors(this, m_ConfigRoot);
                                  Behavior.ApplyBehaviorAttributes(this);
                              }
                              catch (Exception error)
                              {
                                  var msg = StringConsts.APP_APPLY_BEHAVIORS_ERROR + error.ToMessageWithType();
                                  WriteLog(MessageType.CatastrophicError, INIT_FROM, msg, error);
                                  throw new AzosException(msg, error);
                              }
                          }
Exemple #9
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            if (node == null)
            {
                var sNode = App.ConfigRoot[WebSettings.CONFIG_WEBSETTINGS_SECTION][CONFIG_CLOUD_SECTION];
                if (!sNode.Exists)
                {
                    return;
                }

                node = sNode.Children.FirstOrDefault(cn => cn.IsSameName(CONFIG_SYSTEM_SECTION) && cn.IsSameNameAttr(Name));

                if (node == null)
                {
                    node = sNode.Children.FirstOrDefault(cn => cn.IsSameNameAttr(CONFIG_SYSTEM_SECTION) && cn.AttrByName(Configuration.CONFIG_NAME_ATTR).Value.IsNullOrWhiteSpace());
                }

                if (node == null)
                {
                    return;
                }
            }

            ConfigAttribute.Apply(this, node);

            foreach (var hNode in node.Children
                     .Where(cn => cn.IsSameName(CONFIG_HOST_TEMPLATE_SECTION)))
            {
                var host = MakeTemplate(hNode);

                if (!m_Templates.Register(host))
                {
                    throw new CloudException(StringConsts.CLOUD_SYSTEM_DUPLICATE_HOST_ERROR.Args(GetType().FullName, Name));
                }
            }
        }
        public void ConfigAttributeApplyToExtendedClass()
        {
            var conf = Azos.Conf.XMLConfiguration.CreateFromXML(xml);

            var cl = new MyClassExtended();

            ConfigAttribute.Apply(cl, conf.Root);

            Aver.AreEqual("private", cl.getPrivateName());
            Aver.AreEqual("protected", cl.getProtectedName());
            Aver.AreEqual("public", cl.m_PublicName);


            Aver.AreEqual(-892, cl.getPrivateInt());
            Aver.AreEqual(23567, cl.getPrivateProperty());

            Aver.AreEqual(+892, cl.getPrivateIntExtended());
            Aver.AreEqual(-23567, cl.getPrivatePropertyExtended());


            Aver.AreEqual(99, cl.Age);
            Aver.IsTrue(MyEnum.B == cl.MyEnumField);

            Aver.AreEqual(5, cl.When.Month);
            Aver.AreEqual(12, cl.When.Day);
            Aver.AreEqual(1982, cl.When.Year);

            Aver.AreEqual(true, cl.Fuzzy.Value);

            Aver.AreEqual(false, cl.Jazzy.HasValue);

            Aver.AreEqual(155, cl.NoneInt);
            Aver.AreEqual(true, cl.NoneBool);
            Aver.AreEqual("This is default", cl.NoneString);
            Aver.AreEqual("So what?", cl.NoneAnotherString);
        }
Exemple #11
0
 /// <summary>
 /// This constructor
 /// </summary>
 /// <param name="name"></param>
 /// <param name="config"></param>
 protected ErlAbstractNode(string name, IConfigSectionNode config)
     : base(null)
 {
     m_Cookie = s_DefaultCookie;
     ConfigAttribute.Apply(this, config);
 }
Exemple #12
0
 public void Configure(IConfigSectionNode node)
 {
     ConfigAttribute.Apply(this, node);
     m_ResolvedNode = AgniSystem.Metabase.ResolveNetworkService(Host, Network, Service, Binding);
 }
Exemple #13
0
 /// <summary>
 /// Configures specified destination
 /// </summary>
 public void Configure(IConfigSectionNode fromNode)
 {
     DoConfigure(fromNode);
     ConfigAttribute.Apply(this, fromNode);
 }
Exemple #14
0
 private void ctor(IConfigSectionNode node)
 {
     configureMatches(node);
     ConfigAttribute.Apply(this, node);
 }
Exemple #15
0
 public AuthorizeSessionFilter(WorkDispatcher dispatcher, IConfigSectionNode confNode) : base(dispatcher, confNode)
 {
     ConfigAttribute.Apply(this, confNode);
 }
Exemple #16
0
 public void Configure(IConfigSectionNode node) => ConfigAttribute.Apply(this, node);
 public virtual void Configure(IConfigSectionNode node)
 {
     ConfigAttribute.Apply(this, node);
 }
 public ClientLoginProcessor()
 {
     Console.WriteLine(UIMessages.WELCOME_TEXT);
     ConfigAttribute.Apply(this, App.ConfigRoot);
 }
Exemple #19
0
 protected TestTrendingHost(TrendingSystemService director, IConfigSectionNode config) : base(director, config)
 {
     ConfigAttribute.Apply(this, config);
 }
Exemple #20
0
        private static void run(string[] args)
        {
            var config = new CommandArgsConfiguration(args);


            ConsoleUtils.WriteMarkupContent(typeof(ProgramBody).GetText("Welcome.txt"));

            if (config.Root["?"].Exists ||
                config.Root["h"].Exists ||
                config.Root["help"].Exists)
            {
                ConsoleUtils.WriteMarkupContent(typeof(ProgramBody).GetText("Help.txt"));
                return;
            }



            if (!config.Root.AttrByIndex(0).Exists)
            {
                ConsoleUtils.Error("Template source path is missing");
                return;
            }


            var files = getFiles(config.Root);

            var ctypename = config.Root["c"].AttrByIndex(0).Value ?? config.Root["compiler"].AttrByIndex(0).Value;

            var ctype = string.IsNullOrWhiteSpace(ctypename)? typeof(Azos.Templatization.TextCSTemplateCompiler) : Type.GetType(ctypename);

            if (ctype == null)
            {
                throw new AzosException("Can not create compiler type: " + (ctypename ?? "<none>"));
            }

            var compiler = Activator.CreateInstance(ctype) as TemplateCompiler;

            var onode = config.Root["options"];

            if (!onode.Exists)
            {
                onode = config.Root["o"];
            }
            if (onode.Exists)
            {
                ConfigAttribute.Apply(compiler, onode);
                var asms = onode.AttrByName("ref").ValueAsString(string.Empty).Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (var asm in asms)
                {
                    compiler.ReferenceAssembly(asm);
                }
            }

            showOptions(compiler);

            foreach (var f in files)
            {
                var src = new FileTemplateStringContentSource(f);
                ConsoleUtils.Info("Included: " + src.GetName(50));
                compiler.IncludeTemplateSource(src);
            }

            compiler.Compile();

            if (compiler.HasErrors)
            {
                showErrors(compiler, config.Root);
                return;
            }

            if (config.Root["src"].Exists)
            {
                writeToDiskCompiledSourceFiles(compiler, config.Root);
            }
        }
Exemple #21
0
 public AuthorizeSessionFilter(WorkHandler handler, IConfigSectionNode confNode) : base(handler, confNode)
 {
     ConfigAttribute.Apply(this, confNode);
 }
Exemple #22
0
 protected override void DoConfigure(IConfigSectionNode node)
 {
     base.DoConfigure(node);
     ConfigAttribute.Apply(this, node);
 }
Exemple #23
0
 public Api()
 {
     ConfigAttribute.Apply(this, App.ConfigRoot);
 }
Exemple #24
0
        protected virtual void DoInitApplication()
        {
            const string FROM = "app.init";

            ConfigAttribute.Apply(this, m_ConfigRoot);

            m_Name = m_ConfigRoot.AttrByName(CONFIG_APP_NAME_ATTR).ValueAsString(GetType().FullName);

            Debugging.DefaultDebugAction = Debugging.ReadDefaultDebugActionFromConfig();
            Debugging.TraceDisabled      = Debugging.ReadTraceDisableFromConfig();

            var node = m_ConfigRoot[CONFIG_LOG_SECTION];

            if (node.Exists)
            {
                try
                {
                    m_Log = FactoryUtils.MakeAndConfigure(node, typeof(LogService)) as ILogImplementation;

                    if (m_Log == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "Log made");

                    BeforeLogStart(m_Log);

                    if (m_Log is Service)
                    {
                        if (((Service)m_Log).StartByApplication())
                        {
                            WriteLog(MessageType.Info, FROM, "Log started, msg times are localized of machine-local time until time source starts");
                        }
                    }
                }
                catch (Exception error)
                {
                    throw new NFXException(StringConsts.APP_LOG_INIT_ERROR + error.ToMessageWithType(), error);
                }
            }


            node = m_ConfigRoot[CONFIG_TIMESOURCE_SECTION];
            if (node.Exists)
            {
                try
                {
                    m_TimeSource = FactoryUtils.MakeAndConfigure(node, null) as ITimeSourceImplementation;

                    if (m_TimeSource == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "TimeSource made");

                    BeforeTimeSourceStart(m_TimeSource);

                    if (m_TimeSource is Service)
                    {
                        if (((Service)m_TimeSource).StartByApplication())
                        {
                            WriteLog(MessageType.Info, FROM, "TimeSource started");
                        }
                    }

                    WriteLog(MessageType.Info, FROM, "Log msg time is time source-supplied now");

                    m_StartTime = LocalizedTime;
                    WriteLog(MessageType.Info, FROM, "App start time is {0}".Args(m_StartTime));
                }
                catch (Exception error)
                {
                    var msg = StringConsts.APP_TIMESOURCE_INIT_ERROR + error.ToMessageWithType();
                    WriteLog(MessageType.CatastrophicError, FROM, msg, error);
                    throw new NFXException(msg, error);
                }
            }
            else
            {
                WriteLog(MessageType.Info, FROM, "Using default time source");

                m_StartTime = LocalizedTime;
                WriteLog(MessageType.Info, FROM, "App start time is {0}".Args(m_StartTime));
            }


            node = m_ConfigRoot[CONFIG_EVENT_TIMER_SECTION];
            //20150827 DKh event timer must allocate even if it is absent in config
            //// if (node.Exists)
            {
                try
                {
                    m_EventTimer = FactoryUtils.MakeAndConfigure(node, typeof(EventTimer)) as IEventTimerImplementation;

                    if (m_EventTimer == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "EventTimer made");

                    BeforeEventTimerStart(m_EventTimer);

                    if (m_EventTimer is Service)
                    {
                        if (((Service)m_EventTimer).StartByApplication())
                        {
                            WriteLog(MessageType.Info, FROM, "EventTimer started");
                        }
                    }
                }
                catch (Exception error)
                {
                    var msg = StringConsts.APP_EVENT_TIMER_INIT_ERROR + error.ToMessageWithType();
                    WriteLog(MessageType.CatastrophicError, FROM, msg, error);
                    throw new NFXException(msg, error);
                }
            }



            node = m_ConfigRoot[CONFIG_SECURITY_SECTION];
            if (node.Exists)
            {
                try
                {
                    m_SecurityManager = FactoryUtils.MakeAndConfigure(node, typeof(ConfigSecurityManager)) as ISecurityManagerImplementation;

                    if (m_SecurityManager == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "Security Manager made");

                    BeforeSecurityManagerStart(m_SecurityManager);

                    if (m_SecurityManager is Service)
                    {
                        if (((Service)m_SecurityManager).StartByApplication())
                        {
                            WriteLog(MessageType.Info, FROM, "Security Manager started");
                        }
                    }
                }
                catch (Exception error)
                {
                    var msg = StringConsts.APP_SECURITY_MANAGER_INIT_ERROR + error;
                    WriteLog(MessageType.CatastrophicError, FROM, msg, error);
                    throw new NFXException(msg, error);
                }
            }

            try
            {
                Behavior.ApplyConfiguredBehaviors(this, m_ConfigRoot);
            }
            catch (Exception error)
            {
                var msg = StringConsts.APP_APPLY_BEHAVIORS_ERROR + error;
                WriteLog(MessageType.Error, FROM, msg, error);
                throw new NFXException(msg, error);
            }


            node = m_ConfigRoot[CONFIG_INSTRUMENTATION_SECTION];
            if (node.Exists)
            {
                try
                {
                    m_Instrumentation = FactoryUtils.MakeAndConfigure(node, typeof(InstrumentationService)) as IInstrumentationImplementation;

                    if (m_Instrumentation == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "Instrumentation made");

                    BeforeInstrumentationStart(m_Instrumentation);

                    if (m_Instrumentation is Service)
                    {
                        if (((Service)m_Instrumentation).StartByApplication())
                        {
                            WriteLog(MessageType.Info, FROM, "Instrumentation started");
                        }
                    }
                }
                catch (Exception error)
                {
                    var msg = StringConsts.APP_INSTRUMENTATION_INIT_ERROR + error;
                    WriteLog(MessageType.CatastrophicError, FROM, msg, error);
                    throw new NFXException(msg, error);
                }
            }


            node = m_ConfigRoot[CONFIG_THROTTLING_SECTION];
            if (node.Exists)
            {
                try
                {
                    m_Throttling = FactoryUtils.MakeAndConfigure(node, typeof(ThrottlingService)) as IThrottlingImplementation;

                    if (m_Throttling == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "Throttling made");

                    BeforeThrottlingStart(m_Throttling);

                    if (m_Throttling is Service)
                    {
                        if (((Service)m_Throttling).StartByApplication())
                        {
                            WriteLog(MessageType.Info, FROM, "Throttling started");
                        }
                    }
                }
                catch (Exception error)
                {
                    var msg = StringConsts.APP_THROTTLING_INIT_ERROR + error;
                    WriteLog(MessageType.CatastrophicError, FROM, msg, error);
                    throw new NFXException(msg, error);
                }
            }



            node = m_ConfigRoot[CONFIG_DATA_STORE_SECTION];
            if (node.Exists)
            {
                try
                {
                    m_DataStore = FactoryUtils.MakeAndConfigure(node) as IDataStoreImplementation;

                    if (m_DataStore == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "DataStore made");


                    BeforeDataStoreStart(m_DataStore);

                    if (m_DataStore is Service)
                    {
                        if (((Service)m_DataStore).StartByApplication())
                        {
                            WriteLog(MessageType.Info, FROM, "DataStore started");
                        }
                    }
                }
                catch (Exception error)
                {
                    var msg = StringConsts.APP_DATA_STORE_INIT_ERROR + error;
                    WriteLog(MessageType.CatastrophicError, FROM, msg, error);
                    throw new NFXException(msg, error);
                }
            }

            node = m_ConfigRoot[CONFIG_OBJECT_STORE_SECTION];
            if (node.Exists)
            {
                try
                {
                    m_ObjectStore = FactoryUtils.MakeAndConfigure(node, typeof(ObjectStoreService)) as IObjectStoreImplementation;

                    if (m_ObjectStore == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "ObjectStore made");

                    BeforeObjectStoreStart(m_ObjectStore);

                    if (m_ObjectStore is Service)
                    {
                        if (((Service)m_ObjectStore).StartByApplication())
                        {
                            WriteLog(MessageType.Info, FROM, "ObjectStore started");
                        }
                    }
                }
                catch (Exception error)
                {
                    var msg = StringConsts.APP_OBJECT_STORE_INIT_ERROR + error;
                    WriteLog(MessageType.CatastrophicError, FROM, msg, error);
                    throw new NFXException(msg, error);
                }
            }

            node = m_ConfigRoot[CONFIG_GLUE_SECTION];
            if (node.Exists)
            {
                try
                {
                    m_Glue = FactoryUtils.MakeAndConfigure(node, typeof(NFX.Glue.Implementation.GlueService)) as IGlueImplementation;

                    if (m_Glue == null)
                    {
                        throw new NFXException(StringConsts.APP_INJECTION_TYPE_MISMATCH_ERROR +
                                               node
                                               .AttrByName(FactoryUtils.CONFIG_TYPE_ATTR)
                                               .ValueAsString(CoreConsts.UNKNOWN));
                    }

                    WriteLog(MessageType.Info, FROM, "Glue made");

                    BeforeGlueStart(m_Glue);

                    if (m_Glue is Service)
                    {
                        if (((Service)m_Glue).StartByApplication())
                        {
                            WriteLog(MessageType.Info, FROM, "Glue started");
                        }
                    }
                }
                catch (Exception error)
                {
                    var msg = StringConsts.APP_GLUE_INIT_ERROR + error;
                    WriteLog(MessageType.CatastrophicError, FROM, msg, error);
                    throw new NFXException(msg, error);
                }
            }



            WriteLog(MessageType.Info, FROM, "Common application initialized in '{0}' time location".Args(this.TimeLocation));
            WriteLog(MessageType.Info, FROM, "Component dump:");
            foreach (var cmp in ApplicationComponent.AllComponents)
            {
                WriteLog(MessageType.Info, FROM, "  -> Component: {0}  '{1}'  '{2}' ".Args(cmp.ComponentSID, cmp.GetType().FullName, cmp.ComponentCommonName));
            }
        }
Exemple #25
0
        private static void run(string[] args)
        {
            var config = new CommandArgsConfiguration(args);


            if (config.Root["?"].Exists ||
                config.Root["h"].Exists ||
                config.Root["help"].Exists)
            {
                ConsoleUtils.WriteMarkupContent(typeof(Program).GetText("Help.txt"));
                return;
            }


            if (!config.Root.AttrByIndex(0).Exists)
            {
                Console.WriteLine("Specify ';'-delimited assembly list");
                return;
            }



            var manager = new InventorizationManager(config.Root.AttrByIndex(0).Value);

            var fnode = config.Root["f"];

            if (!fnode.Exists)
            {
                fnode = config.Root["filter"];
            }
            if (fnode.Exists)
            {
                ConfigAttribute.Apply(manager, fnode);
            }

            foreach (var n in config.Root.Children.Where(chi => chi.IsSameName("s") || chi.IsSameName("strat") || chi.IsSameName("strategy")))
            {
                var  tname = n.AttrByIndex(0).Value ?? "<unspecified>";
                Type t     = Type.GetType(tname);
                if (t == null)
                {
                    throw new NFXException("Can not create strategy type: " + tname);
                }

                var strategy = Activator.CreateInstance(t) as IInventorization;

                if (strategy == null)
                {
                    throw new NFXException("The supplied type is not strategy: " + tname);
                }

                manager.Strategies.Add(strategy);
            }

            if (manager.Strategies.Count == 0)
            {
                manager.Strategies.Add(new BasicInventorization());
            }



            // if (config.Root["any"].Exists)
            //  manager.OnlyAttributed = false;

            var result = new XMLConfiguration();

            result.Create("inventory");
            manager.Run(result.Root);
            Console.WriteLine(result.SaveToString());
        }
Exemple #26
0
 public ErrorFilter(WorkHandler handler, IConfigSectionNode confNode) : base(handler, confNode)
 {
     ConfigureMatches(confNode, m_ShowDumpMatches, m_LogMatches, GetType().FullName);
     ConfigAttribute.Apply(this, confNode);
 }
Exemple #27
0
            public void Configure(IConfigSectionNode node)
            {
                ConfigAttribute.Apply(this, node);

                NLSName = new NLSMap(node[CONFIG_NLS_SECTION]);
            }
Exemple #28
0
 protected override void DoConfigure(Conf.IConfigSectionNode node)
 {
     base.DoConfigure(node);
     ConfigAttribute.Apply(m_DataStore, node);
 }
Exemple #29
0
 public void Configure(IConfigSectionNode node)
 {
     EnsureNotCompiled();
     ConfigAttribute.Apply(this, node);
 }
Exemple #30
0
 public VarDef(IConfigSectionNode node)
     : this(node.NonNull(text : "VarDef.ctor(node==null)").AttrByName(Configuration.CONFIG_NAME_ATTR).Value)
 {
     ConfigAttribute.Apply(this, node);
 }