Esempio n. 1
0
        /// <summary>
        /// Outputs a table row containing a variable dump.
        /// </summary>
        private static void HtmlVarRow(TextWriter output, string array, object name, object variable)
        {
            string s;

            output.Write("<tr><td class='rowHeader'>{0}[\"", array);

            // name:
            if ((s = name as string) != null)
            {
                output.Write((string)StringUtils.AddCSlashes(s, false, true));
            }
            else
            {
                output.Write((int)name);
            }

            // printed value:
            output.Write("\"]</td><td>");

            IPhpPrintable printable;

            if (variable == null || (variable as string) == String.Empty)
            {
                output.Write("<i>no value</i>");
            }
            else
            if ((printable = variable as IPhpPrintable) != null)
            {
                output.Write("<pre>");
                StringWriter str_output = new StringWriter();
                printable.Print(str_output);
                output.Write(HttpUtility.HtmlEncode(str_output.ToString()));
                output.Write("</pre>");
            }
            else
            {
                output.Write(Convert.ObjectToString(variable));
            }

            output.Write("</td></tr>");
        }
Esempio n. 2
0
        /// <summary>
        /// Prints a content of the given variable in PHP language.
        /// </summary>
        /// <param name="output">The output text stream.</param>
        /// <param name="obj">The variable to be printed.</param>
        public static void Export(TextWriter output, object obj)
        {
            IPhpPrintable printable;
            string        s;

            if ((printable = obj as IPhpPrintable) != null)
            {
                printable.Export(output);
            }
            else if ((s = obj as string) != null)
            {
                output.Write("'{0}'", StringUtils.AddCSlashes(s, true, false));
            }
            else if (obj is int)
            {
                output.Write((int)obj);
            }
            else if (obj is long)
            {
                output.Write((long)obj);
            }
            else if (obj is double)
            {
                output.Write(Convert.DoubleToString((double)obj));
            }
            else if (obj is bool)
            {
                output.Write((bool)obj ? True : False);
            }
            else
            {
                output.Write(TypeNameNull);
            }

            // prints an eoln if we are on the top level:
            //if (PrintIndentationLevel == 0)
            //	output.WriteLine();
        }