MongoDB.Bson.IO.BsonWriter.WriteJavaScriptWithScope C# (CSharp) Method

WriteJavaScriptWithScope() public abstract method

Writes a BSON JavaScript to the writer (call WriteStartDocument to start writing the scope).
public abstract WriteJavaScriptWithScope ( string code ) : void
code string The JavaScript code.
return void
        public abstract void WriteJavaScriptWithScope(string code);

Same methods

BsonWriter::WriteJavaScriptWithScope ( string name, string code ) : void

Usage Example

 /// <summary>
 /// Serializes an object to a BsonWriter.
 /// </summary>
 /// <param name="bsonWriter">The BsonWriter.</param>
 /// <param name="nominalType">The nominal type.</param>
 /// <param name="value">The object.</param>
 /// <param name="options">The serialization options.</param>
 public override void Serialize(
     BsonWriter bsonWriter,
     Type nominalType,
     object value,
     IBsonSerializationOptions options
 ) {
     if (value == null) {
         bsonWriter.WriteNull();
     } else {
         var script = (BsonJavaScriptWithScope) value;
         bsonWriter.WriteJavaScriptWithScope(script.Code);
         script.Scope.WriteTo(bsonWriter);
     }
 }
All Usage Examples Of MongoDB.Bson.IO.BsonWriter::WriteJavaScriptWithScope