Skip to content

Commit

Permalink
Split up configuration for Web and Bl in separate extension methods
Browse files Browse the repository at this point in the history
  • Loading branch information
HerbertBodner committed Dec 28, 2015
1 parent 2142cdb commit e152f97
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/Example.Web/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Microsoft.Framework.Configuration;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.DependencyInjection.Extensions;
using WaCore.Bl;
using WaCore.Contracts.Data.Repositories;
using WaCore.Contracts.Data.Repositories.Base;
using WaCore.Data;
Expand Down Expand Up @@ -57,7 +58,8 @@ public void ConfigureServices(IServiceCollection services)
.AddDbContext<ExampleDbContext>(options =>
options.UseSqlServer(Configuration["Data:DefaultConnection:ConnectionString"]));

services.ConfigureWaCore(Configuration);
services.ConfigureWaCoreWeb(Configuration);
services.ConfigureWaCoreBl(Configuration);

services.AddIdentity<User, Role>()
.AddEntityFrameworkStores<ExampleDbContext, Guid>()
Expand Down
24 changes: 24 additions & 0 deletions src/WaCore.Bl/ConfigurationExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.Framework.Configuration;
using Microsoft.Framework.DependencyInjection;
using Microsoft.Framework.DependencyInjection.Extensions;
using WaCore.Bl.Services.Account;
using WaCore.Contracts.Bl.Services.Account;

namespace WaCore.Bl
{
public static class ConfigurationExtensions
{
public static IServiceCollection ConfigureWaCoreBl(this IServiceCollection services,
IConfigurationRoot configuration)
{

services.TryAddTransient<IAccountService, AccountService>();

return services;
}
}
}
1 change: 1 addition & 0 deletions src/WaCore.Bl/project.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"Microsoft.AspNet.Cryptography.KeyDerivation": "1.0.0-beta8",
"Microsoft.AspNet.Identity": "3.0.0-beta8",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta8",
"Microsoft.Framework.DependencyInjection.Abstractions": "1.0.0-beta8",
"WaCore.Contracts": "1.0.0-*",
"WaCore.Entities": "1.0.0-*"
}
Expand Down
1 change: 1 addition & 0 deletions src/WaCore.Bl/project.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -10445,6 +10445,7 @@
"Microsoft.AspNet.Cryptography.KeyDerivation >= 1.0.0-beta8",
"Microsoft.AspNet.Identity >= 3.0.0-beta8",
"Microsoft.AspNet.Identity.EntityFramework >= 3.0.0-beta8",
"Microsoft.Framework.DependencyInjection.Abstractions >= 1.0.0-beta8",
"WaCore.Contracts >= 1.0.0-*",
"WaCore.Entities >= 1.0.0-*"
],
Expand Down
3 changes: 3 additions & 0 deletions src/WaCore.UnitTests/project.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,7 @@
"Microsoft.AspNet.Cryptography.KeyDerivation": "1.0.0-beta8",
"Microsoft.AspNet.Identity": "3.0.0-beta8",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta8",
"Microsoft.Framework.DependencyInjection.Abstractions": "1.0.0-beta8",
"RazorEngine": "3.7.5",
"WaCore.Contracts": "1.0.0",
"WaCore.Entities": "1.0.0"
Expand Down Expand Up @@ -3189,6 +3190,7 @@
"Microsoft.AspNet.Cryptography.KeyDerivation": "1.0.0-beta8",
"Microsoft.AspNet.Identity": "3.0.0-beta8",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta8",
"Microsoft.Framework.DependencyInjection.Abstractions": "1.0.0-beta8",
"RazorEngine": "3.7.5",
"WaCore.Contracts": "1.0.0",
"WaCore.Entities": "1.0.0"
Expand Down Expand Up @@ -4860,6 +4862,7 @@
"Microsoft.AspNet.Cryptography.KeyDerivation": "1.0.0-beta8",
"Microsoft.AspNet.Identity": "3.0.0-beta8",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta8",
"Microsoft.Framework.DependencyInjection.Abstractions": "1.0.0-beta8",
"RazorEngine": "3.7.5",
"WaCore.Contracts": "1.0.0",
"WaCore.Entities": "1.0.0"
Expand Down
5 changes: 1 addition & 4 deletions src/WaCore.Web/ConfigurationExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,14 @@
using Microsoft.Framework.DependencyInjection;
using WaCore.Web.Infrastructure;
using Microsoft.Framework.DependencyInjection.Extensions;
using WaCore.Bl.Services.Account;
using WaCore.Contracts.Bl.Services.Account;
using WaCore.Web.Controllers;

