コード例 #1
0
        protected override void Write(object value, bool isProperty, Type fieldType = null)
        {
            if (value is Regex)
            {
                if (isProperty && this.Settings.PrettyPrint)
                {
                    this.TextWriter.Write(' ');
                }
                EcmaScriptWriter.WriteEcmaScriptRegExp(this, (Regex)value);
                return;
            }

            base.Write(value, isProperty);
        }
コード例 #2
0
 /// <summary>
 /// Outputs a .NET Regex as an ECMAScript RegExp literal.
 /// Defaults to global matching off.
 /// </summary>
 /// <param name="writer"></param>
 /// <param name="regex"></param>
 /// <remarks>
 /// http://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdf
 /// </remarks>
 public static void WriteEcmaScriptRegExp(JsonWriter writer, Regex regex)
 {
     EcmaScriptWriter.WriteEcmaScriptRegExp(writer, regex, false);
 }