From b7909e7c25b8663c9e477cf1291aeabda81eb678 Mon Sep 17 00:00:00 2001 From: Hsu Still <341464@gmail.com> Date: Thu, 28 Sep 2017 15:55:06 +0800 Subject: [PATCH] Adjust service collection sample ...according to https://github.com/RogueException/Discord.Net/pull/826/files/f89aecb7bfa8fe82a541d3bba44d0e37c125d235#r141530227 --- .../commands/samples/dependency_map_setup.cs | 30 +++++++++---------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/guides/commands/samples/dependency_map_setup.cs b/docs/guides/commands/samples/dependency_map_setup.cs index 413f3d9a0..08f06edbf 100644 --- a/docs/guides/commands/samples/dependency_map_setup.cs +++ b/docs/guides/commands/samples/dependency_map_setup.cs @@ -1,18 +1,18 @@ -using Discord; -using Discord.Commands; -using Discord.WebSocket; -using foxboat.Services; +private IServiceProvider _services; +private CommandService _commands; -public class Commands +public async Task InstallAsync(DiscordSocketClient client) { - public async Task Install(DiscordSocketClient client) - { - // Here, we will inject the ServiceProvider with - // all of the services our client will use. - _serviceCollection.AddSingleton(client); - _serviceCollection.AddSingleton(new NotificationService()); - _serviceCollection.AddSingleton(new DatabaseService()); - // ... - await _commands.AddModulesAsync(Assembly.GetEntryAssembly()); - } + // Here, we will inject the ServiceProvider with + // all of the services our client will use. + _services = new ServiceCollection() + .AddSingleton(client) + .AddSingleton(_commands) + // You can pass in an instance of the desired type + .AddSingleton(new NotificationService()) + // ...or by using the generic method. + .AddSingleton() + .BuildServiceProvider(); + // ... + await _commands.AddModulesAsync(Assembly.GetEntryAssembly()); }