diff --git a/LightweightIocContainer/Exceptions/CircularDependencyException.cs b/LightweightIocContainer/Exceptions/CircularDependencyException.cs index 9047db7..1aa9678 100644 --- a/LightweightIocContainer/Exceptions/CircularDependencyException.cs +++ b/LightweightIocContainer/Exceptions/CircularDependencyException.cs @@ -6,17 +6,16 @@ using System; using System.Collections.Generic; using System.Linq; using System.Text; -using LightweightIocContainer.Interfaces; namespace LightweightIocContainer.Exceptions { /// - /// A circular dependency was detected during + /// A circular dependency was detected during /// internal class CircularDependencyException : IocContainerException { /// - /// A circular dependency was detected during + /// A circular dependency was detected during /// /// The currently resolving /// The resolve stack at the time the was thrown diff --git a/LightweightIocContainer/Factories/TypedFactory.cs b/LightweightIocContainer/Factories/TypedFactory.cs index c68cb23..022988c 100644 --- a/LightweightIocContainer/Factories/TypedFactory.cs +++ b/LightweightIocContainer/Factories/TypedFactory.cs @@ -96,7 +96,7 @@ namespace LightweightIocContainer.Factories generator.EmitCall(OpCodes.Call, emptyArray, null); } - generator.EmitCall(OpCodes.Callvirt, typeof(IIocContainer).GetMethod(nameof(IIocContainer.Resolve), new[] { typeof(object[]) })?.MakeGenericMethod(createMethod.ReturnType), null); + generator.EmitCall(OpCodes.Callvirt, typeof(IResolver).GetMethod(nameof(IResolver.Resolve), new[] { typeof(object[]) })?.MakeGenericMethod(createMethod.ReturnType), null); generator.Emit(OpCodes.Castclass, createMethod.ReturnType); generator.Emit(OpCodes.Ret); } diff --git a/LightweightIocContainer/Interfaces/IIocContainer.cs b/LightweightIocContainer/Interfaces/IIocContainer.cs index 141cdfb..e7fc31b 100644 --- a/LightweightIocContainer/Interfaces/IIocContainer.cs +++ b/LightweightIocContainer/Interfaces/IIocContainer.cs @@ -9,7 +9,7 @@ using LightweightIocContainer.Interfaces.Registrations; namespace LightweightIocContainer.Interfaces { /// - /// The main container that carries all the s and can resolve all the types you'll ever want + /// The main container that carries all s /// public interface IIocContainer : IDisposable { @@ -111,21 +111,6 @@ namespace LightweightIocContainer.Interfaces /// The created IMultipleMultitonRegistration RegisterMultiton() where TImplementation : TInterface1, TInterface2; - /// - /// Gets an instance of the given - /// - /// The given - /// An instance of the given - T Resolve(); - - /// - /// Gets an instance of the given - /// - /// The given - /// The constructor arguments - /// An instance of the given - T Resolve(params object[] arguments); - /// /// Clear the multiton instances of the given from the registered multitons list /// diff --git a/LightweightIocContainer/Interfaces/IResolver.cs b/LightweightIocContainer/Interfaces/IResolver.cs new file mode 100644 index 0000000..bdc3ed6 --- /dev/null +++ b/LightweightIocContainer/Interfaces/IResolver.cs @@ -0,0 +1,29 @@ +// Author: Gockner, Simon +// Created: 2021-12-06 +// Copyright(c) 2021 SimonG. All Rights Reserved. + +using System; + +namespace LightweightIocContainer.Interfaces +{ + /// + /// Provides methods + /// + public interface IResolver + { + /// + /// Gets an instance of the given + /// + /// The given + /// An instance of the given + T Resolve(); + + /// + /// Gets an instance of the given + /// + /// The given + /// The constructor arguments + /// An instance of the given + T Resolve(params object[] arguments); + } +} \ No newline at end of file diff --git a/LightweightIocContainer/Interfaces/Registrations/Fluent/IWithParameters.cs b/LightweightIocContainer/Interfaces/Registrations/Fluent/IWithParameters.cs index 7330932..7e56a87 100644 --- a/LightweightIocContainer/Interfaces/Registrations/Fluent/IWithParameters.cs +++ b/LightweightIocContainer/Interfaces/Registrations/Fluent/IWithParameters.cs @@ -14,7 +14,7 @@ namespace LightweightIocContainer.Interfaces.Registrations.Fluent public interface IWithParameters { /// - /// Pass parameters that will be used to an instance of this + /// Pass parameters that will be used to an instance of this /// Parameters set with this method are always inserted at the beginning of the argument list if more parameters are given when resolving /// /// The parameters @@ -23,7 +23,7 @@ namespace LightweightIocContainer.Interfaces.Registrations.Fluent IRegistrationBase WithParameters(params object[] parameters); /// - /// Pass parameters that will be used to an instance of this + /// Pass parameters that will be used to an instance of this /// Parameters set with this method are inserted at the position in the argument list that is passed with the parameter if more parameters are given when resolving /// /// The parameters with their position @@ -35,7 +35,7 @@ namespace LightweightIocContainer.Interfaces.Registrations.Fluent internal interface IWithParametersInternal : IWithParameters { /// - /// An of parameters that are used to an instance of this + /// An of parameters that are used to an instance of this /// Can be set in the by calling /// object[] Parameters { get; } diff --git a/LightweightIocContainer/Interfaces/Registrations/ISingleTypeRegistration.cs b/LightweightIocContainer/Interfaces/Registrations/ISingleTypeRegistration.cs index c0818dd..0fece0d 100644 --- a/LightweightIocContainer/Interfaces/Registrations/ISingleTypeRegistration.cs +++ b/LightweightIocContainer/Interfaces/Registrations/ISingleTypeRegistration.cs @@ -15,13 +15,13 @@ namespace LightweightIocContainer.Interfaces.Registrations /// /// that is invoked instead of creating an instance of this the default way /// - Func FactoryMethod { get; } + Func FactoryMethod { get; } /// /// Pass a that will be invoked instead of creating an instance of this the default way /// /// The /// The current instance of this - ISingleTypeRegistration WithFactoryMethod(Func factoryMethod); + ISingleTypeRegistration WithFactoryMethod(Func factoryMethod); } } \ No newline at end of file diff --git a/LightweightIocContainer/IocContainer.cs b/LightweightIocContainer/IocContainer.cs index 892467f..6bcc437 100644 --- a/LightweightIocContainer/IocContainer.cs +++ b/LightweightIocContainer/IocContainer.cs @@ -21,7 +21,7 @@ namespace LightweightIocContainer /// /// The main container that carries all the s and can resolve all the types you'll ever want /// - public class IocContainer : IIocContainer + public class IocContainer : IIocContainer, IResolver { private readonly RegistrationFactory _registrationFactory; diff --git a/LightweightIocContainer/LightweightIocContainer.xml b/LightweightIocContainer/LightweightIocContainer.xml index b609eed..7be92cf 100644 --- a/LightweightIocContainer/LightweightIocContainer.xml +++ b/LightweightIocContainer/LightweightIocContainer.xml @@ -44,12 +44,12 @@ - A circular dependency was detected during + A circular dependency was detected during - A circular dependency was detected during + A circular dependency was detected during The currently resolving The resolve stack at the time the was thrown @@ -394,7 +394,7 @@ - The main container that carries all the s and can resolve all the types you'll ever want + The main container that carries all s @@ -495,21 +495,6 @@ The Type of the multiton scope The created - - - Gets an instance of the given - - The given - An instance of the given - - - - Gets an instance of the given - - The given - The constructor arguments - An instance of the given - Clear the multiton instances of the given from the registered multitons list @@ -544,6 +529,26 @@ The current + + + Provides methods + + + + + Gets an instance of the given + + The given + An instance of the given + + + + Gets an instance of the given + + The given + The constructor arguments + An instance of the given + Provides an to the generic @@ -601,7 +606,7 @@ - Pass parameters that will be used to an instance of this + Pass parameters that will be used to an instance of this Parameters set with this method are always inserted at the beginning of the argument list if more parameters are given when resolving The parameters @@ -610,7 +615,7 @@ - Pass parameters that will be used to an instance of this + Pass parameters that will be used to an instance of this Parameters set with this method are inserted at the position in the argument list that is passed with the parameter if more parameters are given when resolving The parameters with their position @@ -619,7 +624,7 @@ - An of parameters that are used to an instance of this + An of parameters that are used to an instance of this Can be set in the by calling @@ -739,7 +744,7 @@ that is invoked instead of creating an instance of this the default way - + Pass a that will be invoked instead of creating an instance of this the default way @@ -1247,7 +1252,7 @@ The of the Interface The of the registration - The current instance of the + The current instance of the @@ -1261,7 +1266,7 @@ - An of parameters that are used to an instance of this + An of parameters that are used to an instance of this Can be set in the by calling @@ -1272,7 +1277,7 @@ - Pass parameters that will be used to an instance of this + Pass parameters that will be used to an instance of this Parameters set with this method are always inserted at the beginning of the argument list if more parameters are given when resolving The parameters @@ -1281,7 +1286,7 @@ - Pass parameters that will be used to an instance of this + Pass parameters that will be used to an instance of this Parameters set with this method are inserted at the position in the argument list that is passed with the parameter if more parameters are given when resolving The parameters with their position @@ -1425,7 +1430,7 @@ that is invoked instead of creating an instance of this the default way - + Pass a that will be invoked instead of creating an instance of this the default way diff --git a/LightweightIocContainer/Registrations/RegistrationBase.cs b/LightweightIocContainer/Registrations/RegistrationBase.cs index 2bc1e07..a57a28b 100644 --- a/LightweightIocContainer/Registrations/RegistrationBase.cs +++ b/LightweightIocContainer/Registrations/RegistrationBase.cs @@ -6,7 +6,6 @@ using System; using System.Linq; using LightweightIocContainer.Exceptions; using LightweightIocContainer.Factories; -using LightweightIocContainer.Interfaces; using LightweightIocContainer.Interfaces.Factories; using LightweightIocContainer.Interfaces.Installers; using LightweightIocContainer.Interfaces.Registrations; @@ -26,7 +25,7 @@ namespace LightweightIocContainer.Registrations /// /// The of the Interface /// The of the registration - /// The current instance of the + /// The current instance of the protected RegistrationBase(Type interfaceType, Lifestyle lifestyle, IocContainer container) { InterfaceType = interfaceType; @@ -45,7 +44,7 @@ namespace LightweightIocContainer.Registrations public Lifestyle Lifestyle { get; } /// - /// An of parameters that are used to an instance of this + /// An of parameters that are used to an instance of this /// Can be set in the by calling /// public object[] Parameters { get; private set; } @@ -56,7 +55,7 @@ namespace LightweightIocContainer.Registrations public ITypedFactory Factory { get; private set; } /// - /// Pass parameters that will be used to an instance of this + /// Pass parameters that will be used to an instance of this /// Parameters set with this method are always inserted at the beginning of the argument list if more parameters are given when resolving /// /// The parameters @@ -75,7 +74,7 @@ namespace LightweightIocContainer.Registrations } /// - /// Pass parameters that will be used to an instance of this + /// Pass parameters that will be used to an instance of this /// Parameters set with this method are inserted at the position in the argument list that is passed with the parameter if more parameters are given when resolving /// /// The parameters with their position diff --git a/LightweightIocContainer/Registrations/SingleTypeRegistration.cs b/LightweightIocContainer/Registrations/SingleTypeRegistration.cs index a01e785..8ce618a 100644 --- a/LightweightIocContainer/Registrations/SingleTypeRegistration.cs +++ b/LightweightIocContainer/Registrations/SingleTypeRegistration.cs @@ -29,14 +29,14 @@ namespace LightweightIocContainer.Registrations /// /// that is invoked instead of creating an instance of this the default way /// - public Func FactoryMethod { get; private set; } + public Func FactoryMethod { get; private set; } /// /// Pass a that will be invoked instead of creating an instance of this the default way /// /// The /// The current instance of this - public ISingleTypeRegistration WithFactoryMethod(Func factoryMethod) + public ISingleTypeRegistration WithFactoryMethod(Func factoryMethod) { FactoryMethod = factoryMethod; return this; diff --git a/Test.LightweightIocContainer/FluentFactoryRegistrationTest.cs b/Test.LightweightIocContainer/FluentFactoryRegistrationTest.cs index b6236af..d9b6733 100644 --- a/Test.LightweightIocContainer/FluentFactoryRegistrationTest.cs +++ b/Test.LightweightIocContainer/FluentFactoryRegistrationTest.cs @@ -5,7 +5,6 @@ using JetBrains.Annotations; using LightweightIocContainer; using LightweightIocContainer.Exceptions; -using LightweightIocContainer.Interfaces; using NUnit.Framework; namespace Test.LightweightIocContainer @@ -84,7 +83,7 @@ namespace Test.LightweightIocContainer } - private IIocContainer _iocContainer; + private IocContainer _iocContainer; [SetUp] public void SetUp() => _iocContainer = new IocContainer(); diff --git a/Test.LightweightIocContainer/IocContainerInterfaceSegregationTest.cs b/Test.LightweightIocContainer/IocContainerInterfaceSegregationTest.cs index 492606a..e93056a 100644 --- a/Test.LightweightIocContainer/IocContainerInterfaceSegregationTest.cs +++ b/Test.LightweightIocContainer/IocContainerInterfaceSegregationTest.cs @@ -5,7 +5,6 @@ using System; using JetBrains.Annotations; using LightweightIocContainer; -using LightweightIocContainer.Interfaces; using NUnit.Framework; namespace Test.LightweightIocContainer @@ -44,7 +43,7 @@ namespace Test.LightweightIocContainer } - private IIocContainer _container; + private IocContainer _container; [SetUp] public void SetUp() => _container = new IocContainer(); diff --git a/Test.LightweightIocContainer/IocContainerParameterRegistrationTest.cs b/Test.LightweightIocContainer/IocContainerParameterRegistrationTest.cs index 88b700c..b3c6bee 100644 --- a/Test.LightweightIocContainer/IocContainerParameterRegistrationTest.cs +++ b/Test.LightweightIocContainer/IocContainerParameterRegistrationTest.cs @@ -4,7 +4,6 @@ using JetBrains.Annotations; using LightweightIocContainer; -using LightweightIocContainer.Interfaces; using NUnit.Framework; namespace Test.LightweightIocContainer @@ -87,7 +86,7 @@ namespace Test.LightweightIocContainer } - private IIocContainer _iocContainer; + private IocContainer _iocContainer; [SetUp] public void SetUp() => _iocContainer = new IocContainer(); diff --git a/Test.LightweightIocContainer/IocContainerRecursionTest.cs b/Test.LightweightIocContainer/IocContainerRecursionTest.cs index 5a5ba61..0f10744 100644 --- a/Test.LightweightIocContainer/IocContainerRecursionTest.cs +++ b/Test.LightweightIocContainer/IocContainerRecursionTest.cs @@ -5,7 +5,6 @@ using JetBrains.Annotations; using LightweightIocContainer; using LightweightIocContainer.Exceptions; -using LightweightIocContainer.Interfaces; using Moq; using NUnit.Framework; @@ -85,7 +84,7 @@ namespace Test.LightweightIocContainer } - private IIocContainer _iocContainer; + private IocContainer _iocContainer; [SetUp] public void SetUp() => _iocContainer = new IocContainer(); diff --git a/Test.LightweightIocContainer/IocContainerTest.cs b/Test.LightweightIocContainer/IocContainerTest.cs index d895855..517b7a7 100644 --- a/Test.LightweightIocContainer/IocContainerTest.cs +++ b/Test.LightweightIocContainer/IocContainerTest.cs @@ -80,7 +80,7 @@ namespace Test.LightweightIocContainer } - private IIocContainer _iocContainer; + private IocContainer _iocContainer; [SetUp] public void SetUp() => _iocContainer = new IocContainer(); diff --git a/Test.LightweightIocContainer/MultipleMultitonRegistrationTest.cs b/Test.LightweightIocContainer/MultipleMultitonRegistrationTest.cs index 86b4d56..5328fee 100644 --- a/Test.LightweightIocContainer/MultipleMultitonRegistrationTest.cs +++ b/Test.LightweightIocContainer/MultipleMultitonRegistrationTest.cs @@ -4,7 +4,6 @@ using JetBrains.Annotations; using LightweightIocContainer; -using LightweightIocContainer.Interfaces; using NUnit.Framework; namespace Test.LightweightIocContainer @@ -12,7 +11,7 @@ namespace Test.LightweightIocContainer [TestFixture] public class MultipleMultitonRegistrationTest { - private IIocContainer _iocContainer; + private IocContainer _iocContainer; [UsedImplicitly] public interface ITest : IProvider diff --git a/Test.LightweightIocContainer/OpenGenericRegistrationTest.cs b/Test.LightweightIocContainer/OpenGenericRegistrationTest.cs index 84d6b74..50425c1 100644 --- a/Test.LightweightIocContainer/OpenGenericRegistrationTest.cs +++ b/Test.LightweightIocContainer/OpenGenericRegistrationTest.cs @@ -6,7 +6,6 @@ using System.Diagnostics.CodeAnalysis; using JetBrains.Annotations; using LightweightIocContainer; using LightweightIocContainer.Exceptions; -using LightweightIocContainer.Interfaces; using NUnit.Framework; namespace Test.LightweightIocContainer @@ -14,7 +13,7 @@ namespace Test.LightweightIocContainer [TestFixture] public class OpenGenericRegistrationTest { - private IIocContainer _iocContainer; + private IocContainer _iocContainer; [UsedImplicitly] [SuppressMessage("ReSharper", "UnusedTypeParameter")] diff --git a/Test.LightweightIocContainer/SingleTypeRegistrationTest.cs b/Test.LightweightIocContainer/SingleTypeRegistrationTest.cs index 907a17f..2acc5bc 100644 --- a/Test.LightweightIocContainer/SingleTypeRegistrationTest.cs +++ b/Test.LightweightIocContainer/SingleTypeRegistrationTest.cs @@ -4,7 +4,6 @@ using JetBrains.Annotations; using LightweightIocContainer; -using LightweightIocContainer.Interfaces; using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Registrations; using Moq; @@ -58,7 +57,7 @@ namespace Test.LightweightIocContainer [Test] public void TestSingleTypeRegistrationResolveSingleton() { - IIocContainer container = new IocContainer(); + IocContainer container = new IocContainer(); IBar bar = new Bar(); container.Register(Lifestyle.Singleton).WithFactoryMethod(_ => new Foo(bar));