/// <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;
Beispiel #2
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;
Beispiel #3
0
 /// <summary>
 /// Factory method that creates new Process based on provided Type, PID and Configuration
 /// </summary>
 public static Process MakeNew(IApplication app, Type type, PID pid, IConfigSectionNode args)
 => makeDefault(app.AsSky(), FactoryUtils.MakeAndConfigure <Process>(args, type), pid);
Beispiel #4
0
 /// <summary>
 /// Factory method that creates new Process based on provided PID
 /// </summary>
 public static TProcess MakeNew <TProcess>(IApplication app, PID pid) where TProcess : Process, new()
 => makeDefault(app.AsSky(), new TProcess(), pid);
Beispiel #5
0
 /// <summary>
 /// Factory method that creates new Signal based on provided Type, PID and Configuration
 /// </summary>
 public static Signal MakeNew(IApplication app, Type type, PID pid, IConfigSectionNode args)
 {
     return(makeDefault(app.AsSky(), FactoryUtils.MakeAndConfigure <Signal>(args, type), pid));
 }
Beispiel #6
0
 /// <summary>
 /// Factory method that creates new Signal based on provided PID
 /// </summary>
 public static TSignal MakeNew <TSignal>(IApplication app, PID pid) where TSignal : Signal, new()
 {
     return(makeDefault(app.AsSky(), new TSignal(), pid));
 }
Beispiel #7
0
 /// <summary>
 /// Returns ISkyApp.HostName
 /// </summary>
 public static string GetThisHostName(this IApplication app)
 => app.AsSky().HostName;
Beispiel #8
0
 /// <summary>
 /// Returns Metabank.SectionHost (metabase's information about this host)
 /// </summary>
 public static Metabank.SectionHost GetThisHostMetabaseSection(this IApplication app)
 => app.AsSky().Metabase.CatalogReg.NavigateHost(app.AsSky().HostName);
Beispiel #9
0
 /// <summary>
 /// Returns Metabank of this IApplication
 /// </summary>
 public static Metabank GetMetabase(this IApplication app) => app.AsSky().Metabase;
Beispiel #10
0
 /// <summary>
 /// Factory method that creates new Todos from Type and Configuration assigning them new GDID
 /// </summary>
 public static Todo MakeNew(IApplication app, Type type, IConfigSectionNode args)
 {
     return(makeDefault(app.AsSky(), FactoryUtils.MakeAndConfigure <Todo>(args, type)));
 }
Beispiel #11
0
 /// <summary>
 /// Factory method that creates new Todos assigning them new GDID
 /// </summary>
 public static TTodo MakeNew <TTodo>(IApplication app) where TTodo : Todo, new()
 {
     return(makeDefault(app.AsSky(), new TTodo()));
 }