diff --git a/src/c#/GeneralUpdate.Drivelution/Core/ServiceCollectionExtensions.cs b/src/c#/GeneralUpdate.Drivelution/Core/ServiceCollectionExtensions.cs
new file mode 100644
index 00000000..82e8b3d9
--- /dev/null
+++ b/src/c#/GeneralUpdate.Drivelution/Core/ServiceCollectionExtensions.cs
@@ -0,0 +1,75 @@
+using Microsoft.Extensions.DependencyInjection;
+using GeneralUpdate.Drivelution.Abstractions;
+using GeneralUpdate.Drivelution.Abstractions.Configuration;
+using GeneralUpdate.Drivelution.Core.Execution;
+using GeneralUpdate.Drivelution.Windows.Implementation;
+using GeneralUpdate.Drivelution.Linux.Implementation;
+using GeneralUpdate.Drivelution.MacOS.Implementation;
+
+namespace GeneralUpdate.Drivelution.Core;
+
+///
+/// Extension methods for registering Drivelution services in the DI container.
+///
+public static class ServiceCollectionExtensions
+{
+ ///
+ /// Registers the Drivelution driver update services for the current platform.
+ ///
+ /// The service collection.
+ /// Optional configuration action for .
+ /// The service collection for chaining.
+ ///
+ ///
+ /// // ASP.NET / Generic Host
+ /// builder.Services.AddDrivelution();
+ ///
+ /// // With options
+ /// builder.Services.AddDrivelution(options =>
+ /// {
+ /// options.DefaultRetryCount = 5;
+ /// options.DefaultTimeoutSeconds = 600;
+ /// });
+ ///
+ /// // Consumer
+ /// public class MyService
+ /// {
+ /// public MyService(IGeneralDrivelution updater) { ... }
+ /// }
+ ///
+ ///
+ public static IServiceCollection AddDrivelution(
+ this IServiceCollection services,
+ Action? configure = null)
+ {
+ // Configuration
+ var options = new DrivelutionOptions();
+ configure?.Invoke(options);
+ services.AddSingleton(options);
+
+ // Infrastructure
+ services.AddSingleton();
+
+ // Platform-specific registrations
+ if (OperatingSystem.IsWindows())
+ {
+ services.AddSingleton();
+ services.AddSingleton();
+ services.AddSingleton();
+ }
+ else if (OperatingSystem.IsLinux())
+ {
+ services.AddSingleton();
+ services.AddSingleton();
+ services.AddSingleton();
+ }
+ else if (OperatingSystem.IsMacOS())
+ {
+ services.AddSingleton();
+ services.AddSingleton();
+ services.AddSingleton();
+ }
+
+ return services;
+ }
+}
diff --git a/src/c#/GeneralUpdate.Drivelution/GeneralDrivelution.cs b/src/c#/GeneralUpdate.Drivelution/GeneralDrivelution.cs
index e7ae3a5c..b7238055 100644
--- a/src/c#/GeneralUpdate.Drivelution/GeneralDrivelution.cs
+++ b/src/c#/GeneralUpdate.Drivelution/GeneralDrivelution.cs
@@ -3,6 +3,7 @@
using GeneralUpdate.Drivelution.Abstractions.Configuration;
using GeneralUpdate.Drivelution.Abstractions.Models;
using GeneralUpdate.Drivelution.Core.Utilities;
+using Microsoft.Extensions.DependencyInjection;
namespace GeneralUpdate.Drivelution;
@@ -35,6 +36,22 @@ public static IGeneralDrivelution Create(DrivelutionOptions? options = null)
return Core.DrivelutionFactory.Create(options);
}
+ ///
+ /// Resolves a driver updater from the DI service provider.
+ /// Falls back to if not registered.
+ ///
+ /// DI service provider.
+ /// Platform-adapted driver updater.
+ public static IGeneralDrivelution Create(IServiceProvider serviceProvider)
+ {
+ var updater = serviceProvider.GetService();
+ if (updater is not null)
+ return updater;
+
+ var options = serviceProvider.GetService();
+ return Core.DrivelutionFactory.Create(options);
+ }
+
///
/// Quick driver update (with default configuration)
///
diff --git a/src/c#/GeneralUpdate.Drivelution/GeneralUpdate.Drivelution.csproj b/src/c#/GeneralUpdate.Drivelution/GeneralUpdate.Drivelution.csproj
index dec7ca72..7b3594ca 100644
--- a/src/c#/GeneralUpdate.Drivelution/GeneralUpdate.Drivelution.csproj
+++ b/src/c#/GeneralUpdate.Drivelution/GeneralUpdate.Drivelution.csproj
@@ -48,5 +48,8 @@
./
+
+
+