forked from dotnet-architecture/eShopOnWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor startup (dotnet-architecture#412)
* Removing unused folder * Refactoring Startup.cs
- Loading branch information
1 parent
b4d0f07
commit e5e9868
Showing
5 changed files
with
88 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
using Microsoft.AspNetCore.Builder; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using System; | ||
|
||
namespace Microsoft.eShopWeb.Web.Configuration | ||
{ | ||
public static class ConfigureCookieSettings | ||
{ | ||
public static void Configure(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; | ||
}); | ||
services.ConfigureApplicationCookie(options => | ||
{ | ||
options.Cookie.HttpOnly = true; | ||
options.ExpireTimeSpan = TimeSpan.FromHours(1); | ||
options.LoginPath = "/Account/Login"; | ||
options.LogoutPath = "/Account/Logout"; | ||
options.Cookie = new CookieBuilder | ||
{ | ||
IsEssential = true // required for auth to work without explicit user consent; adjust to suit your privacy policy | ||
}; | ||
}); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using Microsoft.eShopWeb.ApplicationCore.Interfaces; | ||
using Microsoft.eShopWeb.ApplicationCore.Services; | ||
using Microsoft.eShopWeb.Infrastructure.Data; | ||
using Microsoft.eShopWeb.Infrastructure.Logging; | ||
using Microsoft.eShopWeb.Infrastructure.Services; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Microsoft.eShopWeb.Web.Configuration | ||
{ | ||
public static class ConfigureCoreServices | ||
{ | ||
public static void Configure(IServiceCollection services, IConfiguration configuration) | ||
{ | ||
services.AddScoped(typeof(IAsyncRepository<>), typeof(EfRepository<>)); | ||
services.AddScoped<IBasketService, BasketService>(); | ||
services.AddScoped<IOrderService, OrderService>(); | ||
services.AddScoped<IOrderRepository, OrderRepository>(); | ||
services.AddSingleton<IUriComposer>(new UriComposer(configuration.Get<CatalogSettings>())); | ||
services.AddScoped(typeof(IAppLogger<>), typeof(LoggerAdapter<>)); | ||
services.AddTransient<IEmailSender, EmailSender>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using MediatR; | ||
using Microsoft.eShopWeb.Web.Interfaces; | ||
using Microsoft.eShopWeb.Web.Services; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Microsoft.eShopWeb.Web.Configuration | ||
{ | ||
public static class ConfigureWebServices | ||
{ | ||
public static void Configure(IServiceCollection services, IConfiguration configuration) | ||
{ | ||
services.AddMediatR(typeof(BasketViewModelService).Assembly); | ||
services.AddScoped<IBasketViewModelService, BasketViewModelService>(); | ||
services.AddScoped<CatalogViewModelService>(); | ||
services.AddScoped<ICatalogItemViewModelService, CatalogItemViewModelService>(); | ||
services.Configure<CatalogSettings>(configuration); | ||
services.AddScoped<ICatalogViewModelService, CachedCatalogViewModelService>(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters