~ruther/NosSmooth

ref: 03cada92bb7cd3914882704953b6f786fe557cfb NosSmooth/Core/NosSmooth.Packets/Converters/Basic/UIntStringConverter.cs -rw-r--r-- 706 bytes
03cada92 — František Boháček feat!: remove nossmooth core 3 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
//
//  UIntStringConverter.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 NosSmooth.Packets.Errors;
using Remora.Results;

namespace NosSmooth.Packets.Converters.Basic;

/// <summary>
/// Converter of <see cref="uint"/>.
/// </summary>
public class UIntStringConverter : BasicTypeConverter<uint>
{
    /// <inheritdoc />
    protected override Result<uint> Deserialize(string value)
    {
        if (!uint.TryParse(value, out var parsed))
        {
            return new CouldNotConvertError(this, value, "Could not parse as uint");
        }

        return parsed;
    }
}
Do not follow this link