This is a lightweight Dependency Injection library that simplifies dependency management in your applications.
- 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
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!");
}
}