Replaced DependencyMap with ServiceCollection and IServiceProvider (#625)
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Discord.Commands.Builders
|
||||
{
|
||||
@@ -12,7 +13,7 @@ namespace Discord.Commands.Builders
|
||||
private readonly List<string> _aliases;
|
||||
|
||||
public ModuleBuilder Module { get; }
|
||||
internal Func<ICommandContext, object[], IDependencyMap, Task> Callback { get; set; }
|
||||
internal Func<ICommandContext, object[], IServiceProvider, Task> Callback { get; set; }
|
||||
|
||||
public string Name { get; set; }
|
||||
public string Summary { get; set; }
|
||||
@@ -35,7 +36,7 @@ namespace Discord.Commands.Builders
|
||||
_aliases = new List<string>();
|
||||
}
|
||||
//User-defined
|
||||
internal CommandBuilder(ModuleBuilder module, string primaryAlias, Func<ICommandContext, object[], IDependencyMap, Task> callback)
|
||||
internal CommandBuilder(ModuleBuilder module, string primaryAlias, Func<ICommandContext, object[], IServiceProvider, Task> callback)
|
||||
: this(module)
|
||||
{
|
||||
Discord.Preconditions.NotNull(primaryAlias, nameof(primaryAlias));
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
namespace Discord.Commands.Builders
|
||||
{
|
||||
@@ -73,7 +74,7 @@ namespace Discord.Commands.Builders
|
||||
_preconditions.Add(precondition);
|
||||
return this;
|
||||
}
|
||||
public ModuleBuilder AddCommand(string primaryAlias, Func<ICommandContext, object[], IDependencyMap, Task> callback, Action<CommandBuilder> createFunc)
|
||||
public ModuleBuilder AddCommand(string primaryAlias, Func<ICommandContext, object[], IServiceProvider, Task> callback, Action<CommandBuilder> createFunc)
|
||||
{
|
||||
var builder = new CommandBuilder(this, primaryAlias, callback);
|
||||
createFunc(builder);
|
||||
|
||||
@@ -243,7 +243,7 @@ namespace Discord.Commands
|
||||
}
|
||||
|
||||
//We dont have a cached type reader, create one
|
||||
reader = ReflectionUtils.CreateObject<TypeReader>(typeReaderType.GetTypeInfo(), service, DependencyMap.Empty);
|
||||
reader = ReflectionUtils.CreateObject<TypeReader>(typeReaderType.GetTypeInfo(), service, EmptyServiceProvider.Instance);
|
||||
service.AddTypeReader(paramType, reader);
|
||||
|
||||
return reader;
|
||||
|
||||
Reference in New Issue
Block a user