Ch0pstix.InjectX
1.0.0
dotnet add package Ch0pstix.InjectX --version 1.0.0
NuGet\Install-Package Ch0pstix.InjectX -Version 1.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Ch0pstix.InjectX" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Ch0pstix.InjectX --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Ch0pstix.InjectX, 1.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Ch0pstix.InjectX as a Cake Addin #addin nuget:?package=Ch0pstix.InjectX&version=1.0.0 // Install Ch0pstix.InjectX as a Cake Tool #tool nuget:?package=Ch0pstix.InjectX&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
InjectX ยท
Automatic service registration extensions for Microsoft.Extensions.DependencyInjection
.
๐ Getting Started
The packages may be installed via Nuget, Package Manager Console, or DotNet CLI.
Nuget
Package Manager Console
Install-Package InjectX
Install-Package InjectX.Mvvm
DotNet CLI
dotnet add package InjectX
dotnet add package InjectX.Mvvm
๐ What's Included
Types
Name | Description |
---|---|
SingletonAttribute | Specifies that a view or service should be registered with a ServiceLifetime of ServiceLifetime.Singleton . |
TransientAttribute | Specifies that a view or service should be registered with a ServiceLifetime of ServiceLifetime.Transient . |
ScopedAttribute | Specifies that a service should be registered with a ServiceLifetime of ServiceLifetime.Scoped . |
RegistrationStrategy | Specifies strategies that may be applied when adding a ServiceDescriptor to an IServiceCollection . |
Extension Methods
Method | Description |
---|---|
IServiceCollection.RegisterApplicationServices(optional: ServiceRegistrationStrategy) | Registers service objects that have been defined within the application's assembly. |
IServiceCollection.RegisterAssemblyServices(Assembly, optional: ServiceRegistrationStrategy) | Registers service objects that have been defined within the specified assembly. |
IServiceCollection.RegisterViewsAndViewModels() | Registers view and viewmodel objects that have been defined within the application's assembly. |
๐ก Usage Examples
Console App (InjectX)
MyConsoleApp/Program.cs
using MyConsoleApp.Services;
var services = new ServiceCollection()
.RegisterApplicationServices() // from MyConsoleApp.Services*
.BuildServiceProvider();
var service = services.GetRequiredService<IExampleService>();
service.SayHello();
MyConsoleApp/Services/IExampleService.cs
public interface IExampleService()
{
void SayHello();
}
MyConsoleApp/Services/ExampleService.cs
[Transient] // Compiled descriptor will be (IExampleService, ExampleService, ServiceLifetime.Transient)
public class ExampleService : IExampleService
{
public void SayHello()
{
Console.WriteLine("Hello World");
}
}
Wpf Mvvm App (InjectX + InjectX.Mvvm)
MyWpfApp/App.xaml.cs:
public partial class App : Application
{
protected override void OnStartup(StartupEventArgs e)
{
var services = new ServiceCollection()
.RegisterApplicationServices() // from MyWpfApp.Services*
.RegisterViewsAndViewModels() // from MyWpfApp.Views* && MyWpfApp.ViewModels*
.BuildServiceProvider();
var mainWindow = services.GetRequiredService<MainWindow>();
mainWindow.Show();
base.OnStartup(e);
}
}
MyWpfApp/Views/Dialogs/MyCustomDialogWindow.cs:
[Transient] // Override the default singleton lifetime as dialogs tend to be reusable objects
public partial class MyCustomDialogWindow : Window
{
public MyCustomDialogWindow()
{
InitializeComponent();
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETStandard 2.1
- Ch0pstix.InjectX.Shared (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.0 | 204 | 2/11/2023 |