// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2) .AddControllersAsServices(); //把控制器当作服务注册 return(CoreContainer.Init(services)); }
// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddControllers() .AddControllersAsServices(); //把控制器当作服务注册 return(CoreContainer.Init(services)); }
protected override void ConfigureWebHost(IWebHostBuilder builder) { Runner = MongoDbRunner.Start(); builder.ConfigureServices(services => { var client = new MongoClient(Runner.ConnectionString); var database = client.GetDatabase("okn"); services.AddSingleton(database); CoreContainer.Init(services); }); }
protected override void ConfigureWebHost(IWebHostBuilder builder) { Runner = MongoDbRunner.Start(); builder.ConfigureServices(services => { var client = new MongoClient(Runner.ConnectionString); var database = client.GetDatabase("okn"); services.AddSingleton(database); CoreContainer.Init(services); services.AddAuthentication("Test") .AddScheme <AuthenticationSchemeOptions, FakeAuthHandler>("Test", options => { }); }); }
public void ConfigureServices(IServiceCollection services) { services.AddApplicationInsightsTelemetry(); services.AddMemoryCache(); services.AddAuthentication(OldsaratovAuthenticationDefaults.AuthenticationScheme).AddOldsaratov(options => { options.TokenExpirationTimeout = TimeSpan.FromSeconds(3600); }); services.AddCors(options => { options.AddPolicy("CorsPolicy", builder => builder.AllowAnyOrigin() .AllowAnyMethod() .AllowAnyHeader()); }); services.AddMvc().AddNewtonsoftJson(); ConfigureMongo(services); services.AddTransient <DbContext>(); var v = Assembly.GetEntryAssembly().GetName().Version; var b = Configuration.GetValue <string>("BuildNumber"); services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo { Title = $"OKN API", Version = v.ToString(), Description = $"Build Number: {b}" }); var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); c.IncludeXmlComments(xmlPath); }); CoreContainer.Init(services); }
// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); return(CoreContainer.Init(services)); }