From 7d3a12fabf46978c446135ae1dba310d45f2103a Mon Sep 17 00:00:00 2001 From: "Simon G." Date: Fri, 5 Dec 2025 08:53:01 +0100 Subject: [PATCH] - add generic factory --- .../SampleInstaller.cs | 1 + .../Samples/Factories/IGenericSampleFactory.cs | 12 ++++++++++++ .../Samples/Interfaces/IOtherSample.cs | 7 +++++++ .../Samples/OtherSample.cs | 9 +++++++++ 4 files changed, 29 insertions(+) create mode 100644 Debug.LightweightIocContainer.FactoryGenerator/Samples/Factories/IGenericSampleFactory.cs create mode 100644 Debug.LightweightIocContainer.FactoryGenerator/Samples/Interfaces/IOtherSample.cs create mode 100644 Debug.LightweightIocContainer.FactoryGenerator/Samples/OtherSample.cs diff --git a/Debug.LightweightIocContainer.FactoryGenerator/SampleInstaller.cs b/Debug.LightweightIocContainer.FactoryGenerator/SampleInstaller.cs index dd14b13..20e9a55 100644 --- a/Debug.LightweightIocContainer.FactoryGenerator/SampleInstaller.cs +++ b/Debug.LightweightIocContainer.FactoryGenerator/SampleInstaller.cs @@ -16,5 +16,6 @@ public class SampleInstaller : IIocInstaller public void Install(IRegistrationCollector registration) { registration.Add().WithGeneratedFactory(); + registration.Add().WithGeneratedFactory>(); } } \ No newline at end of file diff --git a/Debug.LightweightIocContainer.FactoryGenerator/Samples/Factories/IGenericSampleFactory.cs b/Debug.LightweightIocContainer.FactoryGenerator/Samples/Factories/IGenericSampleFactory.cs new file mode 100644 index 0000000..cb165b2 --- /dev/null +++ b/Debug.LightweightIocContainer.FactoryGenerator/Samples/Factories/IGenericSampleFactory.cs @@ -0,0 +1,12 @@ +// Author: Simon.Gockner +// Created: 2025-12-05 +// Copyright(c) 2025 SimonG. All Rights Reserved. + +using Debug.LightweightIocContainer.FactoryGenerator.Samples.Interfaces; + +namespace Debug.LightweightIocContainer.FactoryGenerator.Samples.Factories; + +public interface IGenericSampleFactory where T : IOtherSample +{ + T Create(); +} \ No newline at end of file diff --git a/Debug.LightweightIocContainer.FactoryGenerator/Samples/Interfaces/IOtherSample.cs b/Debug.LightweightIocContainer.FactoryGenerator/Samples/Interfaces/IOtherSample.cs new file mode 100644 index 0000000..e302c88 --- /dev/null +++ b/Debug.LightweightIocContainer.FactoryGenerator/Samples/Interfaces/IOtherSample.cs @@ -0,0 +1,7 @@ +// Author: Simon.Gockner +// Created: 2025-12-05 +// Copyright(c) 2025 SimonG. All Rights Reserved. + +namespace Debug.LightweightIocContainer.FactoryGenerator.Samples.Interfaces; + +public interface IOtherSample; \ No newline at end of file diff --git a/Debug.LightweightIocContainer.FactoryGenerator/Samples/OtherSample.cs b/Debug.LightweightIocContainer.FactoryGenerator/Samples/OtherSample.cs new file mode 100644 index 0000000..72095a1 --- /dev/null +++ b/Debug.LightweightIocContainer.FactoryGenerator/Samples/OtherSample.cs @@ -0,0 +1,9 @@ +// Author: Simon.Gockner +// Created: 2025-12-05 +// Copyright(c) 2025 SimonG. All Rights Reserved. + +using Debug.LightweightIocContainer.FactoryGenerator.Samples.Interfaces; + +namespace Debug.LightweightIocContainer.FactoryGenerator.Samples; + +public class OtherSample : IOtherSample; \ No newline at end of file