| | | 1 | | using Microsoft.Extensions.DependencyInjection; |
| | | 2 | | |
| | | 3 | | using NexusLabs.Needlr.Injection.TypeFilterers; |
| | | 4 | | |
| | | 5 | | using System.Reflection; |
| | | 6 | | |
| | | 7 | | namespace NexusLabs.Needlr.Injection; |
| | | 8 | | |
| | | 9 | | /// <summary> |
| | | 10 | | /// The base container for configuring Needlr service discovery. |
| | | 11 | | /// </summary> |
| | | 12 | | /// <remarks> |
| | | 13 | | /// <para> |
| | | 14 | | /// <see cref="Syringe"/> is a starting point that must be configured with a strategy before building. |
| | | 15 | | /// Use one of these approaches to get a <see cref="ConfiguredSyringe"/> that can build a service provider: |
| | | 16 | | /// </para> |
| | | 17 | | /// <list type="bullet"> |
| | | 18 | | /// <item>Reference <c>NexusLabs.Needlr.Injection.SourceGen</c> and call <c>.UsingSourceGen()</c></item> |
| | | 19 | | /// <item>Reference <c>NexusLabs.Needlr.Injection.Reflection</c> and call <c>.UsingReflection()</c></item> |
| | | 20 | | /// <item>Reference <c>NexusLabs.Needlr.Injection.Bundle</c> and call <c>.UsingAutoConfiguration()</c></item> |
| | | 21 | | /// </list> |
| | | 22 | | /// <para> |
| | | 23 | | /// The strategy methods return a <see cref="ConfiguredSyringe"/> which has the <c>BuildServiceProvider()</c> method. |
| | | 24 | | /// </para> |
| | | 25 | | /// </remarks> |
| | | 26 | | /// <example> |
| | | 27 | | /// <code> |
| | | 28 | | /// // Using reflection |
| | | 29 | | /// var provider = new Syringe() |
| | | 30 | | /// .UsingReflection() |
| | | 31 | | /// .BuildServiceProvider(); |
| | | 32 | | /// |
| | | 33 | | /// // Using source generation (AOT-compatible) |
| | | 34 | | /// var provider = new Syringe() |
| | | 35 | | /// .UsingSourceGen() |
| | | 36 | | /// .BuildServiceProvider(); |
| | | 37 | | /// </code> |
| | | 38 | | /// </example> |
| | | 39 | | [DoNotAutoRegister] |
| | | 40 | | public sealed record Syringe |
| | | 41 | | { |
| | 590 | 42 | | internal ITypeRegistrar? TypeRegistrar { get; init; } |
| | 590 | 43 | | internal ITypeFilterer? TypeFilterer { get; init; } |
| | 590 | 44 | | internal IPluginFactory? PluginFactory { get; init; } |
| | 590 | 45 | | internal Func<ITypeRegistrar, ITypeFilterer, IPluginFactory, IServiceCollectionPopulator>? ServiceCollectionPopulato |
| | 590 | 46 | | internal IAssemblyProvider? AssemblyProvider { get; init; } |
| | 590 | 47 | | internal AssemblyOrdering.AssemblyOrderBuilder? AssemblyOrder { get; init; } |
| | 590 | 48 | | internal IReadOnlyList<Assembly>? AdditionalAssemblies { get; init; } |
| | 590 | 49 | | internal IReadOnlyList<Action<IServiceCollection>>? PreRegistrationCallbacks { get; init; } |
| | 590 | 50 | | internal IReadOnlyList<Action<IServiceCollection>>? PostPluginRegistrationCallbacks { get; init; } |
| | 590 | 51 | | internal VerificationOptions? VerificationOptions { get; init; } |
| | | 52 | | |
| | | 53 | | /// <summary> |
| | | 54 | | /// Factory for creating <see cref="IServiceProviderBuilder"/> instances. |
| | | 55 | | /// </summary> |
| | 590 | 56 | | internal Func<IServiceCollectionPopulator, IAssemblyProvider, IReadOnlyList<Assembly>, IServiceProviderBuilder>? Ser |
| | | 57 | | } |