Skip to content

Commit

Permalink
✨ refactoring code
Browse files Browse the repository at this point in the history
  • Loading branch information
neozhu committed Sep 24, 2023
1 parent 74fdbec commit decd0fa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Application/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public static IServiceCollection AddApplicationServices(this IServiceCollection
options.UseReduxDevTools();
});
services.AddLazyCache();
services.AddScoped<PicklistService>();
services.AddScoped<IPicklistService>(sp => {
services.AddSingleton<PicklistService>();
services.AddSingleton<IPicklistService>(sp => {
var service = sp.GetRequiredService<PicklistService>();
service.Initialize();
return service;
Expand Down
7 changes: 5 additions & 2 deletions src/Application/Services/Picklist/PicklistService.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using CleanArchitecture.Blazor.Application.Features.KeyValues.Caching;
using CleanArchitecture.Blazor.Application.Features.KeyValues.DTOs;
using Microsoft.Extensions.DependencyInjection;

namespace CleanArchitecture.Blazor.Application.Services.Picklist;

Expand All @@ -11,10 +12,12 @@ public class PicklistService : IPicklistService

public PicklistService(
IAppCache cache,
IApplicationDbContext context, IMapper mapper)
IServiceScopeFactory scopeFactory,
IMapper mapper)
{
_cache = cache;
_context = context;
var scope = scopeFactory.CreateScope();
_context = scope.ServiceProvider.GetRequiredService<IApplicationDbContext>();
_mapper = mapper;
}

Expand Down

0 comments on commit decd0fa

Please sign in to comment.