WriteRegex() 공개 메소드

Writes a BSON regex.
public WriteRegex ( string pattern, string options ) : void
pattern string The regex pattern.
options string The regex options.
리턴 void
예제 #1
0
    private void WriteBson(BsonWriter writer, Regex regex)
    {
      // Regular expression - The first cstring is the regex pattern, the second
      // is the regex options string. Options are identified by characters, which 
      // must be stored in alphabetical order. Valid options are 'i' for case 
      // insensitive matching, 'm' for multiline matching, 'x' for verbose mode, 
      // 'l' to make \w, \W, etc. locale dependent, 's' for dotall mode 
      // ('.' matches everything), and 'u' to make \w, \W, etc. match unicode.

      string options = null;

      if (HasFlag(regex.Options, RegexOptions.IgnoreCase))
        options += "i";

      if (HasFlag(regex.Options, RegexOptions.Multiline))
        options += "m";

      if (HasFlag(regex.Options, RegexOptions.Singleline))
        options += "s";

      options += "u";

      if (HasFlag(regex.Options, RegexOptions.ExplicitCapture))
        options += "x";

      writer.WriteRegex(regex.ToString(), options);
    }
예제 #2
0
 private void WriteBson(BsonWriter writer, Regex regex)
 {
   string str = (string) null;
   if (this.HasFlag(regex.Options, RegexOptions.IgnoreCase))
     str = str + "i";
   if (this.HasFlag(regex.Options, RegexOptions.Multiline))
     str = str + "m";
   if (this.HasFlag(regex.Options, RegexOptions.Singleline))
     str = str + "s";
   string options = str + "u";
   if (this.HasFlag(regex.Options, RegexOptions.ExplicitCapture))
     options = options + "x";
   writer.WriteRegex(regex.ToString(), options);
 }
        public void WriteRegexPlusContent()
        {
            MemoryStream ms = new MemoryStream();
            BsonWriter writer = new BsonWriter(ms);

            writer.WriteStartObject();
            writer.WritePropertyName("regex");
            writer.WriteRegex("abc", "i");
            writer.WritePropertyName("test");
            writer.WriteRegex(string.Empty, null);
            writer.WriteEndObject();

            byte[] expected = HexToBytes("1A-00-00-00-0B-72-65-67-65-78-00-61-62-63-00-69-00-0B-74-65-73-74-00-00-00-00");

            CollectionAssert.AreEquivalent(expected, ms.ToArray());
        }
예제 #4
0
 // Token: 0x060001A6 RID: 422
 // RVA: 0x0002BE48 File Offset: 0x0002A048
 private void WriteBson(BsonWriter writer, Regex regex)
 {
     string text = null;
     if (this.HasFlag(regex.Options, RegexOptions.IgnoreCase))
     {
         text += "i";
     }
     if (this.HasFlag(regex.Options, RegexOptions.Multiline))
     {
         text += "m";
     }
     if (this.HasFlag(regex.Options, RegexOptions.Singleline))
     {
         text += "s";
     }
     text += "u";
     if (this.HasFlag(regex.Options, RegexOptions.ExplicitCapture))
     {
         text += "x";
     }
     writer.WriteRegex(regex.ToString(), text);
 }