Table of Contents

Class HandlerServiceTypeImplementationModel

Namespace
Savvyio
Assembly
Savvyio.Core.dll

Represents a model for handler service type implementations.

public record HandlerServiceTypeImplementationModel : IEquatable<HandlerServiceTypeImplementationModel>
Inheritance
HandlerServiceTypeImplementationModel
Implements

Examples

This example shows how to read implementation entries from the discovery report a handler descriptor produces.

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 HandlerServiceTypeImplementationModelExample
{
    public IEnumerable<string> ReadImplementationNames()
    {
        var descriptor = new HandlerServicesDescriptor(new[] { new Grouping<Type, KeyValuePair<Type, List<IHierarchy<object>>>>(typeof(ICommandHandler), new List<KeyValuePair<Type, List<IHierarchy<object>>>>()) }, new[] { typeof(ICommandHandler) });
        IEnumerable<HandlerServiceTypeImplementationModel> implementations = descriptor.GenerateHandlerDiscoveries().SelectMany(model => model.Assemblies ?? Array.Empty<HandlerServiceAssemblyModel>()).SelectMany(assembly => assembly.Implementations ?? Array.Empty<HandlerServiceTypeImplementationModel>());
        return implementations.Select(implementation => implementation.Name);
    }
}

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

HandlerServiceTypeImplementationModel(IHierarchy<object>, Type, Type)

Initializes a new instance of the HandlerServiceTypeImplementationModel class.

public HandlerServiceTypeImplementationModel(IHierarchy<object> node, Type handlerImplementationType, Type delegateAbstractionType)

Parameters

node IHierarchy<object>

The hierarchy node.

handlerImplementationType Type

The Type of the handler implementation.

delegateAbstractionType Type

The Type of the delegate abstraction.

Properties

Delegates

Gets the delegates of the handler implementation.

public IEnumerable<HandlerServiceTypeImplementationDelegatesModel> Delegates { get; init; }

Property Value

IEnumerable<HandlerServiceTypeImplementationDelegatesModel>

Name

Gets the name of the handler implementation.

public string Name { get; init; }

Property Value

string