semesterWork/Presence.Desktop/DI/ServiceCollectionExtensions.cs
2024-12-13 08:47:52 +03:00

41 lines
1.3 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;
using data;
using data.Repository;
using domain.Service;
using domain.UseCase;
using Microsoft.Extensions.DependencyInjection;
using Presence.Desktop.ViewModels;
namespace Presence.Desktop.DI
{
public static class ServiceCollectionExtensions
{
public static void AddCommonService(this IServiceCollection collection)
{
collection
.AddDbContext<RemoteDatabaseContext>()
.AddSingleton<IGroupRepository, SQLGroupRepository>()
.AddTransient<IGroupUseCase, GroupService>()
.AddSingleton<SQLPresenceRepository>()
.AddTransient<PresenceService>()
.AddTransient<GroupViewModel>();
}
public static void AddPresenceService(this IServiceCollection collection)
{
collection
.AddDbContext<RemoteDatabaseContext>()
.AddSingleton<IGroupRepository, SQLGroupRepository>()
.AddTransient<IGroupUseCase, GroupService>()
.AddSingleton<SQLPresenceRepository>()
.AddTransient<PresenceService>()
.AddTransient<PresenceViewModel>();
}
}
}