Table of Contents

HandlerDiscoveryModel Class

Definition

Namespace
Savvyio
Assemblies
Savvyio.Core.dll
Source
src/Savvyio.Core/HandlerDiscoveryModel.cs

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

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

Initializes a new instance of the HandlerDiscoveryModel class.

Properties

Name Description
AbstractionType

Gets the name of the handler abstraction.

Assemblies

Gets the assemblies containing the handler implementations.

DelegateType

Gets the name of the delegate abstraction.

DelegatesCount

Gets the count of handler implementations delegates.

ImplementationsCount

Gets the count of handler implementations.