コード例 #1
0
        public void TryParseSuccess(string value)
        {
            ReadOnlyFixedBytes v;
            int length;

            Assert.True(ReadOnlyFixedBytes.TryParse(value, out v, out length), value);
            Assert.Equal(value.Length / 2, length);
        }
コード例 #2
0
        public void TryParseFail(string value)
        {
            ReadOnlyFixedBytes v;
            int length;

            Assert.False(ReadOnlyFixedBytes.TryParse(value, out v, out length));
            Assert.Equal(0, length);
        }
コード例 #3
0
        /// <summary>
        ///     Try to parse the serialized form.
        /// </summary>
        public static bool TryParse(string serialized, out Fingerprint value)
        {
            if (!ReadOnlyFixedBytes.TryParse(serialized, out var v, out var length))
            {
                value = default(Fingerprint);
                return(false);
            }

            if (length == 0 || length > MaxLength)
            {
                value = default(Fingerprint);
                return(false);
            }

            value = new Fingerprint(v, length);
            return(true);
        }