
Security News
TC39 Advances 11 Proposals for Math Precision, Binary APIs, and More
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
JoeDevSharp.WinForms.Extensions.DependencyInjection
Advanced tools
Advanced Dependency Injection (DI) integration tailored for Windows Forms applications. Built on top of `Microsoft.Extensions.DependencyInjection`, but adapted and extended to address WinForms-specific development needs.
Advanced Dependency Injection (DI) integration tailored for Windows Forms applications. Built on top of Microsoft.Extensions.DependencyInjection
, but adapted and extended to address WinForms-specific development needs.
[Inject]
-marked properties.IInjectable
interface for post-injection initialization.Reactive
and RouteManager
.Add the package via NuGet or build from source:
dotnet add package WinForms.Extensions.DependencyInjection
Program.cs
using Microsoft.Extensions.DependencyInjection;
using WinForms.Extensions.DependencyInjection.Bootstrap;
var services = new ServiceCollection();
// Register your services and forms here
services.AddSingleton<IMainService, MainService>();
services.AddTransient<MainForm>();
services.AddSingleton<FormFactory>();
var provider = services.BuildWinFormsServiceProvider();
ServiceProviderGlobal.Instance.Initialize(provider);
Application.Run(provider.GetRequiredService<MainForm>());
var formFactory = provider.GetRequiredService<FormFactory>();
var settingsForm = formFactory.CreateScopedForm<SettingsForm>();
settingsForm.Show();
[Inject]
public partial class MainForm : Form, IInjectable
{
[Inject]
public IMyService MyService { get; set; }
public MainForm()
{
InitializeComponent();
this.ResolveInjectedProperties(ServiceProviderGlobal.Instance.Provider);
}
public void OnInjected()
{
// Initialization logic after injection
}
}
ServiceProviderBuilder.BuildWinFormsServiceProvider(IServiceCollection)
: Builds the DI container.FormFactory.CreateScopedForm<T>()
: Creates a form with its own scoped lifetime.[Inject]
: Attribute to mark properties for injection.ResolveInjectedProperties(this object, IServiceProvider)
: Extension for automatic property injection.IInjectable
: Interface for post-injection initialization callback.ServiceProviderGlobal.Instance
: Singleton for global service provider access.This module addresses common DI challenges in WinForms by integrating naturally with the platform and respecting its paradigms. It simplifies transitioning to modern, maintainable architectures.
https://github.com/JoeDevSharp/WinForms.Extensions.DependencyInjection
Contributions, issues, and pull requests are welcome.
FAQs
Advanced Dependency Injection (DI) integration tailored for Windows Forms applications. Built on top of `Microsoft.Extensions.DependencyInjection`, but adapted and extended to address WinForms-specific development needs.
We found that joedevsharp.winforms.extensions.dependencyinjection demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
TC39 advances 11 JavaScript proposals, with two moving to Stage 4, bringing better math, binary APIs, and more features one step closer to the ECMAScript spec.
Research
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.