DataService hinzugefügt

This commit is contained in:
hydrant
2019-09-17 23:09:00 +02:00
parent e62ca95f4d
commit 73659cdb9e
13 changed files with 490 additions and 1 deletions

View File

@@ -0,0 +1,35 @@
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;
}
}
}