Bindicate
An autowiring library for .NET.
Install / Use
/learn @Tim-Maes/BindicateREADME
'A blend of "Bind" and "Indicate"'.
Features 🌟
- Automatic registration of (keyed) services using custom attributes.
- Automatic registration and configuration of options via
IOptions<T>. - Provides clear visibility and reduces boilerplate code.
- Simple integration with the built-in .NET IoC container.
- Supports Decorators
Supported types
<center>| Type | Available | Keyed (.NET 8) | Decorators |Interceptors | Activators | |--------------------|----------|------------------------------|---------|------------|------------| |AddTransient |✔️ |✔️ | ✔️|❌ |❌ | |TryAddTransient |✔️ |❌ | ❌| ❌|❌ | |AddScoped |✔️ |✔️ |✔️ | ❌| ❌| |TryAddScoped |✔️ |❌ |❌ |❌ |❌ | |AddSingleton |✔️ |✔️ | ✔️| ❌| ❌| |TryAddSingleton |✔️ |❌ |❌ |❌ |❌ | |TryAddEnumerable |✔️ |❌ | ❌| ❌|❌ |
</center>Installation 📦
Via NuGet
Install-Package Bindicate
or
dotnet add package Bindicate
Usage
You can check out the documentation for examples and more information on how to use Bindicate.
Quick overview
Add this line in a project to register all decorated services.
To also configure options, use .WithOptions().
You can also use the ServiceCollectionExtension pattern and use IConfiguration as a parameters for your extension method if they have options to register.
Example in host project
// Register all decorated services for the current assembly
builder.Services
.AddAutowiringForAssembly(Assembly.GetExecutingAssembly())
.Register();
// Also register Keyed Services (.NET 8)
builder.Services
.AddAutowiringForAssembly(Assembly.GetExecutingAssembly())
.ForKeyedServices()
.Register();
// Also register Options as IOptions<T>
builder.Services
.AddAutowiringForAssembly(Assembly.GetExecutingAssembly())
.ForKeyedServices()
.WithOptions(Configuration) //Pass builder.Configuration here
.Register();
Example usage
[AddScoped(typeof(IMyTaskRunner))]
public class TaskRunner : IMyTaskRunner
{
public void Run()
{
// ...
}
}
public interface IMyTaskRunner
{
void Run();
}
License
This project is licensed under the MIT license.
Related Skills
node-connect
352.0kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
111.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
352.0kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
352.0kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
