Dependo.LightInject
1.2.3
dotnet add package Dependo.LightInject --version 1.2.3
NuGet\Install-Package Dependo.LightInject -Version 1.2.3
<PackageReference Include="Dependo.LightInject" Version="1.2.3" />
<PackageVersion Include="Dependo.LightInject" Version="1.2.3" />
<PackageReference Include="Dependo.LightInject" />
paket add Dependo.LightInject --version 1.2.3
#r "nuget: Dependo.LightInject, 1.2.3"
#:package Dependo.LightInject@1.2.3
#addin nuget:?package=Dependo.LightInject&version=1.2.3
#tool nuget:?package=Dependo.LightInject&version=1.2.3
<img src="https://github.com/gordon-matt/Dependo/raw/master/_Misc/Logo.png" alt="Logo" width="250" />
Intro
Dependo is a library that let's you resolve dependencies from anywhere via a singleton call to DependoResolver.Instance. This is mostly useful for resolving dependencies in static classes, including extensions methods.
Additionally, there is an IDependencyRegistrar interface to let you register dependencies from anywhere, such as class libraries. If you need to take advantage of implementation-specific registration features, you can make use of the more specialized dependency registrar, such as IAutofacDependencyRegistrar, IDryIocDependencyRegistrar, etc.
Check the demo project for a clearer idea on how to use Dependo. Or for a more advanced example, see it being used in MantleCMS
NuGet Packages
| Package | Version | Downloads |
|---|---|---|
| Dependo | ||
| Dependo.Autofac | ||
| Dependo.DotNetDefault | ||
| Dependo.DryIoc | ||
| Dependo.Lamar | ||
| Dependo.LightInject |
Feature Support
The default .NET implementation suits most needs. You could start with that and then if more advanced features are required, simply swap out that implementation for another. Use the following table to help decide which is most suitable for your project.
| Method | Default .NET DI | Autofac | DryIoc | Lamar | LightInject |
|---|---|---|---|---|---|
IsRegistered(Type serviceType) |
✅ | ✅ | ✅ | ✅ | ✅ |
Resolve<T>() |
✅ | ✅ | ✅ | ✅ | ✅ |
Resolve<T>(IDictionary<string, object> ctorArgs) |
❌ | ✅ | ✅ | ❌ | ❌ |
object Resolve(Type type) |
✅ | ✅ | ✅ | ✅ | ✅ |
T ResolveKeyed<T>(object key) |
✅ | ✅ | ✅ | ✅ | ✅ |
T ResolveKeyed<T>(object key, IDictionary<string, object> ctorArgs) |
❌ | ✅ | ✅ | ❌ | ❌ |
IEnumerable<T> ResolveAllKeyed<T>(object key) |
✅ | ✅ | ❌ | ❌ | ❌ |
IEnumerable<T> ResolveAll<T>() |
✅ | ✅ | ✅ | ✅ | ✅ |
IEnumerable<T> ResolveAllNamed<T> |
✅ | ✅ | ❌ | ❌ | ❌ |
T ResolveNamed<T>(string name) |
✅ | ✅ | ✅ | ✅ | ✅ |
T? ResolveUnregistered<T>() |
✅ | ✅ | ✅ | ✅ | ✅ |
object ResolveUnregistered(Type type) |
✅ | ✅ | ✅ | ✅ | ✅ |
bool TryResolve<T>(out T? instance) |
✅ | ✅ | ✅ | ✅ | ✅ |
bool TryResolve(Type serviceType, out object? instance) |
✅ | ✅ | ✅ | ✅ | ✅ |
Credits
I based the original version of this project on some code found in an old version of nopCommerce. They only used Autofac; I wanted it to be more generic for use in projects where the IOC container may need to be swapped out for another implementation.
Support
If you find this project useful, consider supporting its development.
<p align="center"> <a href="https://buymeacoffee.com/vnmatt"> <img src="https://github.com/gordon-matt/MyResume/blob/gh-pages/assets/images/BuyMeACoffee_Logo.png" alt="Buy Me a Coffee" height="40"> </a> <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=gordon_matt%40live%2ecom&lc=AU¤cy_code=AUD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted"> <img src="https://github.com/gordon-matt/MyResume/blob/gh-pages/assets/images/PayPal_Logo.png" alt="Donate with PayPal" height="40"> </a> </p>
<p align="center"> Prefer using your phone? Scan the QR code: </p>
<p align="center"> <a href="https://buymeacoffee.com/vnmatt"> <img src="https://github.com/gordon-matt/MyResume/blob/gh-pages/assets/images/BuyMeACoffee_QR.png" alt="Buy Me a Coffee QR Code" width="180"> </a> </p>
<img src="https://komarev.com/ghpvc/?username=gordon-matt&label=GitHub%20Hits%20Since%202025-06-01%3A%20&color=ff0000&style=flat" alt="gordon-matt" />
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Dependo (>= 1.2.3)
- Extenso.Core (>= 10.2.1)
- LightInject (>= 7.1.1)
- LightInject.Microsoft.DependencyInjection (>= 4.1.2)
- LightInject.Microsoft.Hosting (>= 2.3.0)
- Microsoft.Extensions.DependencyInjection (>= 10.0.14)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Dependo.LightInject:
| Package | Downloads |
|---|---|
|
MantleFramework.Infrastructure.LightInject
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.