Exemplo n.º 1
0
        internal Area(Heap director, IConfigSectionNode cfg) : base(director)
        {
            cfg.NonEmpty(nameof(cfg));

            //1. Build Schema
            m_Schema = new TypeSchema(this, cfg[TypeSchema.CONFIG_SCHEMA_SECTION]);

            //2. Build Selector
            var cfgSelector = cfg[CONFIG_NODE_SELECTOR_SECTION];

            m_NodeSelector = FactoryUtils.MakeDirectedComponent <INodeSelector>(this, cfgSelector, typeof(DefaultNodeSelector), new object[] { cfgSelector });

            //3. Build Service Client
            var cfgClient = cfg[CONFIG_SERVICE_CLIENT_SECTION];

            m_ServiceClient = FactoryUtils.MakeDirectedComponent <IHttpService>(this, cfgClient, typeof(HttpService), new object[] { cfgClient });

            //4. Build Spaces
            m_Spaces = new Dictionary <Type, ISpace>();
            foreach (var tObject in m_Schema.ObjectTypes)
            {
                var tSpace = typeof(Space <>).MakeGenericType(tObject);
                var space  = Activator.CreateInstance(tSpace).CastTo <ISpace>("space .ctor");
                m_Spaces.Add(tSpace, space);
            }
        }
Exemplo n.º 2
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            if (node == null || !node.Exists)
            {
                throw new WaveException(StringConsts.CONFIG_PORTAL_HUB_NODE_ERROR);
            }

            foreach (var cn in node.Children.Where(cn => cn.IsSameName(CONFIG_PORTAL_SECTION)))
            {
                var portal = FactoryUtils.MakeDirectedComponent <Portal>(this, cn, extraArgs: new [] { cn });
                if (!m_Portals.Register(portal))
                {
                    throw new WaveException(StringConsts.PORTAL_HUB_MODULE_ALREADY_CONTAINS_PORTAL_ERROR.Args(portal.Name));
                }
            }


            //Make File System
            var fsNode = node[CONFIG_CONTENT_FS_SECTION];

            m_ContentFS = FactoryUtils.MakeAndConfigureDirectedComponent <FileSystem>(this, fsNode, typeof(IO.FileSystem.Local.LocalFileSystem));
            var fsPNode = fsNode[CONFIG_FS_CONNECT_PARAMS_SECTION];

            if (fsPNode.Exists)
            {
                m_ContentFSConnect = FileSystemSessionConnectParams.Make <FileSystemSessionConnectParams>(fsPNode);
            }
            else
            {
                m_ContentFSConnect = new FileSystemSessionConnectParams()
                {
                    User = Azos.Security.User.Fake
                };
            }

            m_ContentFSRootPath = fsNode.AttrByName(CONFIG_FS_ROOT_PATH_ATTR).Value;
            if (m_ContentFSRootPath.IsNullOrWhiteSpace())
            {
                throw new WaveException(StringConsts.CONFIG_PORTAL_HUB_FS_ROOT_PATH_ERROR.Args(CONFIG_CONTENT_FS_SECTION, CONFIG_FS_ROOT_PATH_ATTR));
            }

            //todo temporary - uncomment after done
            //var cmsNode = node[CONFIG_CMS_BANK_SECTION];
            //if (cmsNode.Exists)
            //{
            //  m_CMSBank = FactoryUtils.MakeAndConfigure<CMS.ICMSBankImplementation>(cmsNode, typeof(CMS.CMSBank));
            //  var svc = m_CMSBank as ServiceModel.Service;
            //  if (svc!=null)
            //    svc.Start();
            //}
            //else
            m_CMSBank = CMS.NOPCMSBank.Instance;
        }
Exemplo n.º 3
0
 protected override void DoConfigure(IConfigSectionNode node)
 {
     base.DoConfigure(node);
     cleanupAlgorithms();
     foreach (var n in node.Children.Where(c => c.IsSameName(CONFIG_ALGORITHM_SECTION)))
     {
         var algo = FactoryUtils.MakeDirectedComponent <ICryptoMessageAlgorithmImplementation>(this, n, extraArgs: new[] { n });
         if (!m_MessageProtectionAlgorithms.Register(algo))
         {
             throw new SecurityException("Algorithm `{0}` is already registered".Args(algo.Name));
         }
     }
 }
Exemplo n.º 4
0
        public void Configure(IConfigSectionNode node)
        {
            ConfigAttribute.Apply(this, node);
            DisposeAndNull(ref m_Server);
            AuthorityAddress.NonBlank(nameof(AuthorityAddress) + " config");
            if (node == null)
            {
                return;
            }

            var nServer = node[CONFIG_SERVICE_SECTION];

            m_Server = FactoryUtils.MakeDirectedComponent <HttpService>(this, nServer, typeof(HttpService), new[] { nServer });
        }
Exemplo n.º 5
0
        public void Configure(IConfigSectionNode node)
        {
            ConfigAttribute.Apply(this, node);
            DisposeAndNull(ref m_Service);
            if (node == null)
            {
                return;
            }

            var nService = node[CONFIG_SERVICE_SECTION];

            m_Service = FactoryUtils.MakeDirectedComponent <HttpService>(this,
                                                                         nService,
                                                                         typeof(HttpService),
                                                                         new object[] { nService });
        }
