- extract resolve to IResolver interface

pull/57/head
Simon G 4 years ago
parent 4ab55e8bfc
commit 8e2c45a5cf
  1. 5
      LightweightIocContainer/Exceptions/CircularDependencyException.cs
  2. 2
      LightweightIocContainer/Factories/TypedFactory.cs
  3. 17
      LightweightIocContainer/Interfaces/IIocContainer.cs
  4. 29
      LightweightIocContainer/Interfaces/IResolver.cs
  5. 6
      LightweightIocContainer/Interfaces/Registrations/Fluent/IWithParameters.cs
  6. 4
      LightweightIocContainer/Interfaces/Registrations/ISingleTypeRegistration.cs
  7. 2
      LightweightIocContainer/IocContainer.cs
  8. 59
      LightweightIocContainer/LightweightIocContainer.xml
  9. 9
      LightweightIocContainer/Registrations/RegistrationBase.cs
  10. 4
      LightweightIocContainer/Registrations/SingleTypeRegistration.cs
  11. 3
      Test.LightweightIocContainer/FluentFactoryRegistrationTest.cs
  12. 3
      Test.LightweightIocContainer/IocContainerInterfaceSegregationTest.cs
  13. 3
      Test.LightweightIocContainer/IocContainerParameterRegistrationTest.cs
  14. 3
      Test.LightweightIocContainer/IocContainerRecursionTest.cs
  15. 2
      Test.LightweightIocContainer/IocContainerTest.cs
  16. 3
      Test.LightweightIocContainer/MultipleMultitonRegistrationTest.cs
  17. 3
      Test.LightweightIocContainer/OpenGenericRegistrationTest.cs
  18. 3
      Test.LightweightIocContainer/SingleTypeRegistrationTest.cs

