Пример #1
0
 // constructors
 /// <summary>
 /// Initializes a new instance of the JsonWriter class.
 /// </summary>
 /// <param name="writer">A TextWriter.</param>
 /// <param name="settings">Optional JsonWriter settings.</param>
 public JsonWriter(TextWriter writer, JsonWriterSettings settings)
     : base(settings)
 {
     _textWriter = writer;
     _jsonWriterSettings = settings; // already frozen by base class
     _context = new JsonWriterContext(null, ContextType.TopLevel, "");
     State = BsonWriterState.Initial;
 }
Пример #2
0
        // constructors
        /// <summary>
        /// Initializes a new instance of the JsonWriter class.
        /// </summary>
        /// <param name="writer">A TextWriter.</param>
        /// <param name="settings">Optional JsonWriter settings.</param>
        public JsonWriter(TextWriter writer, JsonWriterSettings settings)
            : base(settings)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            _textWriter         = writer;
            _jsonWriterSettings = settings; // already frozen by base class
            _context            = new JsonWriterContext(null, ContextType.TopLevel, "");
            State = BsonWriterState.Initial;
        }
Пример #3
0
        // constructors
        /// <summary>
        /// Initializes a new instance of the JsonWriter class.
        /// </summary>
        /// <param name="writer">A TextWriter.</param>
        /// <param name="settings">Optional JsonWriter settings.</param>
        public JsonWriter(TextWriter writer, JsonWriterSettings settings)
            : base(settings)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            _textWriter = writer;
            _jsonWriterSettings = settings; // already frozen by base class
            _context = new JsonWriterContext(null, ContextType.TopLevel, "");
            State = BsonWriterState.Initial;
        }
Пример #4
0
        // protected methods
        /// <summary>
        /// Creates a clone of the settings.
        /// </summary>
        /// <returns>A clone of the settings.</returns>
        protected override BsonWriterSettings CloneImplementation()
        {
            var clone = new JsonWriterSettings
            {
                CloseOutput = _closeOutput,
#pragma warning disable 618
                Encoding = _encoding,
#pragma warning restore
                GuidRepresentation    = GuidRepresentation,
                Indent                = _indent,
                IndentChars           = _indentChars,
                MaxSerializationDepth = MaxSerializationDepth,
                NewLineChars          = _newLineChars,
                OutputMode            = _outputMode,
                ShellVersion          = _shellVersion
            };

            return(clone);
        }
Пример #5
0
 /// <summary>
 /// Creates a BsonWriter to a JSON TextWriter.
 /// </summary>
 /// <param name="writer">A TextWriter.</param>
 /// <param name="settings">Optional JsonWriterSettings.</param>
 /// <returns>A BsonWriter.</returns>
 public static BsonWriter Create(TextWriter writer, JsonWriterSettings settings)
 {
     return(new JsonWriter(writer, settings));
 }
        // protected methods
        /// <summary>
        /// Creates a clone of the settings.
        /// </summary>
        /// <returns>A clone of the settings.</returns>
        protected override BsonWriterSettings CloneImplementation()
        {
            var clone = new JsonWriterSettings
            {
                CloseOutput = _closeOutput,
#pragma warning disable 618
                Encoding = _encoding,
#pragma warning restore
                GuidRepresentation = GuidRepresentation,
                Indent = _indent,
                IndentChars = _indentChars,
                MaxSerializationDepth = MaxSerializationDepth,
                NewLineChars = _newLineChars,
                OutputMode = _outputMode,
                ShellVersion = _shellVersion
            };
            return clone;
        }
Пример #7
0
 /// <summary>
 /// Creates a BsonWriter to a JSON TextWriter.
 /// </summary>
 /// <param name="writer">A TextWriter.</param>
 /// <param name="settings">Optional JsonWriterSettings.</param>
 /// <returns>A BsonWriter.</returns>
 public static BsonWriter Create(TextWriter writer, JsonWriterSettings settings)
 {
     return new JsonWriter(writer, settings);
 }