J4JSoftware.DependencyInjection
2.0.1
See the version list below for details.
dotnet add package J4JSoftware.DependencyInjection --version 2.0.1
NuGet\Install-Package J4JSoftware.DependencyInjection -Version 2.0.1
<PackageReference Include="J4JSoftware.DependencyInjection" Version="2.0.1" />
paket add J4JSoftware.DependencyInjection --version 2.0.1
#r "nuget: J4JSoftware.DependencyInjection, 2.0.1"
// Install J4JSoftware.DependencyInjection as a Cake Addin #addin nuget:?package=J4JSoftware.DependencyInjection&version=2.0.1 // Install J4JSoftware.DependencyInjection as a Cake Tool #tool nuget:?package=J4JSoftware.DependencyInjection&version=2.0.1
Dependency Injection
There are breaking changes in this release. Please re-review the github documentation.
Provides a customized IHostBuilder
-based system for producing an IHost
instance which contain a number of useful services. These include:
- logging (via J4JLogger)
- application and user configuration file management
- simple data protection (i.e., encryption and decryption of strings, via
Microsoft.AspNetCore.DataProtection
) - command line parsing (via J4JCommandLine)
- dependency injection (via Autofac)
This assembly targets Net5 and has nullability enabled.
This example is derived from my GeoProcessor console app. However, it's been simplified to illustrate certain concepts more clearly and therefore will not work "as written".
internal class Program
{
internal static IHost? Host { get; private set; }
private static readonly CancellationToken _cancellationToken = new();
private static IJ4JLogger? _buildLogger;
private static async Task Main( string[] args )
{
var hostConfig = new J4JHostConfiguration()
.ApplicationName( "GeoProcessor" )
.Publisher( "J4JSoftware" )
.OperatingSystem( OSNames.Windows )
.AddApplicationConfigurationFile("appConfig.json")
.AddUserConfigurationFile("userConfig.json")
.AddConfigurationInitializers(SetupConfiguration)
.LoggerInitializer( SetupLogging )
.FilePathTrimmer(FilePathTrimmer)
.OptionsInitializer( SetupOptions )
.AddDependencyInjectionInitializers( SetupDependencyInjection )
.AddServicesInitializers( SetupServices );
_buildLogger = hostConfig.Logger;
var builder = hostConfig.CreateHostBuilder();
Host = builder.Build();
await Host!.RunAsync( _cancellationToken );
}
}
This example Main program shows the basic outline of how to use J4JConfigurationHost
. You create an instance, call various extension methods on it, check to see if all the basic requirements are satisfied, create the builder by calling CreateHostBuilder()
, make sure the builder got built, and then call Build()
on the builder.
Please note, however, that we store the build-time logger, contained in J4JConfigurationHost
's Logger
property, in a field variable. This is done so we can reference it in some of the configuration actions we've defined below. That lets the configuration actions report on issues and problems when they execute when the IHost
instance gets built.
Product | Versions 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. |
-
net5.0
- Autofac (>= 6.2.0)
- Autofac.Configuration (>= 6.0.0)
- Autofac.Extensions.DependencyInjection (>= 7.1.0)
- J4JSoftware.Configuration.CommandLine (>= 4.0.1)
- J4JSoftware.Logging (>= 4.0.1)
- J4JSoftware.TypeUtilities (>= 1.0.0)
- Microsoft.AspNetCore.DataProtection (>= 5.0.10)
- Microsoft.Extensions.Configuration (>= 5.0.0)
- Microsoft.Extensions.Configuration.Abstractions (>= 5.0.0)
- Microsoft.Extensions.DependencyInjection (>= 5.0.2)
- Microsoft.Extensions.Hosting (>= 5.0.0)
- Microsoft.Extensions.Hosting.Abstractions (>= 5.0.0)
NuGet packages (6)
Showing the top 5 NuGet packages that depend on J4JSoftware.DependencyInjection:
Package | Downloads |
---|---|
J4JSoftware.GeoProcessor
a library for processing GPX, KML and KMZ files, and snapping GPS tracks to roadways |
|
J4JSoftware.WPFUtilities
utilities for console applications |
|
J4JSoftware.GeoProcessorApp
a console application for processing GPX, KML and KMZ files, and snapping GPS tracks to roadways |
|
J4JSoftware.GeoProcessorWPF
a WPF application for processing GPX, KML and KMZ files, and snapping GPS tracks to roadways |
|
J4JSoftware.DeusWinApp
provides J4JDeusEx support for Windows Apps (WinUI 3) |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.6.0 | 204 | 5/2/2023 |
2.5.1 | 217 | 4/11/2023 |
2.5.0 | 196 | 4/4/2023 |
2.4.0 | 306 | 1/15/2023 |
2.3.3 | 299 | 1/8/2023 |
2.3.2 | 300 | 1/8/2023 |
2.3.1 | 293 | 1/1/2023 |
2.3.0 | 292 | 12/27/2022 |
2.2.0 | 441 | 2/28/2022 |
2.1.1 | 569 | 11/21/2021 |
2.1.0 | 304 | 11/12/2021 |
2.0.1 | 930 | 9/29/2021 |
2.0.0 | 1,024 | 9/28/2021 |
1.1.0 | 1,017 | 2/3/2021 |
1.0.0 | 439 | 1/21/2021 |
0.8.0 | 373 | 1/9/2021 |
added nuget readme