Exemplo n.º 6
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            base.DoConfigure(node);
            DisposeAndNull(ref m_Server);
            if (node == null)
            {
                return;
            }

            var nServer = node[CONFIG_SERVER_SECTION];

            m_Server = FactoryUtils.MakeDirectedComponent <HttpService>(this,
                                                                        nServer,
                                                                        typeof(HttpService),
                                                                        new object[] { nServer });
        }
Exemplo n.º 7
0
Arquivo: Heap.cs Projeto: azist/azos
        protected override void DoConfigure(IConfigSectionNode node)
        {
            base.DoConfigure(node);
            if (node == null)
            {
                return;
            }

            cleanupAreas();
            m_Areas = new Registry <Area>();
            foreach (var narea in node.Children.Where(n => n.IsSameName(Area.CONFIG_AREA_SECTION)))
            {
                var area = FactoryUtils.MakeDirectedComponent <Area>(this, narea, typeof(Area), new object[] { narea });
                m_Areas.Register(area).IsTrue("Duplicate area: `{0}`".Args(area.Name));
            }
        }
Exemplo n.º 8
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            base.DoConfigure(node);
            if (node == null || !node.Exists)
            {
                return;
            }

            cleanup();
            m_Providers = new Registry <LoginProvider>();

            foreach (var np in node.ChildrenNamed(LoginProvider.CONFIG_PROVIDER_SECTION))
            {
                var provider = FactoryUtils.MakeDirectedComponent <LoginProvider>(this, np, extraArgs: new object[] { np });
                if (!m_Providers.Register(provider))
                {
                    throw new AuthKitException("Duplicate provider `{0}` name in config".Args(provider.Name));
                }
            }
        }
Exemplo n.º 9
0
        protected override void DoConfigure(IConfigSectionNode node)
        {
            if (node == null || !node.Exists)
            {
                throw new WaveException(StringConsts.CONFIG_PORTAL_HUB_NODE_ERROR);
            }

            foreach (var cn in node.Children.Where(cn => cn.IsSameName(CONFIG_PORTAL_SECTION)))
            {
                var portal = FactoryUtils.MakeDirectedComponent <Portal>(this, cn, extraArgs: new [] { cn });
                if (!m_Portals.Register(portal))
                {
                    throw new WaveException(StringConsts.PORTAL_HUB_MODULE_ALREADY_CONTAINS_PORTAL_ERROR.Args(portal.Name));
                }
            }


            //Make File System
            var fsNode = node[CONFIG_CONTENT_FS_SECTION];

            m_ContentFS = FactoryUtils.MakeAndConfigureDirectedComponent <FileSystem>(this, fsNode, typeof(IO.FileSystem.Local.LocalFileSystem));
            var fsPNode = fsNode[CONFIG_FS_CONNECT_PARAMS_SECTION];

            if (fsPNode.Exists)
            {
                m_ContentFSConnect = FileSystemSessionConnectParams.Make <FileSystemSessionConnectParams>(fsPNode);
            }
            else
            {
                m_ContentFSConnect = new FileSystemSessionConnectParams()
                {
                    User = Azos.Security.User.Fake
                };
            }

            m_ContentFSRootPath = fsNode.AttrByName(CONFIG_FS_ROOT_PATH_ATTR).Value;
            if (m_ContentFSRootPath.IsNullOrWhiteSpace())
            {
                throw new WaveException(StringConsts.CONFIG_PORTAL_HUB_FS_ROOT_PATH_ERROR.Args(CONFIG_CONTENT_FS_SECTION, CONFIG_FS_ROOT_PATH_ATTR));
            }
        }
Exemplo n.º 10
0
        private static int run(AzosApplication app)
        {
            var config = app.CommandArgs;

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


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


            var assemblies = config.Attributes
                             .Select(a => Assembly.LoadFrom(a.Value))
                             .ToArray();

            if (assemblies.Length == 0)
            {
                ConsoleUtils.Error("No assemblies to run");
                return(-2);
            }


            Console.ForegroundColor = ConsoleColor.DarkGray;
            Console.Write("Platform runtime: ");
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine(Platform.Abstraction.PlatformAbstractionLayer.PlatformName);
            Console.ForegroundColor = ConsoleColor.Gray;

            var hnode = config["host"];
            var rnode = config["r", "runner"];

            var errors = 0;

            using (var host = FactoryUtils.MakeAndConfigureComponent <IRunnerHost>(app, hnode, typeof(TestRunnerConsoleHost)))
            {
                Console.ForegroundColor = ConsoleColor.DarkGray;
                Console.Write("Runner host: ");
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine(host.GetType().DisplayNameWithExpandedGenericArgs());
                Console.ForegroundColor = ConsoleColor.Gray;

                foreach (var asm in assemblies)
                {
                    using (var runner = FactoryUtils.MakeDirectedComponent <Runner>(host, rnode, typeof(Runner), new object[] { asm, rnode }))
                    {
                        Console.WriteLine("Assembly: {0}".Args(asm));
                        Console.WriteLine("Runner: {0}".Args(runner.GetType().DisplayNameWithExpandedGenericArgs()));
                        Console.WriteLine();

                        runner.Run();
                        errors += host.TotalErrors;

                        Console.WriteLine();
                        Console.WriteLine();
                    }
                }
            }//using host

            return(errors > 0 ? -1 : 0);
        }