From ba406bb646cb66103a412cb4ecc5ac6aaffeb8e5 Mon Sep 17 00:00:00 2001 From: Khionu Sybiern Date: Thu, 2 Mar 2017 01:39:45 -0500 Subject: [PATCH] Split typechecks into their own conditions --- .../Dependencies/DependencyMap.cs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Discord.Net.Commands/Dependencies/DependencyMap.cs b/src/Discord.Net.Commands/Dependencies/DependencyMap.cs index b89ab4370..7fb8d33c9 100644 --- a/src/Discord.Net.Commands/Dependencies/DependencyMap.cs +++ b/src/Discord.Net.Commands/Dependencies/DependencyMap.cs @@ -38,8 +38,10 @@ namespace Discord.Commands public void AddFactory(Func 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 (typeof(T) == typeof(IDependencyMap)) + throw new InvalidOperationException("IDependencyMap is used internally and cannot be added as a dependency"); + if (typeof(T) == typeof(CommandService)) + throw new InvalidOperationException("CommandService is used internally and cannot be added as a dependency"); if (map.ContainsKey(t)) throw new InvalidOperationException($"The dependency map already contains \"{t.FullName}\""); map.Add(t, factory); @@ -50,8 +52,10 @@ 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"); + if (typeof(T) == typeof(IDependencyMap)) + throw new InvalidOperationException("IDependencyMap is used internally and cannot be added as a dependency"); + if (typeof(T) == typeof(CommandService)) + throw new InvalidOperationException("CommandService is used internally and cannot be added as a dependency"); map.Add(t, factory); return true; }