~ruther/NosSmooth

0f53287c92a4a641524ec8a99abd849dc2612f59 — František Boháček 3 years ago 1a8de51
fix: bugs in packet types repository add packet
1 files changed, 6 insertions(+), 1 deletions(-)

M Core/NosSmooth.Packets/Packets/PacketTypesRepository.cs
M Core/NosSmooth.Packets/Packets/PacketTypesRepository.cs => Core/NosSmooth.Packets/Packets/PacketTypesRepository.cs +6 -1
@@ 43,7 43,7 @@ public class PacketTypesRepository : IPacketTypesRepository
    /// <returns>A result that may or may not have succeeded.</returns>
    public Result AddPacketType(Type type)
    {
        if (typeof(IPacket).IsAssignableFrom(type))
        if (!typeof(IPacket).IsAssignableFrom(type))
        {
            return new ArgumentInvalidError(nameof(type), "The type has to be assignable to IPacket.");
        }


@@ 74,6 74,11 @@ public class PacketTypesRepository : IPacketTypesRepository

        if (header.Identifier is not null)
        {
            if (!_headerToPacket.ContainsKey(header.Source))
            {
                _headerToPacket[header.Source] = new Dictionary<string, PacketInfo>();
            }

            if (_headerToPacket[header.Source].ContainsKey(header.Identifier))
            {
                return new AmbiguousHeaderError

Do not follow this link