示例#1
0
        public static bool TryFormat(this Guid value, Span <byte> buffer, out int bytesWritten, TextFormat format = default, SymbolTable symbolTable = null)
        {
            symbolTable = symbolTable ?? SymbolTable.InvariantUtf8;

            if (symbolTable == SymbolTable.InvariantUtf8)
            {
                return(InvariantUtf8GuidFormatter.TryFormat(value, buffer, out bytesWritten, format));
            }
            else if (symbolTable == SymbolTable.InvariantUtf16)
            {
                return(InvariantUtf16GuidFormatter.TryFormat(value, buffer, out bytesWritten, format));
            }
            else
            {
                throw new NotImplementedException();
            }
        }
        public static bool TryFormat(this Guid value, Span <byte> buffer, out int bytesWritten, TextFormat format = default(TextFormat), TextEncoder encoder = null)
        {
            encoder = encoder == null ? TextEncoder.Utf8 : encoder;

            if (encoder.IsInvariantUtf8)
            {
                return(InvariantUtf8GuidFormatter.TryFormat(value, buffer, out bytesWritten, format));
            }
            else if (encoder.IsInvariantUtf16)
            {
                return(InvariantUtf16GuidFormatter.TryFormat(value, buffer, out bytesWritten, format));
            }
            else
            {
                throw new NotImplementedException();
            }
        }