Esempio n. 1
0
        public static IWebHost Initialize(IEnumerable <ServiceDescriptor> services, FullNode fullNode,
                                          SignalRSettings settings, IWebHostBuilder webHostBuilder)
        {
            Guard.NotNull(fullNode, nameof(fullNode));
            Guard.NotNull(webHostBuilder, nameof(webHostBuilder));

            Uri uri = settings.SignalRUri;

            webHostBuilder
            .UseKestrel(o => o.AllowSynchronousIO = true)
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseIISIntegration()
            .UseUrls(uri.ToString())
            .ConfigureServices(collection =>
            {
                if (services == null)
                {
                    return;
                }

                // copies all the services defined for the full node to the Api.
                // also copies over singleton instances already defined
                foreach (ServiceDescriptor service in services)
                {
                    // open types can't be singletons
                    if (service.ServiceType.IsGenericType || service.Lifetime == ServiceLifetime.Scoped)
                    {
                        collection.Add(service);
                        continue;
                    }

                    object obj = fullNode.Services.ServiceProvider.GetService(service.ServiceType);
                    if (obj != null && service.Lifetime == ServiceLifetime.Singleton && service.ImplementationInstance == null)
                    {
                        collection.AddSingleton(service.ServiceType, obj);
                    }
                    else
                    {
                        collection.Add(service);
                    }
                }
            })
            .UseStartup <Startup>();

            IWebHost host = webHostBuilder.Build();

            host.Start();

            return(host);
        }
Esempio n. 2
0
 public SignalRFeature(
     FullNode fullNode,
     IFullNodeBuilder fullNodeBuilder,
     SignalRSettings settings,
     ILoggerFactory loggerFactory,
     IEnumerable <IClientEventBroadcaster> eventBroadcasters,
     IEventsSubscriptionService eventsSubscriptionService)
 {
     this.fullNode                  = fullNode;
     this.fullNodeBuilder           = fullNodeBuilder;
     this.settings                  = settings;
     this.eventBroadcasters         = eventBroadcasters;
     this.eventsSubscriptionService = eventsSubscriptionService;
     this.logger = loggerFactory.CreateLogger <SignalRFeature>();
 }
Esempio n. 3
0
 /// <summary>
 /// Get the default configuration.
 /// </summary>
 /// <param name="builder">The string builder to add the settings to.</param>
 /// <param name="network">The network to base the defaults off.</param>
 public static void BuildDefaultConfigurationFile(StringBuilder builder, Network network)
 {
     SignalRSettings.BuildDefaultConfigurationFile(builder, network);
 }
Esempio n. 4
0
 /// <summary>
 /// Prints command-line help.
 /// </summary>
 /// <param name="network">The network to extract values from.</param>
 public static void PrintHelp(Network network)
 {
     SignalRSettings.PrintHelp(network);
 }