Refactor Dependency Builder
This commit is contained in:
parent
7cab8dbac0
commit
28d7afa486
19
ChaosBot/Dependency/ServiceBuilder.cs
Normal file
19
ChaosBot/Dependency/ServiceBuilder.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using ChaosBot.Discord.Services;
|
||||
using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace ChaosBot.Dependency
|
||||
{
|
||||
public static class ServiceBuilder
|
||||
{
|
||||
public static ServiceProvider Create()
|
||||
{
|
||||
return new ServiceCollection()
|
||||
.AddSingleton<DiscordSocketClient>()
|
||||
.AddSingleton<CommandService>()
|
||||
.AddSingleton<CommandHandler>()
|
||||
.BuildServiceProvider();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -4,6 +4,7 @@ using Discord.Commands;
|
||||
using Discord.WebSocket;
|
||||
using System.Threading.Tasks;
|
||||
using ChaosBot.ConfigHelpers;
|
||||
using ChaosBot.Dependency;
|
||||
using ChaosBot.Discord.Services;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
@ -62,11 +63,7 @@ namespace ChaosBot.Discord
|
||||
|
||||
try
|
||||
{
|
||||
csInfo = new ServiceCollection()
|
||||
.AddSingleton<DiscordSocketClient>()
|
||||
.AddSingleton<CommandService>()
|
||||
.AddSingleton<CommandHandler>()
|
||||
.BuildServiceProvider();
|
||||
csInfo = ServiceBuilder.Create();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user