コード例 #1
0
        public static bool TryReadGuid(ref ReadOnlySpan <byte> remaining, out Guid result, char standardFormat)
        {
            result = default;

            if (!TryReadUtf8Bytes(ref remaining, out var bytes))
            {
                return(false);
            }
            return(Utf8Reader.TryReadGuid(ref bytes, out result, standardFormat));
        }
コード例 #2
0
        public static bool TryReadGuid(ref ReadOnlySpan <byte> remaining, out Guid result, char standardFormat)
        {
            result = default;

            switch (GetTokenType(ref remaining))
            {
            case JsonTokenType.String:
                remaining = remaining.Slice(1);
                if (!Utf8Reader.TryReadGuid(ref remaining, out result, standardFormat))
                {
                    return(false);
                }
                if (remaining.Length == 0 || remaining[0] != '"')
                {
                    return(false);
                }
                remaining = remaining.Slice(1);
                return(true);
            }
            return(false);
        }