Skip to content

Commit

Permalink
Add AddControl method to ServiceCollectionExtensions
Browse files Browse the repository at this point in the history
This method allows registering controls with the IServiceCollection. It uses a generic type parameter to add transient services for controls.
  • Loading branch information
frankhaugen committed Aug 5, 2024
1 parent ffdb443 commit 8404c59
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Frank.Wpf.Hosting/ServiceCollectionExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,10 @@ public static IServiceCollection AddWindow<T>(this IServiceCollection services)
services.AddTransient<Window, T>(provider => provider.GetRequiredService<T>());
return services;
}

public static IServiceCollection AddControl<T>(this IServiceCollection services) where T : Control
{
services.AddTransient<T>();
return services;
}
}

0 comments on commit 8404c59

Please sign in to comment.