/// <summary>
        /// Provides access to ServiceClientHub singleton instance of the app context
        /// </summary>
        public static ServiceClientHub GetServiceClientHub(this IApplication app)
        => app.NonNull(nameof(app))
        .Singletons
        .GetOrCreate(() =>
        {
            string tpn = typeof(ServiceClientHub).FullName;
            try
            {
                var mbNode  = app.AsSky().Metabase.ServiceClientHubConfNode as ConfigSectionNode;
                var appNode = app.ConfigRoot[SysConsts.APPLICATION_CONFIG_ROOT_SECTION]
                              [ServiceClientHub.CONFIG_SERVICE_CLIENT_HUB_SECTION] as ConfigSectionNode;

                var effectiveConf = new MemoryConfiguration();
                effectiveConf.CreateFromMerge(mbNode, appNode);
                var effective = effectiveConf.Root;

                tpn = effective.AttrByName(FactoryUtils.CONFIG_TYPE_ATTR).ValueAsString(typeof(ServiceClientHub).FullName);

                return(FactoryUtils.MakeComponent <ServiceClientHub>(app, effective, typeof(ServiceClientHub), new object[] { effective }));
            }
            catch (Exception error)
            {
                throw new Clients.SkyClientException(StringConsts.SKY_SVC_CLIENT_HUB_SINGLETON_CTOR_ERROR
                                                     .Args(tpn, error.ToMessageWithType()), error);
            }
        }).instance;
Exemple #2
0
        protected virtual THostSet DoTryFindAndBuild <THostSet>(string setName, string clusterPath, bool searchParent, bool transcendNoc)
            where THostSet : HostSet
        {
            THostSet result = null;

            string actualPath;
            var    cnode = DoTryFindConfig(setName, clusterPath, searchParent, transcendNoc, out actualPath);

            if (cnode != null)
            {
                result = FactoryUtils.MakeComponent <THostSet>(App, cnode, typeof(THostSet), new object[] { setName, clusterPath, actualPath, cnode });
            }

            return(result);
        }
Exemple #3
0
        /// <summary>
        /// Provides access to HostSetBuilder singleton instance of the app context
        /// </summary>
        public static HostSetBuilder GetHostSetBuilder(this IApplication app)
        => app.AsSky()
        .Singletons
        .GetOrCreate(() =>
        {
            var conf = "mbroot/" + Metabank.CONFIG_HOST_SET_BUILDER_SECTION;
            try
            {
                var sky = app.AsSky();

                var node = sky.Metabase.RootConfig[Metabank.CONFIG_HOST_SET_BUILDER_SECTION];
                conf     = node.AsTextSnippet();
                return(FactoryUtils.MakeComponent <HostSetBuilder>(app, node, typeof(HostSetBuilder), new[] { node }));
            }
            catch (Exception error)
            {
                throw new CoordinationException(StringConsts.HOST_SET_BUILDER_SINGLETON_CONFIG_ERROR
                                                .Args(conf, error.ToMessageWithType()), error);
            }
        }).instance;