本文整理汇总了C#中MongoDB.Bson.IO.BsonBinaryWriterContext类的典型用法代码示例。如果您正苦于以下问题:C# BsonBinaryWriterContext类的具体用法?C# BsonBinaryWriterContext怎么用?C# BsonBinaryWriterContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
BsonBinaryWriterContext类属于MongoDB.Bson.IO命名空间,在下文中一共展示了BsonBinaryWriterContext类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: BsonBinaryWriterContext
// constructors
internal BsonBinaryWriterContext(
BsonBinaryWriterContext parentContext,
ContextType contextType,
int startPosition)
{
_parentContext = parentContext;
_contextType = contextType;
_startPosition = startPosition;
}
开发者ID:abel,项目名称:sinan,代码行数:10,代码来源:BsonBinaryWriterContext.cs
示例2: BsonBinaryWriterContext
internal BsonBinaryWriterContext(
BsonBinaryWriterContext parentContext,
ContextType contextType,
int startPosition
)
{
this.parentContext = parentContext;
this.contextType = contextType;
this.startPosition = startPosition;
}
开发者ID:kenegozi,项目名称:mongo-csharp-driver,代码行数:10,代码来源:BsonBinaryWriterContext.cs
示例3: WriteJavaScriptWithScope
/// <summary>
/// Writes a BSON JavaScript to the writer (call WriteStartDocument to start writing the scope).
/// </summary>
/// <param name="code">The JavaScript code.</param>
public override void WriteJavaScriptWithScope(string code)
{
if (Disposed) { throw new ObjectDisposedException("BsonBinaryWriter"); }
if (State != BsonWriterState.Value)
{
ThrowInvalidState("WriteJavaScriptWithScope", BsonWriterState.Value);
}
_buffer.WriteByte((byte)BsonType.JavaScriptWithScope);
WriteNameHelper();
_context = new BsonBinaryWriterContext(_context, ContextType.JavaScriptWithScope, _buffer.Position);
_buffer.WriteInt32(0); // reserve space for size of JavaScript with scope value
_buffer.WriteString(code);
State = BsonWriterState.ScopeDocument;
}
开发者ID:ncipollina,项目名称:mongo-csharp-driver,代码行数:20,代码来源:BsonBinaryWriter.cs
示例4: WriteJavaScriptWithScope
/// <summary>
/// Writes a BSON JavaScript to the writer (call WriteStartDocument to start writing the scope).
/// </summary>
/// <param name="code">The JavaScript code.</param>
public override void WriteJavaScriptWithScope(
string code
) {
if (disposed) { throw new ObjectDisposedException("BsonBinaryWriter"); }
if (state != BsonWriterState.Value) {
var message = string.Format("WriteJavaScriptWithScope cannot be called when State is: {0}", state);
throw new InvalidOperationException(message);
}
buffer.WriteByte((byte) BsonType.JavaScriptWithScope);
WriteNameHelper();
context = new BsonBinaryWriterContext(context, ContextType.JavaScriptWithScope, buffer.Position);
buffer.WriteInt32(0); // reserve space for size of JavaScript with scope value
buffer.WriteString(code);
state = BsonWriterState.ScopeDocument;
}
开发者ID:oskysal,项目名称:mongo-csharp-driver,代码行数:21,代码来源:BsonBinaryWriter.cs
示例5: WriteStartArray
/// <summary>
/// Writes the start of a BSON array to the writer.
/// </summary>
public override void WriteStartArray()
{
if (Disposed) { throw new ObjectDisposedException("BsonBinaryWriter"); }
if (State != BsonWriterState.Value)
{
ThrowInvalidState("WriteStartArray", BsonWriterState.Value);
}
_buffer.WriteByte((byte)BsonType.Array);
WriteNameHelper();
_context = new BsonBinaryWriterContext(_context, ContextType.Array, _buffer.Position);
_buffer.WriteInt32(0); // reserve space for size
State = BsonWriterState.Value;
}
开发者ID:ncipollina,项目名称:mongo-csharp-driver,代码行数:18,代码来源:BsonBinaryWriter.cs
示例6: WriteStartArray
/// <summary>
/// Writes the start of a BSON array to the writer.
/// </summary>
public override void WriteStartArray() {
if (disposed) { throw new ObjectDisposedException("BsonBinaryWriter"); }
if (state != BsonWriterState.Value) {
var message = string.Format("WriteStartArray cannot be called when State is: {0}", state);
throw new InvalidOperationException(message);
}
buffer.WriteByte((byte) BsonType.Array);
WriteNameHelper();
context = new BsonBinaryWriterContext(context, ContextType.Array, buffer.Position);
buffer.WriteInt32(0); // reserve space for size
state = BsonWriterState.Value;
}
开发者ID:oskysal,项目名称:mongo-csharp-driver,代码行数:17,代码来源:BsonBinaryWriter.cs
示例7: WriteStartDocument
/// <summary>
/// Writes the start of a BSON document to the writer.
/// </summary>
public override void WriteStartDocument() {
if (disposed) { throw new ObjectDisposedException("BsonBinaryWriter"); }
if (state != BsonWriterState.Initial && state != BsonWriterState.Value && state != BsonWriterState.ScopeDocument && state != BsonWriterState.Done) {
var message = string.Format("WriteStartDocument cannot be called when State is: {0}", state);
throw new InvalidOperationException(message);
}
if (state == BsonWriterState.Value) {
buffer.WriteByte((byte) BsonType.Document);
WriteNameHelper();
}
var contextType = (state == BsonWriterState.ScopeDocument) ? ContextType.ScopeDocument : ContextType.Document;
context = new BsonBinaryWriterContext(context, ContextType.Document, buffer.Position);
buffer.WriteInt32(0); // reserve space for size
state = BsonWriterState.Name;
}
开发者ID:oskysal,项目名称:mongo-csharp-driver,代码行数:20,代码来源:BsonBinaryWriter.cs
示例8: WriteStartDocument
/// <summary>
/// Writes the start of a BSON document to the writer.
/// </summary>
public override void WriteStartDocument()
{
if (Disposed) { throw new ObjectDisposedException("BsonBinaryWriter"); }
if (State != BsonWriterState.Initial && State != BsonWriterState.Value && State != BsonWriterState.ScopeDocument && State != BsonWriterState.Done)
{
ThrowInvalidState("WriteStartDocument", BsonWriterState.Initial, BsonWriterState.Value, BsonWriterState.ScopeDocument, BsonWriterState.Done);
}
if (State == BsonWriterState.Value)
{
_buffer.WriteByte((byte)BsonType.Document);
WriteNameHelper();
}
var contextType = (State == BsonWriterState.ScopeDocument) ? ContextType.ScopeDocument : ContextType.Document;
_context = new BsonBinaryWriterContext(_context, ContextType.Document, _buffer.Position);
_buffer.WriteInt32(0); // reserve space for size
State = BsonWriterState.Name;
}
开发者ID:ncipollina,项目名称:mongo-csharp-driver,代码行数:22,代码来源:BsonBinaryWriter.cs
示例9: Close
/// <summary>
/// Closes the writer.
/// </summary>
public override void Close() {
// Close can be called on Disposed objects
if (state != BsonWriterState.Closed) {
if (state == BsonWriterState.Done) {
Flush();
}
if (stream != null && settings.CloseOutput) {
stream.Close();
}
context = null;
state = BsonWriterState.Closed;
}
}
开发者ID:oskysal,项目名称:mongo-csharp-driver,代码行数:16,代码来源:BsonBinaryWriter.cs
示例10: BsonBinaryWriter
/// <summary>
/// Initializes a new instance of the BsonBinaryWriter class.
/// </summary>
/// <param name="buffer">A BsonBuffer.</param>
/// <param name="disposeBuffer">if set to <c>true</c> this BsonBinaryReader will own the buffer and when Dispose is called the buffer will be Disposed also.</param>
/// <param name="settings">Optional BsonBinaryWriter settings.</param>
/// <exception cref="System.ArgumentNullException">
/// encoder
/// or
/// settings
/// </exception>
public BsonBinaryWriter(BsonBuffer buffer, bool disposeBuffer, BsonBinaryWriterSettings settings)
: base(settings)
{
if (buffer == null)
{
throw new ArgumentNullException("encoder");
}
_buffer = buffer;
_disposeBuffer = disposeBuffer;
_binaryWriterSettings = settings; // already frozen by base class
_context = null;
State = BsonWriterState.Initial;
}
开发者ID:kblok,项目名称:mongo-csharp-driver,代码行数:26,代码来源:BsonBinaryWriter.cs
示例11: BsonBinaryWriter
/// <summary>
/// Initializes a new instance of the BsonBinaryWriter class.
/// </summary>
/// <param name="stream">A stream.</param>
/// <param name="buffer">A BsonBuffer.</param>
/// <param name="settings">Optional BsonBinaryWriter settings.</param>
public BsonBinaryWriter(
Stream stream,
BsonBuffer buffer,
BsonBinaryWriterSettings settings
) {
this.stream = stream;
if (buffer == null) {
this.buffer = new BsonBuffer();
this.disposeBuffer = true; // only call Dispose if we allocated the buffer
} else {
this.buffer = buffer;
this.disposeBuffer = false;
}
this.settings = settings.Freeze();
context = null;
state = BsonWriterState.Initial;
}
开发者ID:dalinhuang,项目名称:tdcodes,代码行数:24,代码来源:BsonBinaryWriter.cs
示例12: BsonBinaryWriter
// constructors
/// <summary>
/// Initializes a new instance of the BsonBinaryWriter class.
/// </summary>
/// <param name="stream">A stream.</param>
/// <param name="buffer">A BsonBuffer.</param>
/// <param name="settings">Optional BsonBinaryWriter settings.</param>
public BsonBinaryWriter(Stream stream, BsonBuffer buffer, BsonBinaryWriterSettings settings)
: base(settings)
{
_stream = stream;
if (buffer == null)
{
_buffer = new BsonBuffer();
_disposeBuffer = true; // only call Dispose if we allocated the buffer
}
else
{
_buffer = buffer;
_disposeBuffer = false;
}
_binaryWriterSettings = settings; // already frozen by base class
_context = null;
State = BsonWriterState.Initial;
}
开发者ID:ncipollina,项目名称:mongo-csharp-driver,代码行数:26,代码来源:BsonBinaryWriter.cs
示例13: BsonBinaryWriter
/// <summary>
/// Initializes a new instance of the BsonBinaryWriter class.
/// </summary>
/// <param name="stream">A stream. The BsonBinaryWriter does not own the stream and will not Dispose it.</param>
/// <param name="settings">The BsonBinaryWriter settings.</param>
public BsonBinaryWriter(Stream stream, BsonBinaryWriterSettings settings)
: base(settings)
{
if (stream == null)
{
throw new ArgumentNullException("stream");
}
if (!stream.CanSeek)
{
throw new ArgumentException("The stream must be capable of seeking.", "stream");
}
_baseStream = stream;
_bsonStream = (stream as BsonStream) ?? new BsonStreamAdapter(stream);
_settings = settings; // already frozen by base class
_maxDocumentSizeStack.Push(_settings.MaxDocumentSize);
_context = null;
State = BsonWriterState.Initial;
}
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:25,代码来源:BsonBinaryWriter.cs
示例14: WriteEndArray
/// <summary>
/// Writes the end of a BSON array to the writer.
/// </summary>
public override void WriteEndArray()
{
if (Disposed) { throw new ObjectDisposedException("BsonBinaryWriter"); }
if (State != BsonWriterState.Value)
{
ThrowInvalidState("WriteEndArray", BsonWriterState.Value);
}
if (_context.ContextType != ContextType.Array)
{
ThrowInvalidContextType("WriteEndArray", _context.ContextType, ContextType.Array);
}
_buffer.WriteByte(0);
BackpatchSize(); // size of document
_context = _context.ParentContext;
State = GetNextState();
}
开发者ID:ncipollina,项目名称:mongo-csharp-driver,代码行数:21,代码来源:BsonBinaryWriter.cs
示例15: WriteEndDocument
/// <summary>
/// Writes the end of a BSON document to the writer.
/// </summary>
public override void WriteEndDocument()
{
if (Disposed) { throw new ObjectDisposedException("BsonBinaryWriter"); }
if (State != BsonWriterState.Name)
{
ThrowInvalidState("WriteEndDocument", BsonWriterState.Name);
}
if (_context.ContextType != ContextType.Document && _context.ContextType != ContextType.ScopeDocument)
{
ThrowInvalidContextType("WriteEndDocument", _context.ContextType, ContextType.Document, ContextType.ScopeDocument);
}
_buffer.WriteByte(0);
BackpatchSize(); // size of document
_context = _context.ParentContext;
if (_context == null)
{
State = BsonWriterState.Done;
}
else
{
if (_context.ContextType == ContextType.JavaScriptWithScope)
{
BackpatchSize(); // size of the JavaScript with scope value
_context = _context.ParentContext;
}
State = GetNextState();
}
}
开发者ID:ncipollina,项目名称:mongo-csharp-driver,代码行数:33,代码来源:BsonBinaryWriter.cs
示例16: WriteEndDocument
/// <summary>
/// Writes the end of a BSON document to the writer.
/// </summary>
public override void WriteEndDocument() {
if (disposed) { throw new ObjectDisposedException("BsonBinaryWriter"); }
if (state != BsonWriterState.Name || (context.ContextType != ContextType.Document && context.ContextType != ContextType.ScopeDocument)) {
var message = string.Format("WriteEndDocument cannot be called when State is: {0}", state);
throw new InvalidOperationException(message);
}
buffer.WriteByte(0);
BackpatchSize(); // size of document
context = context.ParentContext;
if (context == null) {
state = BsonWriterState.Done;
} else {
if (context.ContextType == ContextType.JavaScriptWithScope) {
BackpatchSize(); // size of the JavaScript with scope value
context = context.ParentContext;
}
state = GetNextState();
}
}
开发者ID:oskysal,项目名称:mongo-csharp-driver,代码行数:24,代码来源:BsonBinaryWriter.cs
示例17: WriteEndArray
/// <summary>
/// Writes the end of a BSON array to the writer.
/// </summary>
public override void WriteEndArray() {
if (disposed) { throw new ObjectDisposedException("BsonBinaryWriter"); }
if (state != BsonWriterState.Value || context.ContextType != ContextType.Array) {
var message = string.Format("WriteEndArray cannot be called when State is: {0}", state);
throw new InvalidOperationException(message);
}
buffer.WriteByte(0);
BackpatchSize(); // size of document
context = context.ParentContext;
state = GetNextState();
}
开发者ID:oskysal,项目名称:mongo-csharp-driver,代码行数:16,代码来源:BsonBinaryWriter.cs
示例18: WriteRawBsonDocument
/// <summary>
/// Writes a raw BSON document.
/// </summary>
/// <param name="slice">The byte buffer containing the raw BSON document.</param>
public override void WriteRawBsonDocument(IByteBuffer slice)
{
if (Disposed) { throw new ObjectDisposedException("BsonBinaryWriter"); }
if (State != BsonWriterState.Initial && State != BsonWriterState.Value && State != BsonWriterState.ScopeDocument && State != BsonWriterState.Done)
{
ThrowInvalidState("WriteRawBsonDocument", BsonWriterState.Initial, BsonWriterState.Value, BsonWriterState.ScopeDocument, BsonWriterState.Done);
}
if (State == BsonWriterState.Value)
{
_buffer.WriteByte((byte)BsonType.Document);
WriteNameHelper();
}
_buffer.ByteBuffer.WriteBytes(slice); // assumes byteBuffer is a valid raw BSON document
if (_context == null)
{
State = BsonWriterState.Done;
}
else
{
if (_context.ContextType == ContextType.JavaScriptWithScope)
{
BackpatchSize(); // size of the JavaScript with scope value
_context = _context.ParentContext;
}
State = GetNextState();
}
}
开发者ID:Khosrow-Azizi,项目名称:MasterExperimentV2,代码行数:33,代码来源:BsonBinaryWriter.cs
示例19: Close
// public methods
/// <summary>
/// Closes the writer. Also closes the base stream.
/// </summary>
public override void Close()
{
// Close can be called on Disposed objects
if (State != BsonWriterState.Closed)
{
if (State == BsonWriterState.Done)
{
Flush();
}
_context = null;
State = BsonWriterState.Closed;
}
}
开发者ID:narutoswj,项目名称:mongo-csharp-driver,代码行数:17,代码来源:BsonBinaryWriter.cs
注:本文中的MongoDB.Bson.IO.BsonBinaryWriterContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论