Files
reallife-gamemode/ReallifeGamemode.DataService/Logic/LogicBase.cs
Lennart Kampshoff ed95acc24d Code formatiert
2019-12-21 14:03:06 +01:00

36 lines
860 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using ReallifeGamemode.Database.Models;
namespace ReallifeGamemode.DataService.Logic
{
public abstract class LogicBase
{
protected readonly DatabaseContext dbContext;
public LogicBase(DatabaseContext dbContext)
{
this.dbContext = dbContext;
}
}
public static class ServiceCollectionExtensions
{
public static IServiceCollection AddLogic(this IServiceCollection services)
{
Type[] types = Assembly.GetExecutingAssembly().GetTypes().Where(t => t.IsSubclassOf(typeof(LogicBase)) && !t.IsAbstract).ToArray();
foreach (Type type in types)
{
services = services.AddScoped(type);
}
return services;
}
}
}