Skip to content

IServiceDiscovery

Ershad Raoufi- ارشاد رئوفی edited this page May 24, 2024 · 1 revision

Overview

packageName : ServiceCollector.Abstractions

IServiceDiscovery is an interface used in the ServiceCollector framework for defining service registration logic. Implementations of this interface are automatically discovered and invoked to add services to the IServiceCollection.

Interface Definition:

namespace ServiceCollector.Abstractions
{
    public interface IServiceDiscovery
    {
        void AddServices(IServiceCollection services);
    }
}

Purpose

The purpose of the IServiceDiscovery interface is to provide a standardized way to register services within an application. By implementing this interface, you can encapsulate the service registration logic and make it discoverable by the ServiceCollector lib.

Methods

void AddServices(IServiceCollection services);

Description:

This method is called by the ServiceCollector framework to register services. Implement this method to add your services to the provided IServiceCollection.

Parameters:

services: An instance of IServiceCollection where services should be registered.

Usage

Example Implementation

Define a Service Discovery Class: Implement the IServiceDiscovery interface to define the services you want to register.

using Microsoft.Extensions.DependencyInjection;
using ServiceCollector.Abstractions;

public class MyServiceDiscovery : IServiceDiscovery
{
    public void AddServices(IServiceCollection services)
    {
       // add your services ...
    }
}