diff --git a/LightweightIocContainer/Interfaces/Factories/IFactoryBuilder.cs b/LightweightIocContainer/Interfaces/Factories/IFactoryBuilder.cs new file mode 100644 index 0000000..f64ae43 --- /dev/null +++ b/LightweightIocContainer/Interfaces/Factories/IFactoryBuilder.cs @@ -0,0 +1,19 @@ +// Author: Simon.Gockner +// Created: 2025-12-02 +// Copyright(c) 2025 SimonG. All Rights Reserved. + +namespace LightweightIocContainer.Interfaces.Factories; + +/// +/// Internal class used by the factory source generator to create factory instances +/// +public interface IFactoryBuilder +{ + /// + /// Internal method used by the factory source generator to create factory instances + /// + /// The current instance of the + /// The type of the factory + /// The created factory instance + TFactory Create(IocContainer container); +} \ No newline at end of file diff --git a/LightweightIocContainer/Interfaces/Registrations/Fluent/IWithFactory.cs b/LightweightIocContainer/Interfaces/Registrations/Fluent/IWithFactory.cs index 918a998..978b045 100644 --- a/LightweightIocContainer/Interfaces/Registrations/Fluent/IWithFactory.cs +++ b/LightweightIocContainer/Interfaces/Registrations/Fluent/IWithFactory.cs @@ -29,9 +29,9 @@ public interface IWithFactory /// /// Internal method used by the factory source generator to add the generated factory to the registration /// - /// The actual generated factory + /// The factory creator /// The type of the generated factory - void AddGeneratedFactory(TFactory generatedFactory); + void AddGeneratedFactory(IFactoryBuilder factoryBuilder); } internal interface IWithFactoryInternal : IWithFactory diff --git a/LightweightIocContainer/LightweightIocContainer.xml b/LightweightIocContainer/LightweightIocContainer.xml index 6eb609a..8bbe8b4 100644 --- a/LightweightIocContainer/LightweightIocContainer.xml +++ b/LightweightIocContainer/LightweightIocContainer.xml @@ -486,6 +486,19 @@ The given A new with the given + + + Internal class used by the factory source generator to create factory instances + + + + + Internal method used by the factory source generator to create factory instances + + The current instance of the + The type of the factory + The created factory instance + Non-generic @@ -670,11 +683,11 @@ The type of the implementation for the custom factory The current instance of this - + Internal method used by the factory source generator to add the generated factory to the registration - The actual generated factory + The factory creator The type of the generated factory @@ -1608,11 +1621,11 @@ The type of the abstract typed factory The current instance of this - + Internal method used by the factory source generator to add the generated factory to the registration - The actual generated factory + The factory creator The type of the generated factory diff --git a/LightweightIocContainer/Registrations/RegistrationBase.cs b/LightweightIocContainer/Registrations/RegistrationBase.cs index 54639b5..048f8ec 100644 --- a/LightweightIocContainer/Registrations/RegistrationBase.cs +++ b/LightweightIocContainer/Registrations/RegistrationBase.cs @@ -120,15 +120,15 @@ internal abstract class RegistrationBase : IRegistrationBase, IWithFactoryIntern return this; } - + /// /// Internal method used by the factory source generator to add the generated factory to the registration /// - /// The actual generated factory + /// The factory creator /// The type of the generated factory - public void AddGeneratedFactory(TFactory generatedFactory) + public void AddGeneratedFactory(IFactoryBuilder factoryBuilder) { - TypedFactory factory = new(generatedFactory); + TypedFactory factory = new(factoryBuilder.Create(_container)); Factory = factory; _container.RegisterFactory(factory);