| | | 1 | | using NexusLabs.Needlr.Injection; |
| | | 2 | | |
| | | 3 | | namespace NexusLabs.Needlr.Injection.Scrutor; |
| | | 4 | | |
| | | 5 | | /// <summary> |
| | | 6 | | /// Extension methods for configuring <see cref="ConfiguredSyringe"/> instances with Scrutor-specific functionality. |
| | | 7 | | /// </summary> |
| | | 8 | | /// <remarks> |
| | | 9 | | /// Scrutor uses runtime reflection for assembly scanning. |
| | | 10 | | /// For AOT/trimming compatibility, use source-generated components instead. |
| | | 11 | | /// </remarks> |
| | | 12 | | /// <example> |
| | | 13 | | /// Reflection-based usage with Scrutor: |
| | | 14 | | /// <code> |
| | | 15 | | /// var serviceProvider = new Syringe() |
| | | 16 | | /// .UsingReflection() |
| | | 17 | | /// .UsingScrutorTypeRegistrar() |
| | | 18 | | /// .BuildServiceProvider(); |
| | | 19 | | /// </code> |
| | | 20 | | /// </example> |
| | | 21 | | public static class SyringeScrutorExtensions |
| | | 22 | | { |
| | | 23 | | /// <summary> |
| | | 24 | | /// Configures the syringe to use the Scrutor type registrar. |
| | | 25 | | /// This enables automatic service registration using the Scrutor library for assembly scanning. |
| | | 26 | | /// </summary> |
| | | 27 | | /// <param name="syringe">The configured syringe to update.</param> |
| | | 28 | | /// <returns>A new configured syringe instance.</returns> |
| | | 29 | | /// <example> |
| | | 30 | | /// <code> |
| | | 31 | | /// var syringe = new Syringe() |
| | | 32 | | /// .UsingReflection() |
| | | 33 | | /// .UsingScrutorTypeRegistrar(); |
| | | 34 | | /// </code> |
| | | 35 | | /// </example> |
| | | 36 | | public static ConfiguredSyringe UsingScrutorTypeRegistrar(this ConfiguredSyringe syringe) |
| | | 37 | | { |
| | 29 | 38 | | ArgumentNullException.ThrowIfNull(syringe); |
| | 28 | 39 | | return syringe.UsingTypeRegistrar(new ScrutorTypeRegistrar()); |
| | | 40 | | } |
| | | 41 | | } |