SimpleDependencyResolver 1.0.0
.NET 9.0
This package targets .NET 9.0. The package is compatible with this framework or higher.
.NET Standard 2.1
This package targets .NET Standard 2.1. The package is compatible with this framework or higher.
dotnet add package SimpleDependencyResolver --version 1.0.0
NuGet\Install-Package SimpleDependencyResolver -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="SimpleDependencyResolver" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SimpleDependencyResolver" Version="1.0.0" />
<PackageReference Include="SimpleDependencyResolver" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SimpleDependencyResolver --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SimpleDependencyResolver, 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.
#addin nuget:?package=SimpleDependencyResolver&version=1.0.0
#tool nuget:?package=SimpleDependencyResolver&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
SimpleDependencyResolver
A lightweight library for dependency registration using annotation attributes in .NET.
📝 Description
SimpleDependencyResolver enables dependency registration through attributes, simplifying your DI container setup. The project is split into two packages:
- SimpleDependencyResolver: Core library with resolver implementation
- SimpleDependencyResolver.Abstractions: Contains only attributes, suitable for class libraries without unnecessary dependencies
✨ Features
- Automatic dependency registration
- Support for different lifetimes:
- Transient
- Scoped
- Singleton
- Keyed services support for .NET 8+
- Compatible with .NET Standard 2.1 and higher
- Separated abstractions for class libraries
🚀 Installation
For projects implementing services:
dotnet add package SimpleDependencyResolver.Abstractions
For projects that need to register dependencies:
dotnet add package SimpleDependencyResolver
📋 Usage
- In your class library, add the abstractions reference and use attributes:
using SimpleDependencyResolver.Attributes;
[Scoped]
public class MyService : IMyService
{
public string GetData() => "Hello from MyService";
}
- In your startup project, add the main reference and register the resolver:
using SimpleDependencyResolver;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSimpleDependencyResolver();
- Alternatively, you can register the resolver with a specific assembly:
using SimpleDependencyResolver;
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSimpleDependencyResolver(Assembly.GetExecutingAssembly());
Using Keyed Services (.NET 8+)
[Scoped(ServiceKey = "primary")]
public class PrimaryService : IMyService
{
public string GetData() => "Primary Service";
}
[Scoped(ServiceKey = "secondary")]
public class SecondaryService : IMyService
{
public string GetData() => "Secondary Service";
}
// Inject using IKeyedServiceProvider
public class Consumer
{
private readonly IMyService _primaryService;
public Consumer([FromKeyedServices("primary")] IMyService service)
{
_primaryService = service;
}
}
🧩 Examples
Check the samples/SampleApi
project for a complete implementation example.
📄 License
This project is licensed under the Apache License 2.0.
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. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.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
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 3.1.32)
- SimpleDependencyResolver.Attributes (>= 1.0.0)
-
net9.0
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 9.0.0)
- SimpleDependencyResolver.Attributes (>= 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 | 105 | 3 months ago |