Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/suddenelfilio/katalogo
An extension for Microsoft.DependencyInjection to define a set of registrations as a Catalog
https://github.com/suddenelfilio/katalogo
Last synced: about 2 months ago
JSON representation
An extension for Microsoft.DependencyInjection to define a set of registrations as a Catalog
- Host: GitHub
- URL: https://github.com/suddenelfilio/katalogo
- Owner: suddenelfilio
- License: mit
- Created: 2018-11-15T21:38:32.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-11-28T10:55:42.000Z (about 1 year ago)
- Last Synced: 2024-12-08T12:42:18.480Z (2 months ago)
- Language: C#
- Size: 53.7 KB
- Stars: 4
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Katalogo ![Build status](https://visuasoft.visualstudio.com/Katalogo/_apis/build/status/Katalogo-CI)
> Katalogo - Esperanto for Catalog
Assembly scanning and catalog support for Microsoft.Extensions.DependencyInjection. This allows you to define a Catalog in your projects which allows you to create a set of service registrations.
This technique resembles the Registry in Structuremap and Module in Autofac.**This project was inspired by the [Scrutor Library by Kristian Hellang](https://github.com/khellang/Scrutor) Assembly scanning and decoration extensions for Microsoft.Extensions.DependencyInjection.**
## Installation
Install the [Katalogo NuGet Package](https://www.nuget.org/packages/Katalogo). ![Nuget](https://visuasoft.vsrm.visualstudio.com/_apis/public/Release/badge/69cf96b0-9d30-43a0-b25c-220436a53866/1/1)
### Package Manager Console
```
Install-Package Katalogo
```### .NET Core CLI
```
dotnet add package Katalogo
```## Usage
The library adds two extension methods to `IServiceCollection`:
* `Scan` - This is the entry point to set up your assembly scanning to search for classes deriving from Catalog.
* `RegisterCatalog` - This method is used to register a catalog directly without assembly scanning.See **Examples** below for usage examples.
## Examples
### Scanning
In your project you create a public class deriving from Catalog.
```csharp
public interface ITest
{
void Hello();
}public class Test : ITest
{
public void Hello()
{}
}public class TestCatalog : Catalog
{
public TestCatalog(IServiceCollection services) : base(services)
{
services.AddTransient();
}
}
```In your startup or whatever entry point you use to wire up your ServiceCollection you can do the following.
```csharp
IServiceCollection services = new ServiceCollection();services.Scan(scan => scan.FromCallingAssembly().RegisterCatalogs());
```This will register all classes deriving from Catalog into your ServiceCollection that are in the Calling Assembly.
### Direct registration
You can also register your Catalog directly the following way:```csharp
IServiceCollection services = new ServiceCollection();
services.RegisterCatalog();
```