Class HandlerServicesDescriptor
- Namespace
- Savvyio
- Assembly
- Savvyio.Core.dll
Provides information, in a developer friendly way, about implementations of the IHandler<TRequest> interface such as name, declared members and what type of request they handle.
public class HandlerServicesDescriptor : IHandlerServicesDescriptor
- Inheritance
-
HandlerServicesDescriptor
- Implements
Examples
HandlerServicesDescriptor produces a human-readable handler discovery report. Create it with the service groups and types from the DI container or empty collections for diagnostics, then call ToString() to get the formatted report.
using System;
using System.Collections.Generic;
using System.Linq;
using Savvyio;
using Savvyio.Handlers;
namespace ExampleApp;
public sealed class HandlerServicesDescriptorExample
{
public static void PrintReport()
{
var emptyGroups = Enumerable.Empty<IGrouping<Type, KeyValuePair<Type, List<Cuemon.Extensions.Runtime.IHierarchy<object>>>>>();
var descriptor = new HandlerServicesDescriptor(emptyGroups, new[] { typeof(IHandler<IRequest>) });
Console.WriteLine(descriptor.ToString());
}
}
Remarks
An example of the output available when calling ToString():
Discovered 1 ICommandHandler implementation covering a total of 5 ICommand methods
Assembly: Savvyio.Assets.Tests
Namespace: Savvyio.Assets
<AccountCommandHandler>
*UpdateAccount --> &<RegisterDelegates>b__5_0
*CreateAccount --> &CreateAccountAsync
Constructors
HandlerServicesDescriptor(IEnumerable<IGrouping<Type, KeyValuePair<Type, List<IHierarchy<object>>>>>, IEnumerable<Type>)
Initializes a new instance of the HandlerServicesDescriptor class.
public HandlerServicesDescriptor(IEnumerable<IGrouping<Type, KeyValuePair<Type, List<IHierarchy<object>>>>> discoveredServices, IEnumerable<Type> serviceTypes)
Parameters
discoveredServicesIEnumerable<IGrouping<Type, KeyValuePair<Type, List<IHierarchy<object>>>>>The discovered implementations of the IHandler<TRequest> interface.
serviceTypesIEnumerable<Type>The registered IHandler<TRequest> service types.
Methods
GenerateHandlerDiscoveries()
Generates the handler discoveries.
public IEnumerable<HandlerDiscoveryModel> GenerateHandlerDiscoveries()
Returns
- IEnumerable<HandlerDiscoveryModel>
A collection of HandlerDiscoveryModel representing the handler discoveries.
ToString()
Returns a string that represents this instance.
public override string ToString()