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
BinaryWriterThe writer.
BsonWriter(Stream)
Initializes a new instance of the BsonWriter class.
public BsonWriter(Stream stream)
Parameters
stream
StreamThe 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
stringText to place inside the comment.
WriteEnd(JsonToken)
Writes the end.
protected override void WriteEnd(JsonToken token)
Parameters
token
JsonTokenThe 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
stringThe name of the property.
WriteRaw(string)
Writes raw JSON.
public override void WriteRaw(string json)
Parameters
json
stringThe 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
stringThe raw JSON to write.
WriteRegex(string, string)
Writes a BSON regex.
public void WriteRegex(string pattern, string options)
Parameters
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
stringThe 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
WriteValue(byte)
Writes a byte value.
public override void WriteValue(byte value)
Parameters
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
WriteValue(DateTime)
Writes a DateTime value.
public override void WriteValue(DateTime value)
Parameters
WriteValue(DateTimeOffset)
Writes a DateTimeOffset value.
public override void WriteValue(DateTimeOffset value)
Parameters
value
DateTimeOffsetThe DateTimeOffset value to write.
WriteValue(decimal)
Writes a decimal value.
public override void WriteValue(decimal value)
Parameters
WriteValue(double)
Writes a double value.
public override void WriteValue(double value)
Parameters
WriteValue(Guid)
Writes a Guid value.
public override void WriteValue(Guid value)
Parameters
WriteValue(short)
Writes a short value.
public override void WriteValue(short value)
Parameters
WriteValue(int)
Writes a int value.
public override void WriteValue(int value)
Parameters
WriteValue(long)
Writes a long value.
public override void WriteValue(long value)
Parameters
WriteValue(sbyte)
Writes a sbyte value.
[CLSCompliant(false)]
public override void WriteValue(sbyte value)
Parameters
WriteValue(float)
Writes a float value.
public override void WriteValue(float value)
Parameters
WriteValue(string)
Writes a string value.
public override void WriteValue(string value)
Parameters
WriteValue(TimeSpan)
Writes a TimeSpan value.
public override void WriteValue(TimeSpan value)
Parameters
WriteValue(ushort)
Writes a ushort value.
[CLSCompliant(false)]
public override void WriteValue(ushort value)
Parameters
WriteValue(uint)
Writes a uint value.
[CLSCompliant(false)]
public override void WriteValue(uint value)
Parameters
WriteValue(ulong)
Writes a ulong value.
[CLSCompliant(false)]
public override void WriteValue(ulong value)
Parameters
WriteValue(Uri)
Writes a System.Uri value.
public override void WriteValue(Uri value)
Parameters
value
UriThe System.Uri value to write.