Skip to content

hosseinghaheri/HG.EasyDi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HG.EasyDi

🧩 HG.EasyDi is a lightweight dependency injection library for ASP.NET Core.

Features

✨ Easy integration with ASP.NET Core applications.

✨ Attribute-based service registration.

✨ Support for singleton, scoped, and transient lifetimes.

✨ Automatic scanning of namespaces for service registration.

🔥 Installation

You can install the HG.EasyDi package via NuGet package manager or by adding it directly to your project file.

dotnet add package HG.EasyDi

🪧 Usage

Define your services and interfaces:

public interface ISampleService
{
    void DoSomething();
}

[EasyDi(ServiceLifetime.Singleton)]
public class SampleService : ISampleService
{
    public void DoSomething()
    {
        // Implementation code here
    }
}

For register service as Lazy Proxy use :

[EasyDi(ServiceLifetime.Singleton, true)]
or 
[LazyDi(ServiceLifetime.Singleton)]

Register services in your Program.cs file:

Full Scan:

builder.Services.AddEasyDi();

Scan special namespace:

builder.Services.AddEasyDi(o=>o.SetNamespaceRootToScan("HG.EasyDi.PlantTest.Service"));

Inject and use the services in your controllers or other classes:

public class SampleController : ControllerBase
{
    private readonly ISampleService _sampleService;

    public SampleController(ISampleService sampleService)
    {
        _sampleService = sampleService;
    }

    // Controller actions
}

🤝 Contributing

Contributions are welcome! If you find a bug or have a feature suggestion, please open an issue on the GitHub repository.

📝 License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages