WriteRegularExpression() 공개 메소드

Writes a BSON regular expression to the writer.
public WriteRegularExpression ( BsonRegularExpression regex ) : void
regex BsonRegularExpression A BsonRegularExpression.
리턴 void
예제 #1
0
 public void TestOneRegularExpression()
 {
     var document = new BsonDocument();
     using (var writer = new BsonDocumentWriter(document))
     {
         writer.WriteStartDocument();
         writer.WriteRegularExpression("a", new BsonRegularExpression("p", "i"));
         writer.WriteEndDocument();
     }
     var json = document.ToJson();
     var expected = "{ 'a' : /p/i }".Replace("'", "\""); ;
     Assert.Equal(expected, json);
 }
예제 #2
0
 public void TestTwoNestedRegularExpressions()
 {
     var document = new BsonDocument();
     using (var writer = new BsonDocumentWriter(document))
     {
         writer.WriteStartDocument();
         writer.WriteStartDocument("nested");
         writer.WriteRegularExpression("a", new BsonRegularExpression("p", "i"));
         writer.WriteRegularExpression("b", new BsonRegularExpression("q", "m"));
         writer.WriteEndDocument();
         writer.WriteEndDocument();
     }
     var json = document.ToJson();
     var expected = "{ 'nested' : { 'a' : /p/i, 'b' : /q/m } }".Replace("'", "\"");
     Assert.Equal(expected, json);
 }