public static IGrpcHostBuilder UseUrls(this IGrpcHostBuilder builder, params string[] urls)
        {
            if (urls == null)
            {
                throw new ArgumentNullException(nameof(urls));
            }

            return(builder.UseSetting(GrpcHostDefaults.ServerUrlsKey, string.Join(ServerUrlsSeparator, urls)));
        }
        public static IGrpcHostBuilder UseContentRoot(this IGrpcHostBuilder builder, string contentRoot)
        {
            if (contentRoot == null)
            {
                throw new ArgumentNullException(nameof(contentRoot));
            }

            return(builder.UseSetting(GrpcHostDefaults.ContentRootKey, contentRoot));
        }
        public static IGrpcHostBuilder UseConfiguration(this IGrpcHostBuilder builder, IConfiguration configuration)
        {
            foreach (var setting in configuration.AsEnumerable())
            {
                builder.UseSetting(setting.Key, setting.Value);
            }

            return(builder);
        }
Example #4
0
 public static IGrpcHostBuilder UseDefaultServiceProvider(this IGrpcHostBuilder hostBuilder,
                                                          Action <GrpcHostBuilderContext, ServiceProviderOptions> configure)
 {
     return(hostBuilder.ConfigureServices((context, services) =>
     {
         var options = new ServiceProviderOptions();
         configure(context, options);
         services.Replace(
             ServiceDescriptor.Singleton <IServiceProviderFactory <IServiceCollection> >(
                 new DefaultServiceProviderFactory(options)));
     }));
 }
Example #5
0
 public static IGrpcHostBuilder UseStartup(this IGrpcHostBuilder builder, Type startupType)
 {
     return(builder.ConfigureServices(services =>
     {
         if (typeof(IStartup).GetTypeInfo().IsAssignableFrom(startupType.GetTypeInfo()))
         {
             services.AddSingleton(typeof(IStartup), startupType);
         }
         else
         {
             services.AddSingleton(typeof(IStartup), sp =>
             {
                 var hostingEnvironment = sp.GetRequiredService <IHostingEnvironment>();
                 return new ConventionBasedStartup(StartupLoader.LoadMethods(sp, startupType,
                                                                             hostingEnvironment.EnvironmentName));
             });
         }
     }));
 }
Example #6
0
 public static IGrpcHostBuilder UseStartup <TStartup>(this IGrpcHostBuilder builder) where TStartup : class
 {
     return(builder.UseStartup(typeof(TStartup)));
 }
Example #7
0
 public static IGrpcHostBuilder ConfigureLogging(this IGrpcHostBuilder hostBuilder,
                                                 Action <GrpcHostBuilderContext, ILoggingBuilder> configureLogging)
 {
     return(hostBuilder.ConfigureServices((context, collection) =>
                                          collection.AddLogging(builder => configureLogging(context, builder))));
 }
Example #8
0
 public static IGrpcHostBuilder ConfigureLogging(this IGrpcHostBuilder hostBuilder,
                                                 Action <ILoggingBuilder> configureLogging)
 {
     return(hostBuilder.ConfigureServices(collection => collection.AddLogging(configureLogging)));
 }
Example #9
0
 public static IGrpcHostBuilder ConfigureAppConfiguration(this IGrpcHostBuilder hostBuilder,
                                                          Action <IConfigurationBuilder> configureDelegate)
 {
     return(hostBuilder.ConfigureAppConfiguration((context, builder) => configureDelegate(builder)));
 }
 public static IGrpcHostBuilder BindService <TService>(this IGrpcHostBuilder builder) where TService : class
 {
     return(builder.BindServices(typeof(TService)));
 }