/// <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: /// <PropertyName>PropertyValue</PropertyName> /// </remarks> public void WritePropertyValue(string name, string value) { XmlItem item = FCurItem.Add(); item.Name = name; item.Value = Converter.ToXml(value, false); }
/// <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("\" "); }
/// <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("\" "); }
public void Save(XmlItem rootItem) { foreach (BlobItem item in FList) { XmlItem xi = rootItem.Add(); xi.Name = "item"; xi.SetProp("Stream", Converter.ToXml(item.Stream)); } }
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(); } } }
/// <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><Node Text="" Left="0"/></c>. When you set the /// "Text" property to "test", the node will be <c><Node Text="test" Left="0"/></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); }
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--; }
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()); }