Ejemplo n.º 1
0
        private string ToXMLString(string linePrefix)
        {
            string str1 = "\r\n";

            if (linePrefix == null)
            {
                linePrefix = "";
            }
            StringBuilder stringBuilder = new StringBuilder(linePrefix + "<");

            if (!this.sdlNamespace.Equals(""))
            {
                stringBuilder.Append(this.sdlNamespace + ":");
            }
            stringBuilder.Append(this.name);
            if (this.values.Count != 0)
            {
                int num = 0;
                foreach (object obj in this.values)
                {
                    stringBuilder.Append(" ");
                    stringBuilder.Append("_val" + (object)num + "=\"" + SDLUtil.Format(obj, false) + "\"");
                    ++num;
                }
            }
            if (this.attributes != null && this.attributes.Count != 0)
            {
                foreach (string index in this.attributes.Keys)
                {
                    stringBuilder.Append(" ");
                    string str2 = this.attributeToNamespace[index];
                    if (!str2.Equals(""))
                    {
                        stringBuilder.Append(str2 + ":");
                    }
                    stringBuilder.Append(index + "=");
                    stringBuilder.Append("\"" + SDLUtil.Format(this.attributes[index], false) + "\"");
                }
            }
            if (this.children.Count != 0)
            {
                stringBuilder.Append(">" + str1);
                foreach (Tag tag in this.children)
                {
                    stringBuilder.Append(tag.ToXMLString(linePrefix + "    ") + str1);
                }
                stringBuilder.Append(linePrefix + "</");
                if (!this.sdlNamespace.Equals(""))
                {
                    stringBuilder.Append(this.sdlNamespace + ":");
                }
                stringBuilder.Append(this.name + ">");
            }
            else
            {
                stringBuilder.Append("/>");
            }
            return(((object)stringBuilder).ToString());
        }
Ejemplo n.º 2
0
        private string ToString(string linePrefix)
        {
            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(linePrefix);
            bool flag = false;

            if (this.sdlNamespace.Length == 0 && this.name.Equals("content"))
            {
                flag = true;
            }
            else
            {
                if (this.sdlNamespace.Length != 0)
                {
                    stringBuilder.Append(this.sdlNamespace).Append(':');
                }
                stringBuilder.Append(this.name);
            }
            if (this.values.Count != 0)
            {
                if (flag)
                {
                    flag = false;
                }
                else
                {
                    stringBuilder.Append(" ");
                }
                int count = this.values.Count;
                for (int index = 0; index < count; ++index)
                {
                    stringBuilder.Append(SDLUtil.Format(this.values[index]));
                    if (index < count - 1)
                    {
                        stringBuilder.Append(" ");
                    }
                }
            }
            if (this.attributes != null && this.attributes.Count != 0)
            {
                foreach (string index in this.attributes.Keys)
                {
                    stringBuilder.Append(" ");
                    string str = this.AttributeToNamespace[index];
                    if (!str.Equals(""))
                    {
                        stringBuilder.Append(str + ":");
                    }
                    stringBuilder.Append(index + "=");
                    stringBuilder.Append(SDLUtil.Format(this.attributes[index]));
                }
            }
            if (this.children.Count != 0)
            {
                if (!flag)
                {
                    stringBuilder.Append(" ");
                }
                stringBuilder.Append("{\r\n");
                foreach (Tag tag in this.children)
                {
                    stringBuilder.Append(tag.ToString(linePrefix + "\t") + "\r\n");
                }
                stringBuilder.Append(linePrefix + "}");
            }
            return(((object)stringBuilder).ToString());
        }
Ejemplo n.º 3
0
Archivo: Tag.cs Proyecto: Panke/SDL.NET
        /**
         * Produces a full SDL "dump" of this tag using the given prefix before
         * each line.
         * @param linePrefix Text to be prefixed to each line
         * @return SDL code describing this tag
         */
        string ToString(string linePrefix)
        {
            StringBuilder sb = new StringBuilder();

            sb.Append(linePrefix);

            bool skipValueSpace = false;

            if (sdlNamespace.Length == 0 && name.Equals("content"))
            {
                skipValueSpace = true;
            }
            else
            {
                if (sdlNamespace.Length != 0)
                {
                    sb.Append(sdlNamespace).Append(':');
                }
                sb.Append(name);
            }

            // output values
            if (values.Count != 0)
            {
                if (skipValueSpace == true)
                {
                    skipValueSpace = false;
                }
                else
                {
                    sb.Append(" ");
                }

                int size = values.Count;
                for (int i = 0; i < size; i++)
                {
                    sb.Append(SDLUtil.Format(values[i]));
                    if (i < size - 1)
                    {
                        sb.Append(" ");
                    }
                }
            }

            // output attributes
            if (attributes.Count != 0)
            {
                foreach (string key in attributes.Keys)
                {
                    sb.Append(" ");

                    string attNamespace = AttributeToNamespace[key];
                    if (!attNamespace.Equals(""))
                    {
                        sb.Append(attNamespace + ":");
                    }
                    sb.Append(key + "=");
                    sb.Append(SDLUtil.Format(attributes[key]));
                }
            }

            // output children
            if (children.Count != 0)
            {
                sb.Append(" {\r\n");
                foreach (Tag t in children)
                {
                    sb.Append(t.ToString(linePrefix + "    ") + "\r\n");
                }
                sb.Append(linePrefix + "}");
            }

            return(sb.ToString());
        }
Ejemplo n.º 4
0
Archivo: Tag.cs Proyecto: Panke/SDL.NET
        /**
         * Returns a string containing an XML representation of this tag.
         * Values will be represented using _val0, _val1, etc.
         * @param linePrefix A prefix to insert before every line.
         * @return An XML String describing this Tag
         */
        string ToXMLString(string linePrefix)
        {
            string newLine = "\r\n";

            if (linePrefix == null)
            {
                linePrefix = "";
            }

            StringBuilder builder = new StringBuilder(linePrefix + "<");

            if (!sdlNamespace.Equals(""))
            {
                builder.Append(sdlNamespace + ":");
            }
            builder.Append(name);

            // output values
            if (values.Count != 0)
            {
                int i = 0;
                foreach (object val in values)
                {
                    builder.Append(" ");
                    builder.Append("_val" + i + "=\"" + SDLUtil.Format(val,
                                                                       false) + "\"");

                    i++;
                }
            }

            // output attributes
            if (attributes.Count != 0)
            {
                foreach (string key in attributes.Keys)
                {
                    builder.Append(" ");
                    string attNamespace = attributeToNamespace[key];

                    if (!attNamespace.Equals(""))
                    {
                        builder.Append(attNamespace + ":");
                    }
                    builder.Append(key + "=");
                    builder.Append("\"" + SDLUtil.Format(attributes[key], false)
                                   + "\"");
                }
            }

            if (children.Count != 0)
            {
                builder.Append(">" + newLine);
                foreach (Tag t in children)
                {
                    builder.Append(t.ToXMLString(linePrefix + "    ") + newLine);
                }

                builder.Append(linePrefix + "</");
                if (!sdlNamespace.Equals(""))
                {
                    builder.Append(sdlNamespace + ":");
                }
                builder.Append(name + ">");
            }
            else
            {
                builder.Append("/>");
            }

            return(builder.ToString());
        }
Ejemplo n.º 5
0
 public static string Format(object obj)
 {
     return(SDLUtil.Format(obj, true));
 }