Dependapult 1.0.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Dependapult --version 1.0.0
NuGet\Install-Package Dependapult -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="Dependapult" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Dependapult --version 1.0.0
#r "nuget: Dependapult, 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 Dependapult as a Cake Addin
#addin nuget:?package=Dependapult&version=1.0.0

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

Dependapult

Simple dependency injection library for .NET 6

What is it?

It is a minimal dependency injection library to register all of your dependencies.

Features

  • Two object lifetimes: transient and singleton;
  • Convenient methods to register singleton or transient dependencies;
  • Transient dependency implementation can be replaced;
  • Singletons and the service itself uses lazy loading to save memory;

Usage

Here are some typical scenarios when using Dependapult to show the useage of the service.

Getting Dependapult service object

DependapultService service = DependapultService.Instance;

Registering a dependency without providing arguments

// Manually provide lifetime
service.RegisterDependency<IDependency, Dependency>(DependencyLifetime.Singleton);

// Singleton convenience method
service.RegisterSingleton<IDependency, Dependency>();

// Transient convenience method
service.RegisterTransient<IDependency, Dependency>();

Registering a dependency and providing arguments

object[] arguments = new object[] { "config", 150, false };

// Manually provide lifetime
service.RegisterDependency<IDependency, Dependency>(DependencyLifetime.Singleton, arguments);

// Singleton convenience method
service.RegisterSingleton<IDependency, Dependency>(arguments);

// Transient convenience method
service.RegisterTransient<IDependency, Dependency>(arguments);

Registering a dependency and providing a creator function

// Manually provide lifetime
service.RegisterDependency<IDependency>(DependencyLifetime.Singleton, s => new Dependency(s.GetDependency<IOtherDependency>(), 200));

// Singleton convenience method
service.RegisterSingleton<IDependency>(s => new Dependency(s.GetDependency<IOtherDependency>(), 200));

// Transient convenience method
service.RegisterTransient<IDependency>(s => new Dependency(s.GetDependency<IOtherDependency>(), 200));

Replacing a dependency

// Manually provide lifetime
service.RegisterDependency<IDependency, Dependency>(DependencyLifetime.Transient, true);

// Transient convenience method
service.RegisterTransient<IDependency, Dependency>(true);

Getting a dependency

// With generics
IDependency dependency = service.GetDependency<IDependency>();

// Without generics
IDependency dependency = service.GetDependency(typeof(IDependency)) as IDependency;

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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.
  • net6.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.1 395 5/1/2022
1.0.0 382 4/20/2022

Changelog.md