diff --git a/LightweightIocContainer/Interfaces/IIocContainer.cs b/LightweightIocContainer/Interfaces/IIocContainer.cs index be16027..18a7972 100644 --- a/LightweightIocContainer/Interfaces/IIocContainer.cs +++ b/LightweightIocContainer/Interfaces/IIocContainer.cs @@ -22,7 +22,7 @@ namespace LightweightIocContainer.Interfaces IIocContainer Install(params IIocInstaller[] installers); /// - /// Register an Interface with a Type that implements it/> + /// Register an Interface with a Type that implements it /// /// The Interface to register /// The Type that implements the interface @@ -31,7 +31,7 @@ namespace LightweightIocContainer.Interfaces IDefaultRegistration Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface; /// - /// Register a without an interface/> + /// Register a without an interface /// /// The to register /// The for this @@ -39,7 +39,7 @@ namespace LightweightIocContainer.Interfaces IDefaultRegistration Register(Lifestyle lifestyle = Lifestyle.Transient); /// - /// Register an Interface with a Type that implements it as a multiton/> + /// Register an Interface with a Type that implements it as a multiton /// /// The Interface to register /// The Type that implements the interface @@ -48,45 +48,12 @@ namespace LightweightIocContainer.Interfaces IMultitonRegistration Register() where TImplementation : TInterface; /// - /// Register an Interface with a Type that implements it/> - /// - /// The Interface to register - /// The Type that implements the interface - /// The for this - /// The created - IRegistrationBase Register(Type tInterface, Type tImplementation, Lifestyle lifestyle = Lifestyle.Transient); - - /// - /// Register a without an interface/> - /// - /// The to register - /// The for this - /// The created - IRegistrationBase Register(Type tImplementation, Lifestyle lifestyle = Lifestyle.Transient); - - /// - /// Register an Interface with a Type that implements it as a multiton/> - /// - /// The Interface to register - /// The Type that implements the interface - /// The Type of the multiton scope - /// The created - IRegistrationBase Register(Type tInterface, Type tImplementation, Type tScope); - - /// - /// Register an Interface as an abstract typed factory/> + /// Register an Interface as an abstract typed factory /// /// The abstract typed factory to register /// The created ITypedFactoryRegistration RegisterFactory(); - /// - /// Register an Interface as an abstract typed factory/> - /// - /// The abstract typed factory to register - /// The created - IRegistrationBase RegisterFactory(Type tFactory); - /// /// Register an Interface with an as a callback that is called when is called /// diff --git a/LightweightIocContainer/IocContainer.cs b/LightweightIocContainer/IocContainer.cs index cb78a84..d1320f4 100644 --- a/LightweightIocContainer/IocContainer.cs +++ b/LightweightIocContainer/IocContainer.cs @@ -53,7 +53,7 @@ namespace LightweightIocContainer } /// - /// Register an Interface with a Type that implements it/> + /// Register an Interface with a Type that implements it /// /// The Interface to register /// The Type that implements the interface @@ -68,7 +68,7 @@ namespace LightweightIocContainer } /// - /// Register a without an interface/> + /// Register a without an interface /// /// The to register /// The for this @@ -82,7 +82,7 @@ namespace LightweightIocContainer } /// - /// Register an Interface with a Type that implements it as a multiton/> + /// Register an Interface with a Type that implements it as a multiton /// /// The Interface to register /// The Type that implements the interface @@ -97,51 +97,7 @@ namespace LightweightIocContainer } /// - /// Register an Interface with a Type that implements it/> - /// - /// The Interface to register - /// The Type that implements the interface - /// The for this - /// The created - public IRegistrationBase Register(Type tInterface, Type tImplementation, Lifestyle lifestyle = Lifestyle.Transient) - { - IRegistrationBase registration = _registrationFactory.Register(tInterface, tImplementation, lifestyle); - Register(registration); - - return registration; - } - - /// - /// Register a without an interface/> - /// - /// The to register - /// The for this - /// The created - public IRegistrationBase Register(Type tImplementation, Lifestyle lifestyle = Lifestyle.Transient) - { - IRegistrationBase registration = _registrationFactory.Register(tImplementation, lifestyle); - Register(registration); - - return registration; - } - - /// - /// Register an Interface with a Type that implements it as a multiton/> - /// - /// The Interface to register - /// The Type that implements the interface - /// The Type of the multiton scope - /// The created - public IRegistrationBase Register(Type tInterface, Type tImplementation, Type tScope) - { - IRegistrationBase registration = _registrationFactory.Register(tInterface, tImplementation, tScope); - Register(registration); - - return registration; - } - - /// - /// Register an Interface as an abstract typed factory/> + /// Register an Interface as an abstract typed factory /// /// The abstract typed factory to register /// The created @@ -153,19 +109,6 @@ namespace LightweightIocContainer return registration; } - /// - /// Register an Interface as an abstract typed factory/> - /// - /// The abstract typed factory to register - /// The created - public IRegistrationBase RegisterFactory(Type tFactory) - { - IRegistrationBase registration = _registrationFactory.RegisterFactory(tFactory); - Register(registration); - - return registration; - } - /// /// Register an Interface with an as a callback that is called when is called /// diff --git a/LightweightIocContainer/LightweightIocContainer.xml b/LightweightIocContainer/LightweightIocContainer.xml index 74fab0b..4b01ad3 100644 --- a/LightweightIocContainer/LightweightIocContainer.xml +++ b/LightweightIocContainer/LightweightIocContainer.xml @@ -219,7 +219,7 @@ - Register an Interface with a Type that implements it/> + Register an Interface with a Type that implements it The Interface to register The Type that implements the interface @@ -228,7 +228,7 @@ - Register a without an interface/> + Register a without an interface The to register The for this @@ -236,53 +236,20 @@ - Register an Interface with a Type that implements it as a multiton/> + Register an Interface with a Type that implements it as a multiton The Interface to register The Type that implements the interface The Type of the multiton scope The created - - - Register an Interface with a Type that implements it/> - - The Interface to register - The Type that implements the interface - The for this - The created - - - - Register a without an interface/> - - The to register - The for this - The created - - - - Register an Interface with a Type that implements it as a multiton/> - - The Interface to register - The Type that implements the interface - The Type of the multiton scope - The created - - Register an Interface as an abstract typed factory/> + Register an Interface as an abstract typed factory The abstract typed factory to register The created - - - Register an Interface as an abstract typed factory/> - - The abstract typed factory to register - The created - Register an Interface with an as a callback that is called when is called @@ -445,7 +412,7 @@ - Register an Interface with a Type that implements it/> + Register an Interface with a Type that implements it The Interface to register The Type that implements the interface @@ -454,7 +421,7 @@ - Register a without an interface/> + Register a without an interface The to register The for this @@ -462,53 +429,20 @@ - Register an Interface with a Type that implements it as a multiton/> + Register an Interface with a Type that implements it as a multiton The Interface to register The Type that implements the interface The Type of the multiton scope The created - - - Register an Interface with a Type that implements it/> - - The Interface to register - The Type that implements the interface - The for this - The created - - - - Register a without an interface/> - - The to register - The for this - The created - - - - Register an Interface with a Type that implements it as a multiton/> - - The Interface to register - The Type that implements the interface - The Type of the multiton scope - The created - - Register an Interface as an abstract typed factory/> + Register an Interface as an abstract typed factory The abstract typed factory to register The created - - - Register an Interface as an abstract typed factory/> - - The abstract typed factory to register - The created - Register an Interface with an as a callback that is called when is called @@ -735,32 +669,6 @@ The Type of the multiton scope A new created with the given parameters - - - Register an Interface with a Type that implements it and create a - - The Interface to register - The Type that implements the interface - The for this - A new created with the given parameters - - - - Register a without an interface and create a - - The to register - The for this - A new created with the given parameters - - - - Register an Interface with a Type that implements it as a multiton and create a - - The Interface to register - The Type that implements the interface - The Type of the multiton scope - A new created with the given parameters - Register an Interface as an abstract typed factory and create a @@ -768,13 +676,6 @@ The abstract typed factory to register A new created with the given parameters - - - Register an Interface as an abstract typed factory and create a - - The abstract typed factory to register - A new created with the given parameters - The registration that is used to register an abstract typed factory diff --git a/LightweightIocContainer/Registrations/RegistrationFactory.cs b/LightweightIocContainer/Registrations/RegistrationFactory.cs index 08284a8..1482424 100644 --- a/LightweightIocContainer/Registrations/RegistrationFactory.cs +++ b/LightweightIocContainer/Registrations/RegistrationFactory.cs @@ -60,46 +60,6 @@ namespace LightweightIocContainer.Registrations return new MultitonRegistration(typeof(TInterface), typeof(TImplementation), typeof(TScope)); } - /// - /// Register an Interface with a Type that implements it and create a - /// - /// The Interface to register - /// The Type that implements the interface - /// The for this - /// A new created with the given parameters - public IRegistrationBase Register(Type tInterface, Type tImplementation, Lifestyle lifestyle) - { - Type defaultRegistrationType = typeof(DefaultRegistration<>).MakeGenericType(tInterface); - return (IRegistrationBase)Activator.CreateInstance(defaultRegistrationType, tInterface, tImplementation, lifestyle); - } - - /// - /// Register a without an interface and create a - /// - /// The to register - /// The for this - /// A new created with the given parameters - public IRegistrationBase Register(Type tImplementation, Lifestyle lifestyle) - { - if (tImplementation.IsInterface) - throw new InvalidRegistrationException("Can't register an interface without its implementation type."); - - return Register(tImplementation, tImplementation, lifestyle); - } - - /// - /// Register an Interface with a Type that implements it as a multiton and create a - /// - /// The Interface to register - /// The Type that implements the interface - /// The Type of the multiton scope - /// A new created with the given parameters - public IRegistrationBase Register(Type tInterface, Type tImplementation, Type tScope) - { - Type multitonRegistrationType = typeof(MultitonRegistration<>).MakeGenericType(tInterface); - return (IRegistrationBase)Activator.CreateInstance(multitonRegistrationType, tInterface, tImplementation, tScope); - } - /// /// Register an Interface as an abstract typed factory and create a /// @@ -110,17 +70,6 @@ namespace LightweightIocContainer.Registrations return new TypedFactoryRegistration(typeof(TFactory), _iocContainer); } - /// - /// Register an Interface as an abstract typed factory and create a - /// - /// The abstract typed factory to register - /// A new created with the given parameters - public IRegistrationBase RegisterFactory(Type tFactory) - { - Type factoryRegistrationType = typeof(TypedFactoryRegistration<>).MakeGenericType(tFactory); - return (IRegistrationBase)Activator.CreateInstance(factoryRegistrationType, tFactory, _iocContainer); - } - public IUnitTestCallbackRegistration RegisterUnitTestCallback(ResolveCallback unitTestResolveCallback) { return new UnitTestCallbackRegistration(typeof(TInterface), unitTestResolveCallback); diff --git a/Test.LightweightIocContainer/IocContainerTest.cs b/Test.LightweightIocContainer/IocContainerTest.cs index d690d25..daa5d37 100644 --- a/Test.LightweightIocContainer/IocContainerTest.cs +++ b/Test.LightweightIocContainer/IocContainerTest.cs @@ -65,6 +65,7 @@ namespace Test.LightweightIocContainer [UsedImplicitly] private class TestByte : ITest { + [UsedImplicitly] private readonly byte _id; public TestByte(byte id) @@ -127,25 +128,25 @@ namespace Test.LightweightIocContainer [Test] public void TestRegister() { - Assert.DoesNotThrow(() => _iocContainer.Register(typeof(ITest), typeof(Test))); + Assert.DoesNotThrow(() => _iocContainer.Register()); } [Test] public void TestRegisterTypeWithoutInterface() { - Assert.DoesNotThrow(() => _iocContainer.Register(typeof(Test))); + Assert.DoesNotThrow(() => _iocContainer.Register()); } [Test] public void TestRegisterMultiton() { - Assert.DoesNotThrow(() => _iocContainer.Register(typeof(ITest), typeof(Test), typeof(MultitonScope))); + Assert.DoesNotThrow(() => _iocContainer.Register()); } [Test] public void TestRegisterFactory() { - Assert.DoesNotThrow(() => _iocContainer.RegisterFactory(typeof(ITestFactory))); + Assert.DoesNotThrow(() => _iocContainer.RegisterFactory()); } [Test] @@ -160,7 +161,6 @@ namespace Test.LightweightIocContainer public void TestRegisterInterfaceWithoutImplementation() { Assert.Throws(() => _iocContainer.Register()); - Assert.Throws(() => _iocContainer.Register(typeof(ITest))); } [Test]