Exemplo n.º 1
0
        /// <summary>
        /// Writes a standalone property value.
        /// </summary>
        /// <param name="name">Name of property.</param>
        /// <param name="value">Property value.</param>
        /// <remarks>
        /// This method produces the following output:
        /// &lt;PropertyName&gt;PropertyValue&lt;/PropertyName&gt;
        /// </remarks>
        public void WritePropertyValue(string name, string value)
        {
            XmlItem item = FCurItem.Add();

            item.Name  = name;
            item.Value = Converter.ToXml(value, false);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Writes an enumeration property.
 /// </summary>
 /// <param name="name">Property name.</param>
 /// <param name="value">Property value.</param>
 public void WriteValue(string name, object value)
 {
     FText.Append(PropName(name));
     FText.Append("=\"");
     FText.Append(value != null ? Converter.ToXml(value) : "null");
     FText.Append("\" ");
 }
Exemplo n.º 3
0
 /// <summary>
 /// Writes a string property.
 /// </summary>
 /// <param name="name">Property name.</param>
 /// <param name="value">Property value.</param>
 public void WriteStr(string name, string value)
 {
     FText.Append(PropName(name));
     FText.Append("=\"");
     FText.Append(Converter.ToXml(value));
     FText.Append("\" ");
 }
Exemplo n.º 4
0
 public void Save(XmlItem rootItem)
 {
     foreach (BlobItem item in FList)
     {
         XmlItem xi = rootItem.Add();
         xi.Name = "item";
         xi.SetProp("Stream", Converter.ToXml(item.Stream));
     }
 }
Exemplo n.º 5
0
 public void Save(XmlItem rootItem)
 {
     foreach (BlobItem item in list)
     {
         XmlItem xi = rootItem.Add();
         xi.Name = "item";
         xi.SetProp("Stream", Converter.ToXml(item.Stream));
         if (!String.IsNullOrEmpty(item.Source))
         {
             xi.SetProp("Source", Converter.ToXml(item.Source));
         }
         if (TempFile != null)
         {
             item.Dispose();
         }
     }
 }
Exemplo n.º 6
0
        /// <summary>
        /// Sets the value for a specified property.
        /// </summary>
        /// <param name="index">The property name.</param>
        /// <param name="value">Value to set.</param>
        /// <remarks>
        /// For example, you have a node like <c>&lt;Node Text="" Left="0"/&gt;</c>. When you set the
        /// "Text" property to "test", the node will be <c>&lt;Node Text="test" Left="0"/&gt;</c>.
        /// If property with specified name is not exist, it will be added.
        /// </remarks>
        public void SetProp(string index, string value)
        {
            string s = index + "=\"" + Converter.ToXml(value) + "\"";
            int    i = FText.ToUpper().IndexOf(index.ToUpper() + "=\"");

            if (i != -1 && (i == 0 || FText[i - 1] == 32))
            {
                int j = i + index.Length + 2;
                while (j <= FText.Length && FText[j] != 34)
                {
                    j++;
                }
                FText = FText.Remove(i, j - i + 1);
            }
            else
            {
                i = FText.Length + 1;
                s = " " + s;
            }
            FText = i > FText.Length ? FText + s : FText.Insert(i, s);
        }
Exemplo n.º 7
0
        internal void WriteProps(FastString sb)
        {
            if (properties == null || properties.Length == 0)
            {
                return;
            }

            sb.Append(" ");
            foreach (XmlProperty kv in properties)
            {
                //if (string.IsNullOrWhiteSpace(kv.Key))
                if (String.IsNullOrEmpty(kv.Key) || kv.Key.Trim().Length == 0)
                {
                    continue;
                }

                sb.Append(kv.Key);
                sb.Append("=\"");
                sb.Append(Converter.ToXml(kv.Value));
                sb.Append("\" ");
            }
            sb.Length--;
        }
Exemplo n.º 8
0
        private void WriteItem(XmlItem item, int level)
        {
            FastString sb = new FastString();


            // start
            if (autoIndent)
            {
                sb.Append(Dup(level));
            }
            sb.Append("<");
            sb.Append(item.Name);

            // text

            item.WriteProps(sb);

            // end
            if (item.Count == 0 && item.Value == "")
            {
                sb.Append("/>");
            }
            else
            {
                sb.Append(">");
            }

            // value
            if (item.Count == 0 && item.Value != "")
            {
                sb.Append(Converter.ToXml(item.Value, false));
                sb.Append("</");
                sb.Append(item.Name);
                sb.Append(">");
            }
            WriteLn(sb.ToString());
        }