diff --git a/LightweightIocContainer/Registrations/TypedFactoryRegistration.cs b/LightweightIocContainer/Registrations/TypedFactoryRegistration.cs index 5bf24c1..0e00fba 100644 --- a/LightweightIocContainer/Registrations/TypedFactoryRegistration.cs +++ b/LightweightIocContainer/Registrations/TypedFactoryRegistration.cs @@ -20,16 +20,12 @@ namespace LightweightIocContainer.Registrations /// The type of the abstract typed factory public class TypedFactoryRegistration : ITypedFactoryRegistration { - private readonly IIocContainer _container; - public TypedFactoryRegistration(Type factoryType, IIocContainer container) { - _container = container; - InterfaceType = factoryType; Name = $"{InterfaceType.Name}"; - CreateFactory(); + CreateFactory(container); } /// @@ -52,7 +48,7 @@ namespace LightweightIocContainer.Registrations /// Creates the factory from the given abstract factory type /// /// Factory registration is invalid - private void CreateFactory() + private void CreateFactory(IIocContainer container) { var createMethods = InterfaceType.GetMethods().Where(m => m.ReturnType != typeof(void)).ToList(); if (!createMethods.Any()) @@ -127,7 +123,7 @@ namespace LightweightIocContainer.Registrations generator.Emit(OpCodes.Ret); } - Factory.Factory = (TFactory) Activator.CreateInstance(typeBuilder.CreateTypeInfo().AsType(), _container); + Factory.Factory = (TFactory) Activator.CreateInstance(typeBuilder.CreateTypeInfo().AsType(), container); } } } \ No newline at end of file