Ejemplo n.º 1
0
        protected override void WritePrimitive(TextWriter writer, object value)
        {
            if (value is DateTime)
            {
                // write as ECMAScript Date constructor
                EcmaScriptFormatter.WriteEcmaScriptDate(writer, (DateTime)value);
                return;
            }
            if (value is Regex)
            {
                EcmaScriptFormatter.WriteEcmaScriptRegExp(writer, (Regex)value);
                return;
            }

            base.WritePrimitive(writer, value);
        }
Ejemplo n.º 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(TextWriter writer, Regex regex)
 {
     EcmaScriptFormatter.WriteEcmaScriptRegExp(writer, regex, false);
 }