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

            sliceWriter.Write(str);

            return(sliceWriter.CreateSlice());
        }
Example #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));
        }
Example #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());
        }
Example #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));
        }