~ruther/NosSmooth.Local

ref: 69c46f6f0b73dd4475ee75d44f8783c9a45c262e NosSmooth.Local/src/Extensions/NosSmooth.Extensions.SharedBinding/SharedOptions.cs -rw-r--r-- 1.2 KiB
69c46f6f — Rutherther feat(shared): add sharing of NosSmooth hooks 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
34
35
36
37
38
39
40
41
42
43
44
45
//
//  SharedOptions.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.Data.NOSFiles;
using NosSmooth.LocalBinding;
using NosSmooth.PacketSerializer.Packets;

namespace NosSmooth.Extensions.SharedBinding;

/// <summary>
/// Options for <see cref="SharedManager"/>.
/// </summary>
internal class SharedOptions
{
    private Dictionary<Type, ServiceDescriptor> _descriptors = new();

    /// <summary>
    /// Add service descriptor for given type.
    /// </summary>
    /// <param name="descriptor">The service descriptor.</param>
    public void AddDescriptor(ServiceDescriptor descriptor)
    {
        var type = descriptor.ServiceType;
        if (_descriptors.ContainsKey(type))
        {
            return;
        }

        _descriptors[type] = descriptor;
    }

    /// <summary>
    /// Get descriptor for the given type.
    /// </summary>
    /// <param name="type">The type of the descriptor.</param>
    /// <returns>A descriptor.</returns>
    public ServiceDescriptor GetDescriptor(Type type)
    {
        return _descriptors[type];
    }
}
Do not follow this link