/// <summary> /// Configures the WebHostBuilder with the DataX default services. /// </summary> /// <param name="hostBuilder">The host builder to be configured</param> /// <returns>The configured host builder</returns> public static IWebHostBuilder UseDataXDefaultConfigureServices(this IWebHostBuilder hostBuilder) { void ConfigureServices(IServiceCollection services) { var config = services.BuildServiceProvider().GetRequiredService <IConfiguration>(); // Add DataX settings to be picked up automatically var settings = config.GetSection(DataXSettingsConstants.ServiceEnvironment).Get <DataXSettings>(); services.AddSingleton(settings); // Configures AppInsights logging StartUpUtil.ConfigureServices(services, config); // Adds JWT Auth var bearerOptions = new JwtBearerOptions(); config.GetSection("JwtBearerOptions").Bind(bearerOptions); services .AddAuthentication(options => { options.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme; options.DefaultScheme = JwtBearerDefaults.AuthenticationScheme; }) .AddJwtBearer(options => { options.Audience = bearerOptions.Audience; options.Authority = bearerOptions.Authority; }); } return(hostBuilder.ConfigureServices(ConfigureServices)); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); StartUpUtil.ConfigureServices(services, Configuration); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); _serviceKeyVaultName = ServiceFabricUtil.GetServiceKeyVaultName().Result.ToString(); StartUpUtil.ConfigureServices(services); // Configure and create a logger instance to add it to MEF container var logger = _loggerFactory.CreateLogger <RuntimeConfigGeneration>(); // Initialize the settings by getting the values from settings file InitConfigSettings(); // Export the Config dependencies Type[] exportTypes = new Type[] { typeof(FlowOperation), typeof(RuntimeConfigGeneration), typeof(JobOperation) }; IEnumerable <Assembly> cloudModeDependencyAssemblies = GetCloudModeDependencyAssemblies(); IEnumerable <Assembly> additionalAssemblies = GetDependencyAssembliesFromStorageAsync().Result; var allAssemblies = cloudModeDependencyAssemblies.Union(additionalAssemblies); services.AddMefExportsFromAssemblies(ServiceLifetime.Scoped, allAssemblies, exportTypes, new object[] { logger }); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); StartUpUtil.ConfigureServices(services); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc(options => options.EnableEndpointRouting = false).AddNewtonsoftJson().SetCompatibilityVersion(CompatibilityVersion.Version_3_0); StartUpUtil.ConfigureServices(services, Configuration); }