Implimented discussed changes

This commit is contained in:
Khionu Sybiern
2017-03-01 14:19:28 -05:00
parent c350debdba
commit 4274900d43
2 changed files with 5 additions and 1 deletions

View File

@@ -38,6 +38,8 @@ namespace Discord.Commands
public void AddFactory<T>(Func<T> factory) where T : class
{
var t = typeof(T);
if (typeof(T) == typeof(IDependencyMap) || typeof(T) == typeof(CommandService))
throw new InvalidOperationException("The dependency map cannot contain services directly added as IDependencyMap or CommandService. Only Implimentations and Derivatives are permitted");
if (map.ContainsKey(t))
throw new InvalidOperationException($"The dependency map already contains \"{t.FullName}\"");
map.Add(t, factory);
@@ -48,6 +50,8 @@ namespace Discord.Commands
var t = typeof(T);
if (map.ContainsKey(t))
return false;
if (typeof(T) == typeof(IDependencyMap) || typeof(T) == typeof(CommandService))
throw new InvalidOperationException("The dependency map cannot contain services directly added as IDependencyMap or CommandService. Only Implimentations and Derivatives are permitted");
map.Add(t, factory);
return true;
}