From 83a396b86ec892c6382d563a95adfb61c8c51c2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Selim=20Y=C4=B1ld=C4=B1z?= Date: Fri, 31 Jul 2020 13:12:02 +0300 Subject: [PATCH] Removed code duplication for Register in IoC --- CommandCore.LightIoC/BasicServiceProvider.cs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/CommandCore.LightIoC/BasicServiceProvider.cs b/CommandCore.LightIoC/BasicServiceProvider.cs index 6ca4a95..f9f764a 100644 --- a/CommandCore.LightIoC/BasicServiceProvider.cs +++ b/CommandCore.LightIoC/BasicServiceProvider.cs @@ -19,19 +19,7 @@ private readonly ConcurrentDictionary /// If the concrete type is not instantiable. For instance, using an abstract class for the concrete type throws this exception. public void Register() { - if (typeof(T).IsAbstract) - { - throw new InvalidOperationException( - $"Type {typeof(T).FullName} may not be abstract. Abstract classes cannot be instantiated, hence not allowed to be registered."); - } - - if (!typeof(S).IsAssignableFrom(typeof(T))) - { - throw new InvalidOperationException( - $"Type {typeof(T).FullName} is not assignable to {typeof(S).FullName}"); - } - - _typeRegistry[typeof(S)] = typeof(T); + Register(typeof(S), typeof(T)); } public void Register(Type service, Type implementation)