namespace WaCore.Web
{
public static class ConfigurationExtensions
{
public static IServiceCollection ConfigureWaCore(this IServiceCollection services,
public static IServiceCollection ConfigureWaCoreWeb(this IServiceCollection services,
IConfigurationRoot configuration)
{
services.TryAddSingleton<IRazorViewEngine, WaCoreRazorViewEngine>();
Expand All @@ -29,8 +28,6 @@ public static IServiceCollection ConfigureWaCore(this IServiceCollection service
// so you may need to compare your custom views to the originals again after upgrades


services.TryAddTransient<IAccountService, AccountService>();

services.AddMvc();
return services;
}
Expand Down
6 changes: 6 additions & 0 deletions src/WaCore.Web/project.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,7 @@
"Microsoft.AspNet.Cryptography.KeyDerivation": "1.0.0-beta8",
"Microsoft.AspNet.Identity": "3.0.0-beta8",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta8",
"Microsoft.Framework.DependencyInjection.Abstractions": "1.0.0-beta8",
"RazorEngine": "3.7.5",
"WaCore.Contracts": "1.0.0",
"WaCore.Entities": "1.0.0"
Expand Down Expand Up @@ -3566,6 +3567,7 @@
"Microsoft.AspNet.Identity": "3.0.0-beta8",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta8",
"Microsoft.CSharp": "4.0.1-beta-23409",
"Microsoft.Framework.DependencyInjection.Abstractions": "1.0.0-beta8",
"System.Collections": "4.0.11-beta-23409",
"System.Linq": "4.0.1-beta-23409",
"System.Runtime": "4.0.21-beta-23409",
Expand Down Expand Up @@ -5069,6 +5071,7 @@
"Microsoft.AspNet.Cryptography.KeyDerivation": "1.0.0-beta8",
"Microsoft.AspNet.Identity": "3.0.0-beta8",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta8",
"Microsoft.Framework.DependencyInjection.Abstractions": "1.0.0-beta8",
"RazorEngine": "3.7.5",
"WaCore.Contracts": "1.0.0",
"WaCore.Entities": "1.0.0"
Expand Down Expand Up @@ -6556,6 +6559,7 @@
"Microsoft.AspNet.Cryptography.KeyDerivation": "1.0.0-beta8",
"Microsoft.AspNet.Identity": "3.0.0-beta8",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta8",
"Microsoft.Framework.DependencyInjection.Abstractions": "1.0.0-beta8",
"RazorEngine": "3.7.5",
"WaCore.Contracts": "1.0.0",
"WaCore.Entities": "1.0.0"
Expand Down Expand Up @@ -9065,6 +9069,7 @@
"Microsoft.AspNet.Identity": "3.0.0-beta8",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta8",
"Microsoft.CSharp": "4.0.1-beta-23409",
"Microsoft.Framework.DependencyInjection.Abstractions": "1.0.0-beta8",
"System.Collections": "4.0.11-beta-23409",
"System.Linq": "4.0.1-beta-23409",
"System.Runtime": "4.0.21-beta-23409",
Expand Down Expand Up @@ -11590,6 +11595,7 @@
"Microsoft.AspNet.Identity": "3.0.0-beta8",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta8",
"Microsoft.CSharp": "4.0.1-beta-23409",
"Microsoft.Framework.DependencyInjection.Abstractions": "1.0.0-beta8",
"System.Collections": "4.0.11-beta-23409",
"System.Linq": "4.0.1-beta-23409",
"System.Runtime": "4.0.21-beta-23409",
Expand Down

0 comments on commit e152f97

Please sign in to comment.