@ -6,17 +6,16 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using LightweightIocContainer.Interfaces;
namespace LightweightIocContainer.Exceptions namespace LightweightIocContainer.Exceptions
{ {
/// <summary> /// <summary>
/// A circular dependency was detected during <see cref="IIocContainer.Resolve{T}()"/> /// A circular dependency was detected during <see cref="IocContainer.Resolve{T}()"/>
/// </summary> /// </summary>
internal class CircularDependencyException : IocContainerException internal class CircularDependencyException : IocContainerException
{ {
/// <summary> /// <summary>
/// A circular dependency was detected during <see cref="IIocContainer.Resolve{T}()"/> /// A circular dependency was detected during <see cref="IocContainer.Resolve{T}()"/>
/// </summary> /// </summary>
/// <param name="resolvingType">The currently resolving <see cref="Type"/></param> /// <param name="resolvingType">The currently resolving <see cref="Type"/></param>
/// <param name="resolveStack">The resolve stack at the time the <see cref="CircularDependencyException"/> was thrown</param> /// <param name="resolveStack">The resolve stack at the time the <see cref="CircularDependencyException"/> was thrown</param>

@ -96,7 +96,7 @@ namespace LightweightIocContainer.Factories
generator.EmitCall(OpCodes.Call, emptyArray, null); 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.Castclass, createMethod.ReturnType);
generator.Emit(OpCodes.Ret); generator.Emit(OpCodes.Ret);
} }

@ -9,7 +9,7 @@ using LightweightIocContainer.Interfaces.Registrations;
namespace LightweightIocContainer.Interfaces namespace LightweightIocContainer.Interfaces
{ {
/// <summary> /// <summary>
/// The main container that carries all the <see cref="IRegistration"/>s and can resolve all the types you'll ever want /// The main container that carries all <see cref="IRegistration"/>s
/// </summary> /// </summary>
public interface IIocContainer : IDisposable public interface IIocContainer : IDisposable
{ {
@ -111,21 +111,6 @@ namespace LightweightIocContainer.Interfaces
/// <returns>The created <see cref="IRegistration"/></returns> /// <returns>The created <see cref="IRegistration"/></returns>
IMultipleMultitonRegistration<TInterface1, TInterface2, TImplementation> RegisterMultiton<TInterface1, TInterface2, TImplementation, TScope>() where TImplementation : TInterface1, TInterface2; IMultipleMultitonRegistration<TInterface1, TInterface2, TImplementation> RegisterMultiton<TInterface1, TInterface2, TImplementation, TScope>() where TImplementation : TInterface1, TInterface2;
/// <summary>
/// Gets an instance of the given <see cref="Type"/>
/// </summary>
/// <typeparam name="T">The given <see cref="Type"/></typeparam>
/// <returns>An instance of the given <see cref="Type"/></returns>
T Resolve<T>();
/// <summary>
/// Gets an instance of the given <see cref="Type"/>
/// </summary>
/// <typeparam name="T">The given <see cref="Type"/></typeparam>
/// <param name="arguments">The constructor arguments</param>
/// <returns>An instance of the given <see cref="Type"/></returns>
T Resolve<T>(params object[] arguments);
/// <summary> /// <summary>
/// Clear the multiton instances of the given <see cref="Type"/> from the registered multitons list /// Clear the multiton instances of the given <see cref="Type"/> from the registered multitons list
/// </summary> /// </summary>

@ -0,0 +1,29 @@
// Author: Gockner, Simon
// Created: 2021-12-06
// Copyright(c) 2021 SimonG. All Rights Reserved.
using System;
namespace LightweightIocContainer.Interfaces
{
/// <summary>
/// Provides <see cref="Resolve{T}()"/> methods
/// </summary>
public interface IResolver
{
/// <summary>
/// Gets an instance of the given <see cref="Type"/>
/// </summary>
/// <typeparam name="T">The given <see cref="Type"/></typeparam>
/// <returns>An instance of the given <see cref="Type"/></returns>
T Resolve<T>();
/// <summary>
/// Gets an instance of the given <see cref="Type"/>
/// </summary>
/// <typeparam name="T">The given <see cref="Type"/></typeparam>
/// <param name="arguments">The constructor arguments</param>
/// <returns>An instance of the given <see cref="Type"/></returns>
T Resolve<T>(params object[] arguments);
}
}

@ -14,7 +14,7 @@ namespace LightweightIocContainer.Interfaces.Registrations.Fluent
public interface IWithParameters public interface IWithParameters
{ {
/// <summary> /// <summary>
/// Pass parameters that will be used to<see cref="IIocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/> /// Pass parameters that will be used to<see cref="IocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/>
/// <para>Parameters set with this method are always inserted at the beginning of the argument list if more parameters are given when resolving</para> /// <para>Parameters set with this method are always inserted at the beginning of the argument list if more parameters are given when resolving</para>
/// </summary> /// </summary>
/// <param name="parameters">The parameters</param> /// <param name="parameters">The parameters</param>
@ -23,7 +23,7 @@ namespace LightweightIocContainer.Interfaces.Registrations.Fluent
IRegistrationBase WithParameters(params object[] parameters); IRegistrationBase WithParameters(params object[] parameters);
/// <summary> /// <summary>
/// Pass parameters that will be used to<see cref="IIocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/> /// Pass parameters that will be used to<see cref="IocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/>
/// <para>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</para> /// <para>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</para>
/// </summary> /// </summary>
/// <param name="parameters">The parameters with their position</param> /// <param name="parameters">The parameters with their position</param>
@ -35,7 +35,7 @@ namespace LightweightIocContainer.Interfaces.Registrations.Fluent
internal interface IWithParametersInternal : IWithParameters internal interface IWithParametersInternal : IWithParameters
{ {
/// <summary> /// <summary>
/// An <see cref="Array"/> of parameters that are used to <see cref="IIocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/> /// An <see cref="Array"/> of parameters that are used to <see cref="IocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/>
/// <para>Can be set in the <see cref="IIocInstaller"/> by calling <see cref="IWithParameters.WithParameters(object[])"/></para> /// <para>Can be set in the <see cref="IIocInstaller"/> by calling <see cref="IWithParameters.WithParameters(object[])"/></para>
/// </summary> /// </summary>
object[] Parameters { get; } object[] Parameters { get; }

@ -15,13 +15,13 @@ namespace LightweightIocContainer.Interfaces.Registrations
/// <summary> /// <summary>
/// <see cref="Func{T,TResult}"/> that is invoked instead of creating an instance of this <see cref="Type"/> the default way /// <see cref="Func{T,TResult}"/> that is invoked instead of creating an instance of this <see cref="Type"/> the default way
/// </summary> /// </summary>
Func<IIocContainer, T> FactoryMethod { get; } Func<IResolver, T> FactoryMethod { get; }
/// <summary> /// <summary>
/// Pass a <see cref="Func{T,TResult}"/> that will be invoked instead of creating an instance of this <see cref="Type"/> the default way /// Pass a <see cref="Func{T,TResult}"/> that will be invoked instead of creating an instance of this <see cref="Type"/> the default way
/// </summary> /// </summary>
/// <param name="factoryMethod">The <see cref="Func{T,TResult}"/></param> /// <param name="factoryMethod">The <see cref="Func{T,TResult}"/></param>
/// <returns>The current instance of this <see cref="IRegistration"/></returns> /// <returns>The current instance of this <see cref="IRegistration"/></returns>
ISingleTypeRegistration<T> WithFactoryMethod(Func<IIocContainer, T> factoryMethod); ISingleTypeRegistration<T> WithFactoryMethod(Func<IResolver, T> factoryMethod);
} }
} }

@ -21,7 +21,7 @@ namespace LightweightIocContainer
/// <summary> /// <summary>
/// The main container that carries all the <see cref="IRegistration"/>s and can resolve all the types you'll ever want /// The main container that carries all the <see cref="IRegistration"/>s and can resolve all the types you'll ever want
/// </summary> /// </summary>
public class IocContainer : IIocContainer public class IocContainer : IIocContainer, IResolver
{ {
private readonly RegistrationFactory _registrationFactory; private readonly RegistrationFactory _registrationFactory;

@ -44,12 +44,12 @@
</member> </member>
<member name="T:LightweightIocContainer.Exceptions.CircularDependencyException"> <member name="T:LightweightIocContainer.Exceptions.CircularDependencyException">
<summary> <summary>
A circular dependency was detected during <see cref="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1"/> A circular dependency was detected during <see cref="M:LightweightIocContainer.IocContainer.Resolve``1"/>
</summary> </summary>
</member> </member>
<member name="M:LightweightIocContainer.Exceptions.CircularDependencyException.#ctor(System.Type,System.Collections.Generic.List{System.Type})"> <member name="M:LightweightIocContainer.Exceptions.CircularDependencyException.#ctor(System.Type,System.Collections.Generic.List{System.Type})">
<summary> <summary>
A circular dependency was detected during <see cref="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1"/> A circular dependency was detected during <see cref="M:LightweightIocContainer.IocContainer.Resolve``1"/>
</summary> </summary>
<param name="resolvingType">The currently resolving <see cref="T:System.Type"/></param> <param name="resolvingType">The currently resolving <see cref="T:System.Type"/></param>
<param name="resolveStack">The resolve stack at the time the <see cref="T:LightweightIocContainer.Exceptions.CircularDependencyException"/> was thrown</param> <param name="resolveStack">The resolve stack at the time the <see cref="T:LightweightIocContainer.Exceptions.CircularDependencyException"/> was thrown</param>
@ -394,7 +394,7 @@
</member> </member>
<member name="T:LightweightIocContainer.Interfaces.IIocContainer"> <member name="T:LightweightIocContainer.Interfaces.IIocContainer">
<summary> <summary>
The main container that carries all the <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/>s and can resolve all the types you'll ever want The main container that carries all <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/>s
</summary> </summary>
</member> </member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.Install(LightweightIocContainer.Interfaces.Installers.IIocInstaller[])"> <member name="M:LightweightIocContainer.Interfaces.IIocContainer.Install(LightweightIocContainer.Interfaces.Installers.IIocInstaller[])">
@ -495,21 +495,6 @@
<typeparam name="TScope">The Type of the multiton scope</typeparam> <typeparam name="TScope">The Type of the multiton scope</typeparam>
<returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns> <returns>The created <see cref="T:LightweightIocContainer.Interfaces.Registrations.IRegistration"/></returns>
</member> </member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1">
<summary>
Gets an instance of the given <see cref="T:System.Type"/>
</summary>
<typeparam name="T">The given <see cref="T:System.Type"/></typeparam>
<returns>An instance of the given <see cref="T:System.Type"/></returns>
</member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1(System.Object[])">
<summary>
Gets an instance of the given <see cref="T:System.Type"/>
</summary>
<typeparam name="T">The given <see cref="T:System.Type"/></typeparam>
<param name="arguments">The constructor arguments</param>
<returns>An instance of the given <see cref="T:System.Type"/></returns>
</member>
<member name="M:LightweightIocContainer.Interfaces.IIocContainer.ClearMultitonInstances``1"> <member name="M:LightweightIocContainer.Interfaces.IIocContainer.ClearMultitonInstances``1">
<summary> <summary>
Clear the multiton instances of the given <see cref="T:System.Type"/> from the registered multitons list Clear the multiton instances of the given <see cref="T:System.Type"/> from the registered multitons list
@ -544,6 +529,26 @@
</summary> </summary>
<param name="container">The current <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param> <param name="container">The current <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param>
</member> </member>
<member name="T:LightweightIocContainer.Interfaces.IResolver">
<summary>
Provides <see cref="M:LightweightIocContainer.Interfaces.IResolver.Resolve``1"/> methods
</summary>
</member>
<member name="M:LightweightIocContainer.Interfaces.IResolver.Resolve``1">
<summary>
Gets an instance of the given <see cref="T:System.Type"/>
</summary>
<typeparam name="T">The given <see cref="T:System.Type"/></typeparam>
<returns>An instance of the given <see cref="T:System.Type"/></returns>
</member>
<member name="M:LightweightIocContainer.Interfaces.IResolver.Resolve``1(System.Object[])">
<summary>
Gets an instance of the given <see cref="T:System.Type"/>
</summary>
<typeparam name="T">The given <see cref="T:System.Type"/></typeparam>
<param name="arguments">The constructor arguments</param>
<returns>An instance of the given <see cref="T:System.Type"/></returns>
</member>
<member name="T:LightweightIocContainer.Interfaces.Registrations.Fluent.IOnCreate"> <member name="T:LightweightIocContainer.Interfaces.Registrations.Fluent.IOnCreate">
<summary> <summary>
Provides an <see cref="P:LightweightIocContainer.Interfaces.Registrations.Fluent.IOnCreate.OnCreateAction"/> to the generic <see cref="T:LightweightIocContainer.Interfaces.Registrations.Fluent.IOnCreate`2"/> Provides an <see cref="P:LightweightIocContainer.Interfaces.Registrations.Fluent.IOnCreate.OnCreateAction"/> to the generic <see cref="T:LightweightIocContainer.Interfaces.Registrations.Fluent.IOnCreate`2"/>
@ -601,7 +606,7 @@
</member> </member>
<member name="M:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithParameters.WithParameters(System.Object[])"> <member name="M:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithParameters.WithParameters(System.Object[])">
<summary> <summary>
Pass parameters that will be used to<see cref="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/> Pass parameters that will be used to<see cref="M:LightweightIocContainer.IocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/>
<para>Parameters set with this method are always inserted at the beginning of the argument list if more parameters are given when resolving</para> <para>Parameters set with this method are always inserted at the beginning of the argument list if more parameters are given when resolving</para>
</summary> </summary>
<param name="parameters">The parameters</param> <param name="parameters">The parameters</param>
@ -610,7 +615,7 @@
</member> </member>
<member name="M:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithParameters.WithParameters(System.ValueTuple{System.Int32,System.Object}[])"> <member name="M:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithParameters.WithParameters(System.ValueTuple{System.Int32,System.Object}[])">
<summary> <summary>
Pass parameters that will be used to<see cref="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/> Pass parameters that will be used to<see cref="M:LightweightIocContainer.IocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/>
<para>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</para> <para>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</para>
</summary> </summary>
<param name="parameters">The parameters with their position</param> <param name="parameters">The parameters with their position</param>
@ -619,7 +624,7 @@
</member> </member>
<member name="P:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithParametersInternal.Parameters"> <member name="P:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithParametersInternal.Parameters">
<summary> <summary>
An <see cref="T:System.Array"/> of parameters that are used to <see cref="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/> An <see cref="T:System.Array"/> of parameters that are used to <see cref="M:LightweightIocContainer.IocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/>
<para>Can be set in the <see cref="T:LightweightIocContainer.Interfaces.Installers.IIocInstaller"/> by calling <see cref="M:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithParameters.WithParameters(System.Object[])"/></para> <para>Can be set in the <see cref="T:LightweightIocContainer.Interfaces.Installers.IIocInstaller"/> by calling <see cref="M:LightweightIocContainer.Interfaces.Registrations.Fluent.IWithParameters.WithParameters(System.Object[])"/></para>
</summary> </summary>
</member> </member>
@ -739,7 +744,7 @@
<see cref="T:System.Func`2"/> that is invoked instead of creating an instance of this <see cref="T:System.Type"/> the default way <see cref="T:System.Func`2"/> that is invoked instead of creating an instance of this <see cref="T:System.Type"/> the default way
</summary> </summary>
</member> </member>
<member name="M:LightweightIocContainer.Interfaces.Registrations.ISingleTypeRegistration`1.WithFactoryMethod(System.Func{LightweightIocContainer.Interfaces.IIocContainer,`0})"> <member name="M:LightweightIocContainer.Interfaces.Registrations.ISingleTypeRegistration`1.WithFactoryMethod(System.Func{LightweightIocContainer.Interfaces.IResolver,`0})">
<summary> <summary>
Pass a <see cref="T:System.Func`2"/> that will be invoked instead of creating an instance of this <see cref="T:System.Type"/> the default way Pass a <see cref="T:System.Func`2"/> that will be invoked instead of creating an instance of this <see cref="T:System.Type"/> the default way
</summary> </summary>
@ -1247,7 +1252,7 @@
</summary> </summary>
<param name="interfaceType">The <see cref="T:System.Type"/> of the Interface</param> <param name="interfaceType">The <see cref="T:System.Type"/> of the Interface</param>
<param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of the registration</param> <param name="lifestyle">The <see cref="T:LightweightIocContainer.Lifestyle"/> of the registration</param>
<param name="container">The current instance of the <see cref="T:LightweightIocContainer.Interfaces.IIocContainer"/></param> <param name="container">The current instance of the <see cref="T:LightweightIocContainer.IocContainer"/></param>
</member> </member>
<member name="P:LightweightIocContainer.Registrations.RegistrationBase.InterfaceType"> <member name="P:LightweightIocContainer.Registrations.RegistrationBase.InterfaceType">
<summary> <summary>
@ -1261,7 +1266,7 @@
</member> </member>
<member name="P:LightweightIocContainer.Registrations.RegistrationBase.Parameters"> <member name="P:LightweightIocContainer.Registrations.RegistrationBase.Parameters">
<summary> <summary>
An <see cref="T:System.Array"/> of parameters that are used to <see cref="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/> An <see cref="T:System.Array"/> of parameters that are used to <see cref="M:LightweightIocContainer.IocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/>
<para>Can be set in the <see cref="T:LightweightIocContainer.Interfaces.Installers.IIocInstaller"/> by calling <see cref="M:LightweightIocContainer.Registrations.RegistrationBase.WithParameters(System.Object[])"/></para> <para>Can be set in the <see cref="T:LightweightIocContainer.Interfaces.Installers.IIocInstaller"/> by calling <see cref="M:LightweightIocContainer.Registrations.RegistrationBase.WithParameters(System.Object[])"/></para>
</summary> </summary>
</member> </member>
@ -1272,7 +1277,7 @@
</member> </member>
<member name="M:LightweightIocContainer.Registrations.RegistrationBase.WithParameters(System.Object[])"> <member name="M:LightweightIocContainer.Registrations.RegistrationBase.WithParameters(System.Object[])">
<summary> <summary>
Pass parameters that will be used to <see cref="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/> Pass parameters that will be used to <see cref="M:LightweightIocContainer.IocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/>
<para>Parameters set with this method are always inserted at the beginning of the argument list if more parameters are given when resolving</para> <para>Parameters set with this method are always inserted at the beginning of the argument list if more parameters are given when resolving</para>
</summary> </summary>
<param name="parameters">The parameters</param> <param name="parameters">The parameters</param>
@ -1281,7 +1286,7 @@
</member> </member>
<member name="M:LightweightIocContainer.Registrations.RegistrationBase.WithParameters(System.ValueTuple{System.Int32,System.Object}[])"> <member name="M:LightweightIocContainer.Registrations.RegistrationBase.WithParameters(System.ValueTuple{System.Int32,System.Object}[])">
<summary> <summary>
Pass parameters that will be used to<see cref="M:LightweightIocContainer.Interfaces.IIocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/> Pass parameters that will be used to<see cref="M:LightweightIocContainer.IocContainer.Resolve``1"/> an instance of this <see cref="P:LightweightIocContainer.Interfaces.Registrations.IRegistration.InterfaceType"/>
<para>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</para> <para>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</para>
</summary> </summary>
<param name="parameters">The parameters with their position</param> <param name="parameters">The parameters with their position</param>
@ -1425,7 +1430,7 @@
<see cref="T:System.Func`2"/> that is invoked instead of creating an instance of this <see cref="T:System.Type"/> the default way <see cref="T:System.Func`2"/> that is invoked instead of creating an instance of this <see cref="T:System.Type"/> the default way
</summary> </summary>
</member> </member>
<member name="M:LightweightIocContainer.Registrations.SingleTypeRegistration`1.WithFactoryMethod(System.Func{LightweightIocContainer.Interfaces.IIocContainer,`0})"> <member name="M:LightweightIocContainer.Registrations.SingleTypeRegistration`1.WithFactoryMethod(System.Func{LightweightIocContainer.Interfaces.IResolver,`0})">
<summary> <summary>
Pass a <see cref="T:System.Func`2"/> that will be invoked instead of creating an instance of this <see cref="T:System.Type"/> the default way Pass a <see cref="T:System.Func`2"/> that will be invoked instead of creating an instance of this <see cref="T:System.Type"/> the default way
</summary> </summary>

@ -6,7 +6,6 @@ using System;
using System.Linq; using System.Linq;
using LightweightIocContainer.Exceptions; using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Factories; using LightweightIocContainer.Factories;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Factories; using LightweightIocContainer.Interfaces.Factories;
using LightweightIocContainer.Interfaces.Installers; using LightweightIocContainer.Interfaces.Installers;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
@ -26,7 +25,7 @@ namespace LightweightIocContainer.Registrations
/// </summary> /// </summary>
/// <param name="interfaceType">The <see cref="Type"/> of the Interface</param> /// <param name="interfaceType">The <see cref="Type"/> of the Interface</param>
/// <param name="lifestyle">The <see cref="LightweightIocContainer.Lifestyle"/> of the registration</param> /// <param name="lifestyle">The <see cref="LightweightIocContainer.Lifestyle"/> of the registration</param>
/// <param name="container">The current instance of the <see cref="IIocContainer"/></param> /// <param name="container">The current instance of the <see cref="IocContainer"/></param>
protected RegistrationBase(Type interfaceType, Lifestyle lifestyle, IocContainer container) protected RegistrationBase(Type interfaceType, Lifestyle lifestyle, IocContainer container)
{ {
InterfaceType = interfaceType; InterfaceType = interfaceType;
@ -45,7 +44,7 @@ namespace LightweightIocContainer.Registrations
public Lifestyle Lifestyle { get; } public Lifestyle Lifestyle { get; }
/// <summary> /// <summary>
/// An <see cref="Array"/> of parameters that are used to <see cref="IIocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/> /// An <see cref="Array"/> of parameters that are used to <see cref="IocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/>
/// <para>Can be set in the <see cref="IIocInstaller"/> by calling <see cref="WithParameters(object[])"/></para> /// <para>Can be set in the <see cref="IIocInstaller"/> by calling <see cref="WithParameters(object[])"/></para>
/// </summary> /// </summary>
public object[] Parameters { get; private set; } public object[] Parameters { get; private set; }
@ -56,7 +55,7 @@ namespace LightweightIocContainer.Registrations
public ITypedFactory Factory { get; private set; } public ITypedFactory Factory { get; private set; }
/// <summary> /// <summary>
/// Pass parameters that will be used to <see cref="IIocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/> /// Pass parameters that will be used to <see cref="IocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/>
/// <para>Parameters set with this method are always inserted at the beginning of the argument list if more parameters are given when resolving</para> /// <para>Parameters set with this method are always inserted at the beginning of the argument list if more parameters are given when resolving</para>
/// </summary> /// </summary>
/// <param name="parameters">The parameters</param> /// <param name="parameters">The parameters</param>
@ -75,7 +74,7 @@ namespace LightweightIocContainer.Registrations
} }
/// <summary> /// <summary>
/// Pass parameters that will be used to<see cref="IIocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/> /// Pass parameters that will be used to<see cref="IocContainer.Resolve{T}()"/> an instance of this <see cref="IRegistration.InterfaceType"/>
/// <para>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</para> /// <para>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</para>
/// </summary> /// </summary>
/// <param name="parameters">The parameters with their position</param> /// <param name="parameters">The parameters with their position</param>

@ -29,14 +29,14 @@ namespace LightweightIocContainer.Registrations
/// <summary> /// <summary>
/// <see cref="Func{T,TResult}"/> that is invoked instead of creating an instance of this <see cref="Type"/> the default way /// <see cref="Func{T,TResult}"/> that is invoked instead of creating an instance of this <see cref="Type"/> the default way
/// </summary> /// </summary>
public Func<IIocContainer, T> FactoryMethod { get; private set; } public Func<IResolver, T> FactoryMethod { get; private set; }
/// <summary> /// <summary>
/// Pass a <see cref="Func{T,TResult}"/> that will be invoked instead of creating an instance of this <see cref="Type"/> the default way /// Pass a <see cref="Func{T,TResult}"/> that will be invoked instead of creating an instance of this <see cref="Type"/> the default way
/// </summary> /// </summary>
/// <param name="factoryMethod">The <see cref="Func{T,TResult}"/></param> /// <param name="factoryMethod">The <see cref="Func{T,TResult}"/></param>
/// <returns>The current instance of this <see cref="IRegistration"/></returns> /// <returns>The current instance of this <see cref="IRegistration"/></returns>
public ISingleTypeRegistration<T> WithFactoryMethod(Func<IIocContainer, T> factoryMethod) public ISingleTypeRegistration<T> WithFactoryMethod(Func<IResolver, T> factoryMethod)
{ {
FactoryMethod = factoryMethod; FactoryMethod = factoryMethod;
return this; return this;

@ -5,7 +5,6 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using LightweightIocContainer; using LightweightIocContainer;
using LightweightIocContainer.Exceptions; using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Interfaces;
using NUnit.Framework; using NUnit.Framework;
namespace Test.LightweightIocContainer namespace Test.LightweightIocContainer
@ -84,7 +83,7 @@ namespace Test.LightweightIocContainer
} }
private IIocContainer _iocContainer; private IocContainer _iocContainer;
[SetUp] [SetUp]
public void SetUp() => _iocContainer = new IocContainer(); public void SetUp() => _iocContainer = new IocContainer();

@ -5,7 +5,6 @@
using System; using System;
using JetBrains.Annotations; using JetBrains.Annotations;
using LightweightIocContainer; using LightweightIocContainer;
using LightweightIocContainer.Interfaces;
using NUnit.Framework; using NUnit.Framework;
namespace Test.LightweightIocContainer namespace Test.LightweightIocContainer
@ -44,7 +43,7 @@ namespace Test.LightweightIocContainer
} }
private IIocContainer _container; private IocContainer _container;
[SetUp] [SetUp]
public void SetUp() => _container = new IocContainer(); public void SetUp() => _container = new IocContainer();

@ -4,7 +4,6 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using LightweightIocContainer; using LightweightIocContainer;
using LightweightIocContainer.Interfaces;
using NUnit.Framework; using NUnit.Framework;
namespace Test.LightweightIocContainer namespace Test.LightweightIocContainer
@ -87,7 +86,7 @@ namespace Test.LightweightIocContainer
} }
private IIocContainer _iocContainer; private IocContainer _iocContainer;
[SetUp] [SetUp]
public void SetUp() => _iocContainer = new IocContainer(); public void SetUp() => _iocContainer = new IocContainer();

@ -5,7 +5,6 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using LightweightIocContainer; using LightweightIocContainer;
using LightweightIocContainer.Exceptions; using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Interfaces;
using Moq; using Moq;
using NUnit.Framework; using NUnit.Framework;
@ -85,7 +84,7 @@ namespace Test.LightweightIocContainer
} }
private IIocContainer _iocContainer; private IocContainer _iocContainer;
[SetUp] [SetUp]
public void SetUp() => _iocContainer = new IocContainer(); public void SetUp() => _iocContainer = new IocContainer();

@ -80,7 +80,7 @@ namespace Test.LightweightIocContainer
} }
private IIocContainer _iocContainer; private IocContainer _iocContainer;
[SetUp] [SetUp]
public void SetUp() => _iocContainer = new IocContainer(); public void SetUp() => _iocContainer = new IocContainer();

