示例#1
0
        public static Slice ToSliceUsingBuffer(this string str, byte[] buffer)
        {
            var sliceWriter = new SliceWriter(buffer);

            sliceWriter.Write(str);

            return(sliceWriter.CreateSlice());
        }
示例#2
0
        public static Slice ToSliceUsingBuffer(this string str, ByteStringContext context, byte[] buffer, ByteStringType type = ByteStringType.Mutable)
        {
            var sliceWriter = new SliceWriter(buffer);

            sliceWriter.Write(str);

            return(sliceWriter.CreateSlice(context, type));
        }
示例#3
0
        public static Slice ToSlice(this string str)
        {
            var size = Encoding.UTF8.GetByteCount(str);

            Debug.Assert(size <= ushort.MaxValue);

            var sliceWriter = new SliceWriter(size);

            sliceWriter.Write(str);

            return(sliceWriter.CreateSlice());
        }
示例#4
0
        public static Slice ToSlice(this string str, ByteStringContext context, ByteStringType type = ByteStringType.Mutable)
        {
            var size = Encoding.UTF8.GetByteCount(str);

            Debug.Assert(size <= ushort.MaxValue);

            var sliceWriter = new SliceWriter(size);

            sliceWriter.Write(str);

            return(sliceWriter.CreateSlice(context, type));
        }