Table of Contents

Class HandlerDiscoveryModel

Namespace
Savvyio
Assembly
Savvyio.Core.dll

Represents a model for handler services discovery.

public record HandlerDiscoveryModel : IEquatable<HandlerDiscoveryModel>
Inheritance
HandlerDiscoveryModel
Implements

Examples

This example shows how to create a handler discovery model from the grouped service output that a descriptor consumes.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Cuemon.Extensions.Runtime;
using Savvyio;
using Savvyio.Commands;

namespace ExampleApp;

public sealed class HandlerDiscoveryModelExample
{
    public HandlerDiscoveryModel Create()
    {
        var group = new Grouping<Type, KeyValuePair<Type, List<IHierarchy<object>>>>(typeof(ICommandHandler), new List<KeyValuePair<Type, List<IHierarchy<object>>>>());
        return new HandlerDiscoveryModel(typeof(ICommandHandler), typeof(ICommand), group);
    }
}

internal sealed class Grouping<TKey, TElement> : IGrouping<TKey, TElement>
{
    private readonly IEnumerable<TElement> _elements;
    public Grouping(TKey key, IEnumerable<TElement> elements) { Key = key; _elements = elements; }
    public TKey Key { get; }
    public IEnumerator<TElement> GetEnumerator() => _elements.GetEnumerator();
    IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}

Constructors

HandlerDiscoveryModel(Type, Type, IGrouping<Type, KeyValuePair<Type, List<IHierarchy<object>>>>)

Initializes a new instance of the HandlerDiscoveryModel class.

public HandlerDiscoveryModel(Type handlerAbstractionType, Type delegateAbstractionType, IGrouping<Type, KeyValuePair<Type, List<IHierarchy<object>>>> groupHandlers)

Parameters

handlerAbstractionType Type

The Type of the handler abstraction.

delegateAbstractionType Type

The Type of the delegate abstraction.

groupHandlers IGrouping<Type, KeyValuePair<Type, List<IHierarchy<object>>>>

The implementations of the IHandler<TRequest> interface.

Properties

AbstractionType

Gets the name of the handler abstraction.

public string AbstractionType { get; init; }

Property Value

string

Assemblies

Gets the assemblies containing the handler implementations.

public IEnumerable<HandlerServiceAssemblyModel> Assemblies { get; init; }

Property Value

IEnumerable<HandlerServiceAssemblyModel>

DelegateType

Gets the name of the delegate abstraction.

public string DelegateType { get; init; }

Property Value

string

DelegatesCount

Gets the count of handler implementations delegates.

public int DelegatesCount { get; init; }

Property Value

int

ImplementationsCount

Gets the count of handler implementations.

public int ImplementationsCount { get; init; }

Property Value

int