Exemplo n.º 1
0
        /// <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;
Exemplo n.º 2
0
        private void btnMerge_Click(object sender, EventArgs e)
        {
            try
            {
                var confA = LaconicConfiguration.CreateFromString(this.confMergeA.Text);
                var confB = LaconicConfiguration.CreateFromString(this.confMergeB.Text);
                var conf  = new MemoryConfiguration();

                conf.CreateFromMerge(confA.Root, confB.Root);

                this.resultMerge.Text = conf.ToLaconicString();
            }
            catch (Exception ex)
            {
                this.resultMerge.Text = ex.ToMessageWithType();
            }
        }
Exemplo n.º 3
0
        private static ServiceClientHub makeInstance()
        {
            string tpn = typeof(ServiceClientHub).FullName;

            try
            {
                var mbNode  = AgniSystem.Metabase.ServiceClientHubConfNode as ConfigSectionNode;
                var appNode = App.ConfigRoot[SysConsts.APPLICATION_CONFIG_ROOT_SECTION][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.Make <ServiceClientHub>(effective, typeof(ServiceClientHub), new object[] { effective }));
            }
            catch (Exception error)
            {
                throw new Clients.AgniClientException(StringConsts.AGNI_SVC_CLIENT_HUB_SINGLETON_CTOR_ERROR.Args(tpn, error.ToMessageWithType()), error);
            }
        }