Skip to content

Commit 9cbb7e1

Browse files
committed
Put ServiceRegistration in own class
1 parent 1f3782f commit 9cbb7e1

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using LinkDotNet.Blog.Web.Pages.Admin;
2+
using LinkDotNet.Blog.Web.Shared.Services;
3+
using LinkDotNet.Blog.Web.Shared.Services.Sitemap;
4+
using Microsoft.Extensions.DependencyInjection;
5+
6+
namespace LinkDotNet.Blog.Web
7+
{
8+
public static class ServiceExtensions
9+
{
10+
public static void RegisterServices(this IServiceCollection services)
11+
{
12+
services.AddScoped<ILocalStorageService, LocalStorageService>();
13+
services.AddSingleton<ISortOrderCalculator, SortOrderCalculator>();
14+
services.AddScoped<IUserRecordService, UserRecordService>();
15+
services.AddScoped<IDashboardService, DashboardService>();
16+
services.AddScoped<ISitemapService, SitemapService>();
17+
services.AddScoped<IXmlFileWriter, XmlFileWriter>();
18+
}
19+
}
20+
}

LinkDotNet.Blog.Web/Startup.cs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
using Blazored.Toast;
22
using LinkDotNet.Blog.Web.Authentication.Auth0;
33
using LinkDotNet.Blog.Web.Authentication.Dummy;
4-
using LinkDotNet.Blog.Web.Pages.Admin;
54
using LinkDotNet.Blog.Web.RegistrationExtensions;
6-
using LinkDotNet.Blog.Web.Shared.Services;
7-
using LinkDotNet.Blog.Web.Shared.Services.Sitemap;
85
using Microsoft.AspNetCore.Builder;
96
using Microsoft.AspNetCore.Hosting;
107
using Microsoft.Extensions.Configuration;
@@ -45,7 +42,7 @@ public void ConfigureServices(IServiceCollection services)
4542

4643
services.AddBlazoredToast();
4744
services.AddHeadElementHelper();
48-
RegisterServices(services);
45+
services.RegisterServices();
4946
}
5047

5148
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
@@ -77,15 +74,5 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
7774
endpoints.MapFallbackToPage("/_Host");
7875
});
7976
}
80-
81-
private static void RegisterServices(IServiceCollection services)
82-
{
83-
services.AddScoped<ILocalStorageService, LocalStorageService>();
84-
services.AddSingleton<ISortOrderCalculator, SortOrderCalculator>();
85-
services.AddScoped<IUserRecordService, UserRecordService>();
86-
services.AddScoped<IDashboardService, DashboardService>();
87-
services.AddScoped<ISitemapService, SitemapService>();
88-
services.AddScoped<IXmlFileWriter, XmlFileWriter>();
89-
}
9077
}
9178
}

0 commit comments

Comments
 (0)