diff options
Diffstat (limited to 'lib/VNLib.Plugins.Extensions.Loading/src')
-rw-r--r-- | lib/VNLib.Plugins.Extensions.Loading/src/LoadingExtensions.cs | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/VNLib.Plugins.Extensions.Loading/src/LoadingExtensions.cs b/lib/VNLib.Plugins.Extensions.Loading/src/LoadingExtensions.cs index 3da015e..207aeed 100644 --- a/lib/VNLib.Plugins.Extensions.Loading/src/LoadingExtensions.cs +++ b/lib/VNLib.Plugins.Extensions.Loading/src/LoadingExtensions.cs @@ -30,6 +30,7 @@ using System.Reflection; using System.Runtime.Loader; using System.Threading.Tasks; using System.Collections.Generic; +using System.ComponentModel.Design; using System.Runtime.CompilerServices; using VNLib.Utils.Logging; @@ -359,6 +360,21 @@ namespace VNLib.Plugins.Extensions.Loading } /// <summary> + /// Adds a service to the <see cref="IServiceContainer"/> using generics syntax + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="container"></param> + /// <param name="service">The service instance to add to the container</param> + /// <exception cref="ArgumentNullException"></exception> + public static void AddService<T>(this IServiceContainer container, T service) + { + _ = container ?? throw new ArgumentNullException(nameof(container)); + _ = service ?? throw new ArgumentNullException(nameof(service)); + + container.AddService(typeof(T), service); + } + + /// <summary> /// <para> /// Gets or inializes a singleton service of the desired type. /// </para> |