Esempio n. 1
0
        /// <summary>
        /// Creates an instance of the <c>JsonWriter</c> class using the specified <see cref="TextWriter"/>.
        /// </summary>
        /// <param name="textWriter">The <c>TextWriter</c> to write to.</param>
        public JsonWriter(TextWriter textWriter, int maxJsonLength)
        {
            if (textWriter == null)
            {
                throw new ArgumentNullException("textWriter");
            }

            if (maxJsonLength > 0)
            {
                textWriter = new CountingTextWriter(textWriter, maxJsonLength);
            }

            _writer      = textWriter;
            _quoteChar   = '"';
            _quoteName   = true;
            _indentChar  = ' ';
            _indentation = 2;
            _formatting  = Formatting.None;
            _stack       = new List <JsonType> (1);
            _stack.Add(JsonType.None);
            _currentState = State.Start;
        }
Esempio n. 2
0
        /// <summary>
        /// Creates an instance of the <c>JsonWriter</c> class using the specified <see cref="TextWriter"/>. 
        /// </summary>
        /// <param name="textWriter">The <c>TextWriter</c> to write to.</param>
        public JsonWriter(TextWriter textWriter, int maxJsonLength)
        {
            if (textWriter == null)
                throw new ArgumentNullException ("textWriter");

            if (maxJsonLength > 0)
                textWriter = new CountingTextWriter (textWriter, maxJsonLength);

            _writer = textWriter;
            _quoteChar = '"';
            _quoteName = true;
            _indentChar = ' ';
            _indentation = 2;
            _formatting = Formatting.None;
            _stack = new List<JsonType> (1);
            _stack.Add (JsonType.None);
            _currentState = State.Start;
        }