diff --git a/LightweightIocContainer/Interfaces/IIocContainer.cs b/LightweightIocContainer/Interfaces/IIocContainer.cs
index f2ecd6a..8b3712f 100644
--- a/LightweightIocContainer/Interfaces/IIocContainer.cs
+++ b/LightweightIocContainer/Interfaces/IIocContainer.cs
@@ -22,11 +22,62 @@ namespace LightweightIocContainer.Interfaces
IIocContainer Install(params IIocInstaller[] installers);
///
- /// Add the to the the
+ /// Register an Interface with a Type that implements it/>
///
- /// The given
- /// The is already registered in this
- void Register(IRegistrationBase registration);
+ /// The Interface to register
+ /// The Type that implements the interface
+ /// The for this
+ void Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface;
+
+ ///
+ /// Register a without an interface/>
+ ///
+ /// The to register
+ /// The for this
+ void Register(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
+ void 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
+ void Register(Type tInterface, Type tImplementation, Lifestyle lifestyle = Lifestyle.Transient);
+
+ ///
+ /// Register a without an interface/>
+ ///
+ /// The to register
+ /// The for this
+ void 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
+ void Register(Type tInterface, Type tImplementation, Type tScope);
+
+ ///
+ /// Register an Interface as an abstract typed factory/>
+ ///
+ /// The abstract typed factory to register
+ void RegisterFactory();
+
+ ///
+ /// Register an Interface as an abstract typed factory/>
+ ///
+ /// The abstract typed factory to register
+ void RegisterFactory(Type tFactory);
///
/// Gets an instance of the given
diff --git a/LightweightIocContainer/IocContainer.cs b/LightweightIocContainer/IocContainer.cs
index 34e92e1..08d99a8 100644
--- a/LightweightIocContainer/IocContainer.cs
+++ b/LightweightIocContainer/IocContainer.cs
@@ -12,6 +12,7 @@ using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Installers;
using LightweightIocContainer.Interfaces.Registrations;
+using LightweightIocContainer.Registrations;
namespace LightweightIocContainer
{
@@ -20,10 +21,22 @@ namespace LightweightIocContainer
///
public class IocContainer : IIocContainer
{
+ private readonly RegistrationFactory _registrationFactory;
+
private readonly List _registrations = new List();
private readonly List<(Type type, object instance)> _singletons = new List<(Type, object)>();
private readonly List<(Type type, Type scope, ConditionalWeakTable instances)> _multitons = new List<(Type, Type, ConditionalWeakTable)>();
+
+ ///
+ /// The constructor of the
+ ///
+ public IocContainer()
+ {
+ _registrationFactory = new RegistrationFactory(this);
+ }
+
+
///
/// Install the given installers for the current
///
@@ -39,12 +52,94 @@ namespace LightweightIocContainer
return this;
}
+ ///
+ /// Register an Interface with a Type that implements it/>
+ ///
+ /// The Interface to register
+ /// The Type that implements the interface
+ /// The for this
+ public void Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface
+ {
+ Register(_registrationFactory.Register(lifestyle));
+ }
+
+ ///
+ /// Register a without an interface/>
+ ///
+ /// The to register
+ /// The for this
+ public void Register(Lifestyle lifestyle = Lifestyle.Transient)
+ {
+ Register(_registrationFactory.Register(lifestyle));
+ }
+
+ ///
+ /// 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
+ public void Register() where TImplementation : TInterface
+ {
+ Register(_registrationFactory.Register());
+ }
+
+ ///
+ /// Register an Interface with a Type that implements it/>
+ ///
+ /// The Interface to register
+ /// The Type that implements the interface
+ /// The for this
+ public void Register(Type tInterface, Type tImplementation, Lifestyle lifestyle = Lifestyle.Transient)
+ {
+ Register(_registrationFactory.Register(tInterface, tImplementation, lifestyle));
+ }
+
+ ///
+ /// Register a without an interface/>
+ ///
+ /// The to register
+ /// The for this
+ public void Register(Type tImplementation, Lifestyle lifestyle = Lifestyle.Transient)
+ {
+ Register(_registrationFactory.Register(tImplementation, lifestyle));
+ }
+
+ ///
+ /// 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
+ public void Register(Type tInterface, Type tImplementation, Type tScope)
+ {
+ Register(_registrationFactory.Register(tInterface, tImplementation, tScope));
+ }
+
+ ///
+ /// Register an Interface as an abstract typed factory/>
+ ///
+ /// The abstract typed factory to register
+ public void RegisterFactory()
+ {
+ Register(_registrationFactory.RegisterFactory());
+ }
+
+ ///
+ /// Register an Interface as an abstract typed factory/>
+ ///
+ /// The abstract typed factory to register
+ public void RegisterFactory(Type tFactory)
+ {
+ Register(_registrationFactory.RegisterFactory(tFactory));
+ }
+
///
/// Add the to the the
///
/// The given
/// The is already registered in this
- public void Register(IRegistrationBase registration)
+ private void Register(IRegistrationBase registration)
{
//if type is already registered
if (_registrations.Any(r => r.InterfaceType == registration.InterfaceType))
diff --git a/LightweightIocContainer/LightweightIocContainer.xml b/LightweightIocContainer/LightweightIocContainer.xml
index 48a550f..f532526 100644
--- a/LightweightIocContainer/LightweightIocContainer.xml
+++ b/LightweightIocContainer/LightweightIocContainer.xml
@@ -217,12 +217,63 @@
The given s
An instance of the current
-
+
- Add the to the the
+ Register an Interface with a Type that implements it/>
- The given
- The is already registered in this
+ The Interface to register
+ The Type that implements the interface
+ The for this
+
+
+
+ Register a without an interface/>
+
+ The to register
+ The for this
+
+
+
+ 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
+
+
+
+ Register an Interface with a Type that implements it/>
+
+ The Interface to register
+ The Type that implements the interface
+ The for this
+
+
+
+ Register a without an interface/>
+
+ The to register
+ The for this
+
+
+
+ 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
+
+
+
+ Register an Interface as an abstract typed factory/>
+
+ The abstract typed factory to register
+
+
+
+ Register an Interface as an abstract typed factory/>
+
+ The abstract typed factory to register
@@ -353,6 +404,11 @@
The main container that carries all the s and can resolve all the types you'll ever want
+
+
+ The constructor of the
+
+
Install the given installers for the current
@@ -360,6 +416,64 @@
The given s
An instance of the current
+
+
+ Register an Interface with a Type that implements it/>
+
+ The Interface to register
+ The Type that implements the interface
+ The for this
+
+
+
+ Register a without an interface/>
+
+ The to register
+ The for this
+
+
+
+ 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
+
+
+
+ Register an Interface with a Type that implements it/>
+
+ The Interface to register
+ The Type that implements the interface
+ The for this
+
+
+
+ Register a without an interface/>
+
+ The to register
+ The for this
+
+
+
+ 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
+
+
+
+ Register an Interface as an abstract typed factory/>
+
+ The abstract typed factory to register
+
+
+
+ Register an Interface as an abstract typed factory/>
+
+ The abstract typed factory to register
+
Add the to the the
@@ -604,20 +718,18 @@
The Type of the multiton scope
A new created with the given parameters
-
+
Register an Interface as an abstract typed factory and create a
The abstract typed factory to register
- The current
A new created with the given parameters
-
+
Register an Interface as an abstract typed factory and create a
The abstract typed factory to register
- The current
A new created with the given parameters
diff --git a/LightweightIocContainer/Registrations/RegistrationFactory.cs b/LightweightIocContainer/Registrations/RegistrationFactory.cs
index c07e8ca..e4dca51 100644
--- a/LightweightIocContainer/Registrations/RegistrationFactory.cs
+++ b/LightweightIocContainer/Registrations/RegistrationFactory.cs
@@ -13,8 +13,15 @@ namespace LightweightIocContainer.Registrations
///
/// A factory to register interfaces and factories in an and create the needed s
///
- public static class RegistrationFactory
+ internal class RegistrationFactory
{
+ private readonly IIocContainer _iocContainer;
+
+ internal RegistrationFactory(IIocContainer container)
+ {
+ _iocContainer = container;
+ }
+
///
/// Register an Interface with a Type that implements it and create a
///
@@ -22,7 +29,7 @@ namespace LightweightIocContainer.Registrations
/// The Type that implements the interface
/// The for this
/// A new created with the given parameters
- public static IDefaultRegistration Register(Lifestyle lifestyle = Lifestyle.Transient) where TImplementation : TInterface
+ public IDefaultRegistration Register(Lifestyle lifestyle) where TImplementation : TInterface
{
return new DefaultRegistration(typeof(TInterface), typeof(TImplementation), lifestyle);
}
@@ -33,9 +40,9 @@ namespace LightweightIocContainer.Registrations
/// The to register
/// The for this
/// A new created with the given parameters
- public static IDefaultRegistration Register(Lifestyle lifestyle = Lifestyle.Transient)
+ public IDefaultRegistration Register(Lifestyle lifestyle)
{
- if (typeof(TImplementation).IsInterface)
+ if (typeof(TImplementation).IsInterface) //TODO: handle `Instance` case when an instance is given
throw new InvalidRegistrationException("Can't register an interface without its implementation type.");
return Register(lifestyle);
@@ -48,7 +55,7 @@ namespace LightweightIocContainer.Registrations
/// The Type that implements the interface
/// The Type of the multiton scope
/// A new created with the given parameters
- public static IMultitonRegistration Register() where TImplementation : TInterface
+ public IMultitonRegistration Register() where TImplementation : TInterface
{
return new MultitonRegistration(typeof(TInterface), typeof(TImplementation), typeof(TScope));
}
@@ -60,7 +67,7 @@ namespace LightweightIocContainer.Registrations
/// The Type that implements the interface
/// The for this
/// A new created with the given parameters
- public static IRegistrationBase Register(Type tInterface, Type tImplementation, Lifestyle lifestyle = Lifestyle.Transient)
+ public IRegistrationBase Register(Type tInterface, Type tImplementation, Lifestyle lifestyle)
{
Type defaultRegistrationType = typeof(DefaultRegistration<>).MakeGenericType(tInterface);
return (IRegistrationBase)Activator.CreateInstance(defaultRegistrationType, tInterface, tImplementation, lifestyle);
@@ -72,9 +79,9 @@ namespace LightweightIocContainer.Registrations
/// The to register
/// The for this
/// A new created with the given parameters
- public static IRegistrationBase Register(Type tImplementation, Lifestyle lifestyle = Lifestyle.Transient)
+ public IRegistrationBase Register(Type tImplementation, Lifestyle lifestyle)
{
- if (tImplementation.IsInterface)
+ if (tImplementation.IsInterface) //TODO: handle `Instance` case when an instance is given
throw new InvalidRegistrationException("Can't register an interface without its implementation type.");
return Register(tImplementation, tImplementation, lifestyle);
@@ -87,7 +94,7 @@ namespace LightweightIocContainer.Registrations
/// The Type that implements the interface
/// The Type of the multiton scope
/// A new created with the given parameters
- public static IRegistrationBase Register(Type tInterface, Type tImplementation, Type tScope)
+ public IRegistrationBase Register(Type tInterface, Type tImplementation, Type tScope)
{
Type multitonRegistrationType = typeof(MultitonRegistration<>).MakeGenericType(tInterface);
return (IRegistrationBase)Activator.CreateInstance(multitonRegistrationType, tInterface, tImplementation, tScope);
@@ -97,23 +104,21 @@ namespace LightweightIocContainer.Registrations
/// Register an Interface as an abstract typed factory and create a
///
/// The abstract typed factory to register
- /// The current
/// A new created with the given parameters
- public static ITypedFactoryRegistration RegisterFactory(IIocContainer container) //TODO: Find a nicer way to inject the container into `TypedFactoryRegistration`
+ public ITypedFactoryRegistration RegisterFactory()
{
- return new TypedFactoryRegistration(typeof(TFactory), container);
+ return new TypedFactoryRegistration(typeof(TFactory), _iocContainer);
}
///
/// Register an Interface as an abstract typed factory and create a
///
/// The abstract typed factory to register
- /// The current
/// A new created with the given parameters
- public static IRegistrationBase RegisterFactory(Type tFactory, IIocContainer container)
+ public IRegistrationBase RegisterFactory(Type tFactory)
{
Type factoryRegistrationType = typeof(TypedFactoryRegistration<>).MakeGenericType(tFactory);
- return (IRegistrationBase)Activator.CreateInstance(factoryRegistrationType, tFactory, container);
+ return (IRegistrationBase)Activator.CreateInstance(factoryRegistrationType, tFactory, _iocContainer);
}
}
}
\ No newline at end of file
diff --git a/Test.LightweightIocContainer/AssemblyInstallerTest.cs b/Test.LightweightIocContainer/AssemblyInstallerTest.cs
index 4e183fc..30874e0 100644
--- a/Test.LightweightIocContainer/AssemblyInstallerTest.cs
+++ b/Test.LightweightIocContainer/AssemblyInstallerTest.cs
@@ -25,7 +25,7 @@ namespace Test.LightweightIocContainer
{
public void Install(IIocContainer container)
{
- container.Register(new Mock().Object);
+ container.Register>();
}
}
@@ -54,7 +54,7 @@ namespace Test.LightweightIocContainer
AssemblyInstaller assemblyInstaller = new AssemblyInstaller(assemblyMock.Object);
assemblyInstaller.Install(iocContainerMock.Object);
- iocContainerMock.Verify(ioc => ioc.Register(It.IsAny()), Times.Once);
+ iocContainerMock.Verify(ioc => ioc.Register>>(It.IsAny()), Times.Once);
}
[Test]
diff --git a/Test.LightweightIocContainer/DefaultRegistrationTest.cs b/Test.LightweightIocContainer/DefaultRegistrationTest.cs
index 2782158..70cb966 100644
--- a/Test.LightweightIocContainer/DefaultRegistrationTest.cs
+++ b/Test.LightweightIocContainer/DefaultRegistrationTest.cs
@@ -3,8 +3,11 @@
// Copyright(c) 2019 SimonG. All Rights Reserved.
using System;
+using LightweightIocContainer;
+using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Registrations;
using LightweightIocContainer.Registrations;
+using Moq;
using NUnit.Framework;
namespace Test.LightweightIocContainer
@@ -33,7 +36,8 @@ namespace Test.LightweightIocContainer
[Test]
public void TestOnCreate()
{
- IDefaultRegistration testRegistration = RegistrationFactory.Register().OnCreate(t => t.DoSomething());
+ RegistrationFactory registrationFactory = new RegistrationFactory(new Mock().Object);
+ IDefaultRegistration testRegistration = registrationFactory.Register(Lifestyle.Transient).OnCreate(t => t.DoSomething());
ITest test = new Test();
diff --git a/Test.LightweightIocContainer/IocContainerTest.cs b/Test.LightweightIocContainer/IocContainerTest.cs
index aaed517..d9d7340 100644
--- a/Test.LightweightIocContainer/IocContainerTest.cs
+++ b/Test.LightweightIocContainer/IocContainerTest.cs
@@ -3,7 +3,6 @@ using LightweightIocContainer;
using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Installers;
-using LightweightIocContainer.Registrations;
using Moq;
using NUnit.Framework;
@@ -116,52 +115,52 @@ namespace Test.LightweightIocContainer
[Test]
public void TestRegister()
{
- Assert.DoesNotThrow(() => _iocContainer.Register(RegistrationFactory.Register(typeof(ITest), typeof(Test))));
+ Assert.DoesNotThrow(() => _iocContainer.Register(typeof(ITest), typeof(Test)));
}
[Test]
public void TestRegisterTypeWithoutInterface()
{
- Assert.DoesNotThrow(() => _iocContainer.Register(RegistrationFactory.Register(typeof(Test))));
+ Assert.DoesNotThrow(() => _iocContainer.Register(typeof(Test)));
}
[Test]
public void TestRegisterMultiton()
{
- Assert.DoesNotThrow(() => _iocContainer.Register(RegistrationFactory.Register(typeof(ITest), typeof(Test), typeof(MultitonScope))));
+ Assert.DoesNotThrow(() => _iocContainer.Register(typeof(ITest), typeof(Test), typeof(MultitonScope)));
}
[Test]
public void TestRegisterFactory()
{
- Assert.DoesNotThrow(() => _iocContainer.Register(RegistrationFactory.RegisterFactory(typeof(ITestFactory), _iocContainer)));
+ Assert.DoesNotThrow(() => _iocContainer.RegisterFactory(typeof(ITestFactory)));
}
[Test]
public void TestRegisterMultiple()
{
- _iocContainer.Register(RegistrationFactory.Register());
- MultipleRegistrationException exception = Assert.Throws(() => _iocContainer.Register(RegistrationFactory.Register()));
+ _iocContainer.Register();
+ MultipleRegistrationException exception = Assert.Throws(() => _iocContainer.Register());
Assert.AreEqual(typeof(ITest), exception.Type);
}
[Test]
public void TestRegisterInterfaceWithoutImplementation()
{
- Assert.Throws(() => _iocContainer.Register(RegistrationFactory.Register()));
- Assert.Throws(() => _iocContainer.Register(RegistrationFactory.Register(typeof(ITest))));
+ Assert.Throws(() => _iocContainer.Register());
+ Assert.Throws(() => _iocContainer.Register(typeof(ITest)));
}
[Test]
public void TestRegisterFactoryWithoutCreate()
{
- Assert.Throws(() => _iocContainer.Register(RegistrationFactory.RegisterFactory(_iocContainer)));
+ Assert.Throws(() => _iocContainer.RegisterFactory());
}
[Test]
public void TestRegisterFactoryClearMultitonsNonGeneric()
{
- Assert.Throws(() => _iocContainer.Register(RegistrationFactory.RegisterFactory(_iocContainer)));
+ Assert.Throws(() => _iocContainer.RegisterFactory());
}
[Test]
@@ -174,7 +173,7 @@ namespace Test.LightweightIocContainer
[Test]
public void TestResolve()
{
- _iocContainer.Register(RegistrationFactory.Register());
+ _iocContainer.Register();
ITest resolvedTest = _iocContainer.Resolve();
@@ -184,7 +183,7 @@ namespace Test.LightweightIocContainer
[Test]
public void TestResolveWithoutInterface()
{
- _iocContainer.Register(RegistrationFactory.Register());
+ _iocContainer.Register();
Test resolvedTest = _iocContainer.Resolve();
@@ -194,7 +193,7 @@ namespace Test.LightweightIocContainer
[Test]
public void TestResolveWithParams()
{
- _iocContainer.Register(RegistrationFactory.Register());
+ _iocContainer.Register();
ITest resolvedTest = _iocContainer.Resolve("Test", new Test());
@@ -204,8 +203,8 @@ namespace Test.LightweightIocContainer
[Test]
public void TestResolveWithMissingParam()
{
- _iocContainer.Register(RegistrationFactory.Register());
- _iocContainer.Register(RegistrationFactory.Register()); //this registration is abnormal and should only be used in unit tests
+ _iocContainer.Register();
+ _iocContainer.Register(); //this registration is abnormal and should only be used in unit tests
ITest resolvedTest = _iocContainer.Resolve("Test");
@@ -215,7 +214,7 @@ namespace Test.LightweightIocContainer
[Test]
public void TestResolveReflection()
{
- _iocContainer.Register(RegistrationFactory.Register());
+ _iocContainer.Register();
object resolvedTest = _iocContainer.Resolve(typeof(ITest), null);
@@ -225,7 +224,7 @@ namespace Test.LightweightIocContainer
[Test]
public void TestResolveSingleton()
{
- _iocContainer.Register(RegistrationFactory.Register(Lifestyle.Singleton));
+ _iocContainer.Register(Lifestyle.Singleton);
ITest resolvedTest = _iocContainer.Resolve();
ITest secondResolvedTest = _iocContainer.Resolve();
@@ -236,7 +235,7 @@ namespace Test.LightweightIocContainer
[Test]
public void TestResolveMultiton()
{
- _iocContainer.Register(RegistrationFactory.Register());
+ _iocContainer.Register();
MultitonScope scope1 = new MultitonScope();
MultitonScope scope2 = new MultitonScope();
@@ -253,7 +252,7 @@ namespace Test.LightweightIocContainer
[Test]
public void TestResolveMultitonNoArgs()
{
- _iocContainer.Register(RegistrationFactory.Register());
+ _iocContainer.Register();
MultitonResolveException exception = Assert.Throws(() => _iocContainer.Resolve());
Assert.AreEqual(typeof(ITest), exception.Type);
@@ -262,7 +261,7 @@ namespace Test.LightweightIocContainer
[Test]
public void TestResolveMultitonWrongArgs()
{
- _iocContainer.Register(RegistrationFactory.Register());
+ _iocContainer.Register();
MultitonResolveException exception = Assert.Throws(() => _iocContainer.Resolve(new object()));
Assert.AreEqual(typeof(ITest), exception.Type);
@@ -271,7 +270,7 @@ namespace Test.LightweightIocContainer
[Test]
public void TestResolveTransient()
{
- _iocContainer.Register(RegistrationFactory.Register());
+ _iocContainer.Register();
ITest resolvedTest = _iocContainer.Resolve();
ITest secondResolvedTest = _iocContainer.Resolve();
@@ -282,8 +281,8 @@ namespace Test.LightweightIocContainer
[Test]
public void TestResolveFactory()
{
- _iocContainer.Register(RegistrationFactory.Register());
- _iocContainer.Register(RegistrationFactory.RegisterFactory(_iocContainer));
+ _iocContainer.Register();
+ _iocContainer.RegisterFactory();
ITestFactory testFactory = _iocContainer.Resolve();
@@ -293,8 +292,8 @@ namespace Test.LightweightIocContainer
[Test]
public void TestResolveFromFactory()
{
- _iocContainer.Register(RegistrationFactory.Register());
- _iocContainer.Register(RegistrationFactory.RegisterFactory(_iocContainer));
+ _iocContainer.Register();
+ _iocContainer.RegisterFactory();
ITestFactory testFactory = _iocContainer.Resolve();
ITest createdTest = testFactory.Create();
@@ -305,9 +304,9 @@ namespace Test.LightweightIocContainer
[Test]
public void TestResolveFromFactoryWithParams()
{
- _iocContainer.Register(RegistrationFactory.Register());
- _iocContainer.Register(RegistrationFactory.Register()); //this registration is abnormal and should only be used in unit tests
- _iocContainer.Register(RegistrationFactory.RegisterFactory(_iocContainer));
+ _iocContainer.Register();
+ _iocContainer.Register(); //this registration is abnormal and should only be used in unit tests
+ _iocContainer.RegisterFactory();
ITestFactory testFactory = _iocContainer.Resolve();
ITest createdTest = testFactory.Create("Test");
@@ -318,9 +317,9 @@ namespace Test.LightweightIocContainer
[Test]
public void TestResolveFromFactoryWithDefaultParamCreate()
{
- _iocContainer.Register(RegistrationFactory.Register());
- _iocContainer.Register(RegistrationFactory.Register()); //this registration is abnormal and should only be used in unit tests
- _iocContainer.Register(RegistrationFactory.RegisterFactory(_iocContainer));
+ _iocContainer.Register();
+ _iocContainer.Register(); //this registration is abnormal and should only be used in unit tests
+ _iocContainer.RegisterFactory();
ITestFactory testFactory = _iocContainer.Resolve();
ITest createdTest = testFactory.CreateTest();
@@ -331,9 +330,9 @@ namespace Test.LightweightIocContainer
[Test]
public void TestResolveFromFactoryWithDefaultParamCtor()
{
- _iocContainer.Register(RegistrationFactory.Register());
- _iocContainer.Register(RegistrationFactory.Register()); //this registration is abnormal and should only be used in unit tests
- _iocContainer.Register(RegistrationFactory.RegisterFactory(_iocContainer));
+ _iocContainer.Register();
+ _iocContainer.Register(); //this registration is abnormal and should only be used in unit tests
+ _iocContainer.RegisterFactory();
ITestFactory testFactory = _iocContainer.Resolve();
ITest createdTest = testFactory.Create();
@@ -344,8 +343,8 @@ namespace Test.LightweightIocContainer
[Test]
public void TestResolveMultitonFromFactory()
{
- _iocContainer.Register(RegistrationFactory.Register());
- _iocContainer.Register(RegistrationFactory.RegisterFactory(_iocContainer));
+ _iocContainer.Register();
+ _iocContainer.RegisterFactory();
MultitonScope scope1 = new MultitonScope();
MultitonScope scope2 = new MultitonScope();
@@ -364,8 +363,8 @@ namespace Test.LightweightIocContainer
[Test]
public void TestResolveMultitonFromFactoryClearInstances()
{
- _iocContainer.Register(RegistrationFactory.Register());
- _iocContainer.Register(RegistrationFactory.RegisterFactory(_iocContainer));
+ _iocContainer.Register();
+ _iocContainer.RegisterFactory();
MultitonScope scope1 = new MultitonScope();
MultitonScope scope2 = new MultitonScope();
@@ -395,10 +394,10 @@ namespace Test.LightweightIocContainer
{
Assert.False(_iocContainer.IsTypeRegistered());
- _iocContainer.Register(RegistrationFactory.Register());
+ _iocContainer.Register();
Assert.True(_iocContainer.IsTypeRegistered());
- _iocContainer.Register(RegistrationFactory.Register());
+ _iocContainer.Register();
Assert.True(_iocContainer.IsTypeRegistered());
}
}
diff --git a/Test.LightweightIocContainer/Test.LightweightIocContainer.csproj b/Test.LightweightIocContainer/Test.LightweightIocContainer.csproj
index c13eaed..a6a80e6 100644
--- a/Test.LightweightIocContainer/Test.LightweightIocContainer.csproj
+++ b/Test.LightweightIocContainer/Test.LightweightIocContainer.csproj
@@ -8,7 +8,7 @@
-
+