示例#1
0
 public bool TryWriteLine(string text, TransformationFormat format)
 {
     if (!TryWriteLine(text, out int written))
     {
         return(false);
     }
     if (!format.TryTransform(Free, ref written))
     {
         return(false);
     }
     _written += written;
     return(true);
 }
示例#2
0
        public bool TryWrite <T>(T value, TransformationFormat format) where T : IBufferFormattable
        {
            if (!value.TryFormat(Free, out int written, format.Format, SymbolTable.InvariantUtf8))
            {
                return(false);
            }

            if (format.TryTransform(Free, ref written))
            {
                _written += written;
                return(true);
            }
            return(false);
        }
示例#3
0
        public bool TryWriteBytes <T>(T value, TransformationFormat format) where T : IWritable
        {
            if (!value.TryWrite(Free, out int written, format.Format))
            {
                return(false);
            }

            if (format.TryTransform(Free, ref written))
            {
                _written += written;
                return(true);
            }

            return(false);
        }
示例#4
0
        public bool TryWrite(Utf8Span text, TransformationFormat format)
        {
            int written = text.Bytes.Length;

            if (!text.Bytes.TryCopyTo(Free))
            {
                return(false);
            }
            if (!format.TryTransform(Free, ref written))
            {
                return(false);
            }
            _written += written;
            return(true);
        }