Git Product home page Git Product logo

katalogo's Introduction

Katalogo Build status

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 Assembly scanning and decoration extensions for Microsoft.Extensions.DependencyInjection.

Installation

Install the Katalogo NuGet Package. Nuget

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.

  public interface ITest
    {
        void Hello();
    }

    public class Test : ITest
    {
        public void Hello()
        {

        }
    }

    public class TestCatalog : Catalog
    {
        public TestCatalog(IServiceCollection services) : base(services)
        {
            services.AddTransient<ITest, Test>();
        }
    }

In your startup or whatever entry point you use to wire up your ServiceCollection you can do the following.

    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:

    IServiceCollection services = new ServiceCollection();
    services.RegisterCatalog<TestCatalog>();

katalogo's People

Contributors

suddenelfilio avatar dependabot-preview[bot] avatar jtone123 avatar azure-pipelines[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.