Example #1
0
        public new static string Serialize(object value)
        {
            StringBuilder stringBuilder = new StringBuilder();

            using (EcmaScriptWriter ecmaScriptWriter = new EcmaScriptWriter(stringBuilder))
            {
                ecmaScriptWriter.Write(value);
            }
            return(stringBuilder.ToString());
        }
Example #2
0
        /// <summary>
        /// A helper method for serializing an object to EcmaScript
        /// </summary>
        /// <param name="value"></param>
        /// <returns></returns>
        public static new string Serialize(object value)
        {
            StringBuilder output = new StringBuilder();

            using (EcmaScriptWriter writer = new EcmaScriptWriter(output))
            {
                writer.Write(value);
            }

            return(output.ToString());
        }
Example #3
0
 protected override void Write(object value, bool isProperty)
 {
     if (value is Regex)
     {
         if (isProperty && base.Settings.PrettyPrint)
         {
             base.TextWriter.Write(' ');
         }
         EcmaScriptWriter.WriteEcmaScriptRegExp(this, (Regex)value);
         return;
     }
     base.Write(value, isProperty);
 }
Example #4
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);
 }
Example #5
0
 /// <summary>
 /// Writes dates as ECMAScript Date constructors
 /// </summary>
 /// <param name="value"></param>
 public override void Write(DateTime value)
 {
     EcmaScriptWriter.WriteEcmaScriptDate(this, value);
 }
Example #6
0
		/// <summary>
		/// A helper method for serializing an object to EcmaScript
		/// </summary>
		/// <param name="value"></param>
		/// <returns></returns>
		public static new string Serialize(object value)
		{
			StringBuilder output = new StringBuilder();

			using (EcmaScriptWriter writer = new EcmaScriptWriter(output))
			{
				writer.Write(value);
			}

			return output.ToString();
		}