Billys-ConsoleDi 1.0.0

dotnet add package Billys-ConsoleDi --version 1.0.0                
NuGet\Install-Package Billys-ConsoleDi -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="Billys-ConsoleDi" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Billys-ConsoleDi --version 1.0.0                
#r "nuget: Billys-ConsoleDi, 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 Billys-ConsoleDi as a Cake Addin
#addin nuget:?package=Billys-ConsoleDi&version=1.0.0

// Install Billys-ConsoleDi as a Cake Tool
#tool nuget:?package=Billys-ConsoleDi&version=1.0.0                

Billy's Console DI

Simple lightweight Di for console applications

Setup

// Instantiate the DiServiceCollection
var services = new DiServiceCollection();

//Register your services
services.RegisterSingleton<ISayHello, Greeter>();
services.RegisterSingleton<App>();

// Build the container
var container = services.BuildContainer();

// Retrieve your desired configuration
var app = container.GetService<App>();

// Use as desired
await app.Startup();

Transient scopes also supported

services.RegisterTransient<ISayHello, Greeter>();

Use a startup class

To use a startup class register your class as you see above.

In your startup class inject the necessary dependencies and call them inside of your startup method

private ISayHello _greeter;

public App(ISayHello greeter)
{
        _greeter = greeter;
}
public async Task Startup()
{
        Console.WriteLine("Here I go..."
    _greeter.SayHello();
}

make sure in your program.cs class, inside the main method you're calling your startup method

await app.Startup();
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net5.0

    • No dependencies.

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 275 2/22/2022