@ -4,7 +4,6 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using LightweightIocContainer; using LightweightIocContainer;
using LightweightIocContainer.Interfaces;
using NUnit.Framework; using NUnit.Framework;
namespace Test.LightweightIocContainer namespace Test.LightweightIocContainer
@ -12,7 +11,7 @@ namespace Test.LightweightIocContainer
[TestFixture] [TestFixture]
public class MultipleMultitonRegistrationTest public class MultipleMultitonRegistrationTest
{ {
private IIocContainer _iocContainer; private IocContainer _iocContainer;
[UsedImplicitly] [UsedImplicitly]
public interface ITest : IProvider public interface ITest : IProvider

@ -6,7 +6,6 @@ using System.Diagnostics.CodeAnalysis;
using JetBrains.Annotations; using JetBrains.Annotations;
using LightweightIocContainer; using LightweightIocContainer;
using LightweightIocContainer.Exceptions; using LightweightIocContainer.Exceptions;
using LightweightIocContainer.Interfaces;
using NUnit.Framework; using NUnit.Framework;
namespace Test.LightweightIocContainer namespace Test.LightweightIocContainer
@ -14,7 +13,7 @@ namespace Test.LightweightIocContainer
[TestFixture] [TestFixture]
public class OpenGenericRegistrationTest public class OpenGenericRegistrationTest
{ {
private IIocContainer _iocContainer; private IocContainer _iocContainer;
[UsedImplicitly] [UsedImplicitly]
[SuppressMessage("ReSharper", "UnusedTypeParameter")] [SuppressMessage("ReSharper", "UnusedTypeParameter")]

@ -4,7 +4,6 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using LightweightIocContainer; using LightweightIocContainer;
using LightweightIocContainer.Interfaces;
using LightweightIocContainer.Interfaces.Registrations; using LightweightIocContainer.Interfaces.Registrations;
using LightweightIocContainer.Registrations; using LightweightIocContainer.Registrations;
using Moq; using Moq;
@ -58,7 +57,7 @@ namespace Test.LightweightIocContainer
[Test] [Test]
public void TestSingleTypeRegistrationResolveSingleton() public void TestSingleTypeRegistrationResolveSingleton()
{ {
IIocContainer container = new IocContainer(); IocContainer container = new IocContainer();
IBar bar = new Bar(); IBar bar = new Bar();
container.Register<IFoo>(Lifestyle.Singleton).WithFactoryMethod(_ => new Foo(bar)); container.Register<IFoo>(Lifestyle.Singleton).WithFactoryMethod(_ => new Foo(bar));

Loading…
Cancel
Save