Thanks to visit codestin.com
Credit goes to github.com

Skip to content

xirzo/XirzoDIContainer

Repository files navigation

C# Last Commit

This is a lightweight Dependency Injection library that simplifies dependency management in your applications.

Features

  • Type Binding: Bind concrete types directly with BindType<T>()
  • Interface Binding: Map interfaces to implementations using Bind<T>().To<TImplementation>()
  • Instance Binding: Bind existing instances using ToInstance()
  • Factory Binding: Create custom instantiation logic with ToFactory()
  • Lifetimes:
    • Singleton: One instance for all resolutions
    • Transient: New instance per resolution

Usage

using XirzoDIContainer.Container;

var container = new ContainerDi();

container.Bind<IGreetingService>()
    .To<GreetingService>()
    .AsSingleton();

var service = container.Resolve<IGreetingService>();

service.Greet();

public interface IGreetingService
{
    void Greet();
}

public class GreetingService : IGreetingService
{
    public void Greet()
    {
        Console.WriteLine("Hello!");
    }
}

About

Lightweight Dependency Injection library

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages