Table of Contents

Class BsonWriter

Namespace
Newtonsoft.Json.Bson
Assembly
Newtonsoft.Json.dll

Represents a writer that provides a fast, non-cached, forward-only way of generating Json data.

public class BsonWriter : JsonWriter, IDisposable
Inheritance
BsonWriter
Implements
Inherited Members

Constructors

BsonWriter(BinaryWriter)

Initializes a new instance of the BsonWriter class.

public BsonWriter(BinaryWriter writer)

Parameters

writer BinaryWriter

The writer.

BsonWriter(Stream)

Initializes a new instance of the BsonWriter class.

public BsonWriter(Stream stream)

Parameters

stream Stream

The stream.

Properties

DateTimeKindHandling

Gets or sets the DateTimeKind used when writing DateTime values to BSON. When set to Unspecified no conversion will occur.

public DateTimeKind DateTimeKindHandling { get; set; }

Property Value

DateTimeKind

The DateTimeKind used when writing DateTime values to BSON.

Methods

Close()

Closes this stream and the underlying stream.

public override void Close()

Flush()

Flushes whatever is in the buffer to the underlying streams and also flushes the underlying stream.

public override void Flush()

WriteComment(string)

Writes out a comment

/.../
containing the specified text.
public override void WriteComment(string text)

Parameters

text string

Text to place inside the comment.

WriteEnd(JsonToken)

Writes the end.

protected override void WriteEnd(JsonToken token)

Parameters

token JsonToken

The token.

WriteNull()

Writes a null value.

public override void WriteNull()

WriteObjectId(byte[])

Writes a Byte[] value that represents a BSON object id.

public void WriteObjectId(byte[] value)

Parameters

value byte[]

WritePropertyName(string)

Writes the property name of a name/value pair on a Json object.

public override void WritePropertyName(string name)

Parameters

name string

The name of the property.

WriteRaw(string)

Writes raw JSON.

public override void WriteRaw(string json)

Parameters

json string

The raw JSON to write.

WriteRawValue(string)

Writes raw JSON where a value is expected and updates the writer's state.

public override void WriteRawValue(string json)

Parameters

json string

The raw JSON to write.

WriteRegex(string, string)

Writes a BSON regex.

public void WriteRegex(string pattern, string options)

Parameters

pattern string

The regex pattern.

options string

The regex options.

WriteStartArray()

Writes the beginning of a Json array.

public override void WriteStartArray()

WriteStartConstructor(string)

Writes the start of a constructor with the given name.

public override void WriteStartConstructor(string name)

Parameters

name string

The name of the constructor.

WriteStartObject()

Writes the beginning of a Json object.

public override void WriteStartObject()

WriteUndefined()

Writes an undefined value.

public override void WriteUndefined()

WriteValue(bool)

Writes a bool value.

public override void WriteValue(bool value)

Parameters

value bool

The bool value to write.

WriteValue(byte)

Writes a byte value.

public override void WriteValue(byte value)

Parameters

value byte

The byte value to write.

WriteValue(byte[])

Writes a Byte[] value.

public override void WriteValue(byte[] value)

Parameters

value byte[]

The Byte[] value to write.

WriteValue(char)

Writes a char value.

public override void WriteValue(char value)

Parameters

value char

The char value to write.

WriteValue(DateTime)

Writes a DateTime value.

public override void WriteValue(DateTime value)

Parameters

value DateTime

The DateTime value to write.

WriteValue(DateTimeOffset)

Writes a DateTimeOffset value.

public override void WriteValue(DateTimeOffset value)

Parameters

value DateTimeOffset

The DateTimeOffset value to write.

WriteValue(decimal)

Writes a decimal value.

public override void WriteValue(decimal value)

Parameters

value decimal

The decimal value to write.

WriteValue(double)

Writes a double value.

public override void WriteValue(double value)

Parameters

value double

The double value to write.

WriteValue(Guid)

Writes a Guid value.

public override void WriteValue(Guid value)

Parameters

value Guid

The Guid value to write.

WriteValue(short)

Writes a short value.

public override void WriteValue(short value)

Parameters

value short

The short value to write.

WriteValue(int)

Writes a int value.

public override void WriteValue(int value)

Parameters

value int

The int value to write.

WriteValue(long)

Writes a long value.

public override void WriteValue(long value)

Parameters

value long

The long value to write.

WriteValue(sbyte)

Writes a sbyte value.

[CLSCompliant(false)]
public override void WriteValue(sbyte value)

Parameters

value sbyte

The sbyte value to write.

WriteValue(float)

Writes a float value.

public override void WriteValue(float value)

Parameters

value float

The float value to write.

WriteValue(string)

Writes a string value.

public override void WriteValue(string value)

Parameters

value string

The string value to write.

WriteValue(TimeSpan)

Writes a TimeSpan value.

public override void WriteValue(TimeSpan value)

Parameters

value TimeSpan

The TimeSpan value to write.

WriteValue(ushort)

Writes a ushort value.

[CLSCompliant(false)]
public override void WriteValue(ushort value)

Parameters

value ushort

The ushort value to write.

WriteValue(uint)

Writes a uint value.

[CLSCompliant(false)]
public override void WriteValue(uint value)

Parameters

value uint

The uint value to write.

WriteValue(ulong)

Writes a ulong value.

[CLSCompliant(false)]
public override void WriteValue(ulong value)

Parameters

value ulong

The ulong value to write.

WriteValue(Uri)

Writes a System.Uri value.

public override void WriteValue(Uri value)

Parameters

value Uri

The System.Uri value to write.