~ruther/NosSmooth.Comms

ref: 7ae046c3dac7dbb68abb2e4ae4e13beed116feba NosSmooth.Comms/src/Local/NosSmooth.Comms.Local/Extensions/ServiceCollectionExtensions.cs -rw-r--r-- 1.1 KiB
7ae046c3 — Rutherther fix: register ConsoleResponder to services 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//
//  ServiceCollectionExtensions.cs
//
//  Copyright (c) František Boháček. All rights reserved.
//  Licensed under the MIT license. See LICENSE file in the project root for full license information.

using Microsoft.Extensions.DependencyInjection;
using NosSmooth.Comms.Core.Extensions;
using NosSmooth.Comms.Local.MessageResponders;
using NosSmooth.Injector;

namespace NosSmooth.Comms.Local.Extensions;

/// <summary>
/// Extension methods for <see cref="IServiceCollection"/>.
/// </summary>
public static class ServiceCollectionExtensions
{
    /// <summary>
    /// Add <see cref="CommsInjector"/>.
    /// </summary>
    /// <param name="serviceCollection">The service ocllection.</param>
    /// <returns>The same service collection.</returns>
    public static IServiceCollection AddLocalComms(this IServiceCollection serviceCollection)
    {
        return serviceCollection
            .AddMultiClientHandling()
            .AddMessageResponder<PacketResponder>()
            .AddMessageResponder<RawPacketResponder>()
            .AddSingleton<NosInjector>()
            .AddSingleton<CommsInjector>();
    }
}
Do not follow this link