Ejemplo n.º 1
0
    /// <summary>
    /// Writes elements to an xml writer
    /// </summary>
    /// <param name="writer"></param>
    private void WriteElements(Xml.XmlTextWriter writer)
    {
        // iterate across all keys in this section and write them to the xml file
        IDictionaryEnumerator enumerator = this.keyTable.GetEnumerator();

        while (enumerator.MoveNext())
        {
            writer.WriteStartElement(keyName);
            writer.WriteAttributeString("name", (string)enumerator.Key);
            writer.WriteString((string)enumerator.Value);

        //			System.Diagnostics.Debug.WriteLine(
        //"Wrote: " + this.name + " " + (string)enumerator.Key + " = " + (string)enumerator.Value);

            writer.WriteEndElement();
        }

        // then do it for all sub sections
        foreach (XmlStorage xml in this.subsectionTable.Values)
        {
            writer.WriteStartElement(subsectionName);
            writer.WriteAttributeString("name", xml.name);

            xml.WriteElements(writer);

            writer.WriteEndElement();
        }
    }
Ejemplo n.º 2
0
        private static void WriteStep(Xml.XmlTextWriter writer, Chunk chunk)
        {
            // First write out the chunk itself.
            writer.WriteStartElement(chunk.Name);

            // Write out any values.
            foreach (string key in chunk.Values.Keys )
            {
                writer.WriteStartElement("Value");
                writer.WriteAttributeString("Name", key);
                writer.WriteString( chunk.Values[key] );
                writer.WriteEndElement();
            }

            // Recurse children.
            foreach (Chunk c in chunk)
            {
                WriteStep(writer, c);
            }

            writer.WriteEndElement();
        }