Ch0pstix.InjectX.Shared 1.0.0

dotnet add package Ch0pstix.InjectX.Shared --version 1.0.0                
NuGet\Install-Package Ch0pstix.InjectX.Shared -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.Shared" 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.Shared --version 1.0.0                
#r "nuget: Ch0pstix.InjectX.Shared, 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.Shared as a Cake Addin
#addin nuget:?package=Ch0pstix.InjectX.Shared&version=1.0.0

// Install Ch0pstix.InjectX.Shared as a Cake Tool
#tool nuget:?package=Ch0pstix.InjectX.Shared&version=1.0.0                

InjectX ยท License

InjectX Banner

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 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.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Ch0pstix.InjectX.Shared:

Package Downloads
Ch0pstix.InjectX.Mvvm

Automatic view and viewmodel registration extensions for Microsoft.Extensions.DependencyInjection.

Ch0pstix.InjectX

Automatic service registration extensions for Microsoft.Extensions.DependencyInjection.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.0 634 2/11/2023