百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
A

AutoDI

> 编程语言
开源

依赖注入变得简单。

99 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

依赖注入变得简单。

AutoDI

Have a question?

AutoDI is both a dependency injection container and a framework to simplify working with dependency injection (DI). It is built on top of the Microsoft.Extensions.DependencyInjection.Abstractions library, and it works very similar to the way ASP.NET Core handles dependency injection.

AutoDI delivers delivers two excellent features:

  1. It is built on Microsoft.Extensions.DependencyInjection.Abstractions library to bring the same flavor of dependency injection enjoyed on ASP.NET Core to other platforms (.NET Framework, WPF, Xamarin, UWP, etc).
  2. It generates container registrations at compile time using conventions (of course you can also add more at run-time as well).

See the wiki for more details or check out the Quick Start page to get up and running fast.

Why do I need this?

The goal of this library is to make dependency injection as simple as adding a NuGet package.

In addition to standard constructor dependency injection, it also allows optional constructor parameters that will be resolved when the constructor is invoked.

In a typical DI setup, you can often find objects needing to take in dependencies that the object itself is not using, but needs them to pass into some other object. The bigger and deeper the object model gets, the worse this becomes. As a specific example, imagine you are inside of class Foo and wish to create an instance of Bar, but Bar has a dependency on IService. In many cases, one of several options can be used:

  • Pass a facade to either the DI container or a factory that can create a Bar
  • Add a dependency on Foo to take in an IService so that when it needs to create a Bar it can simply pass the instance to Bar's constructor.

Though both these options work, they add additional effort. After all, in many cases, when we want a Bar we simply call new Bar();. AutoDI lets you write exactly that, and moves the dependency resolution inside of Bar's constructor. This dependency resolution is then forwarded to the DI container to resolve it.

Does it work with ?

Probably. Take a look at the AutoDI.Examples repository for samples. There are examples of adding support for other DI containers as well as simple examples for most frameworks.

Don't see your favorite listed? I accept PRs.

Icon

Needle designed by Austin Andrews from Material Design Icons

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

C#dependency-injectiondependency-resolutiondi-containerfody

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言