public static void SerializeObject <T>(T value, TextWriter textWriter, JsonFormatterOptions options)
        {
            using (var jsonSerializer = CreateJsonSerializer(options))
            {
                ValueInterface <T> .WriteValue((IValueWriter)jsonSerializer, value);

                VersionDifferences.WriteChars(
                    textWriter,
                    jsonSerializer.hGlobal.GetPointer(),
                    jsonSerializer.StringLength);
            }
        }
        public static void SerializeObject <T>(T value, TextWriter textWriter)
        {
            using (var jsonSerializer = new JsonDefaultSerializer(DefaultMaxDepth)
            {
                textWriter = textWriter
            })
            {
                ValueInterface <T> .WriteValue(jsonSerializer, value);

                VersionDifferences.WriteChars(
                    textWriter,
                    jsonSerializer.hGlobal.GetPointer(),
                    jsonSerializer.StringLength);
            }
        }
Esempio n. 3
0
        private void InternalExpand(int expandMinSize)
        {
            if (hGlobal.Count == HGlobalCache <char> .MaxSize && textWriter != null && offset != 0)
            {
                VersionDifferences.WriteChars(textWriter, hGlobal.GetPointer(), offset);

                offset = 0;

                Expand(expandMinSize);
            }
            else
            {
                hGlobal.Expand(expandMinSize);
            }
        }
        public void Serialize <T>(T value, TextWriter textWriter)
        {
            using (var jsonSerializer = CreateJsonSerializer())
            {
                if (id != 0)
                {
                    jsonSerializer.jsonFormatter = this;
                }

                ValueInterface <T> .WriteValue((IValueWriter)jsonSerializer, value);

                VersionDifferences.WriteChars(
                    textWriter,
                    jsonSerializer.hGlobal.GetPointer(),
                    jsonSerializer.StringLength);
            }
        }
Esempio n. 5
0
        public void Expand(int expandMinSize)
        {
Loop:
            if (hGlobal.count - offset < expandMinSize)
            {
                if (hGlobal.count == HGlobalCache.MaxSize && textWriter != null && offset != 0)
                {
                    VersionDifferences.WriteChars(textWriter, hGlobal.chars, offset);

                    offset = 0;

                    goto Loop;
                }
                else
                {
                    hGlobal.Expand(expandMinSize);
                }
            }
        }
Esempio n. 6
0
 public void WriteTo(TextWriter textWriter)
 {
     VersionDifferences.WriteChars(textWriter, hGlobal.chars, offset - 1);
 }