Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Tim-Maes/Bindicate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

115 Commits

Repository files navigation

image

'A blend of "Bind" and "Indicate"'.

NuGet NuGet

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

Type Available Keyed (.NET 8) Decorators Interceptors Activators
AddTransient βœ”οΈ βœ”οΈ βœ”οΈ ❌ ❌
TryAddTransient βœ”οΈ ❌ ❌ ❌ ❌
AddScoped βœ”οΈ βœ”οΈ βœ”οΈ ❌ ❌
TryAddScoped βœ”οΈ ❌ ❌ ❌ ❌
AddSingleton βœ”οΈ βœ”οΈ βœ”οΈ ❌ ❌
TryAddSingleton βœ”οΈ ❌ ❌ ❌ ❌
TryAddEnumerable βœ”οΈ ❌ ❌ ❌ ❌

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.

Sponsor this project

Packages

Contributors

Languages

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /