Ejemplo n.º 1
0
        /// <summary>
        /// Writes the ini data to a stream.
        /// </summary>
        /// <param name="writer">The writer.</param>
        /// <param name="iniData">An <see cref="IniData"/> instance .</param>
        public void WriteData(StreamWriter writer, IniData iniData)
        {
            SectionDataCollection sdc = iniData.Sections;


            //Write sections
            foreach (SectionData sd in sdc)
            {
                //Write section comments
                foreach (string sectionComment in sd.Comments)
                {
                    writer.WriteLine(string.Format("{0}{1}", CommentDelimiter, sectionComment));
                }

                //Write section name
                writer.WriteLine(string.Format(
                                     "{0}{1}{2}",
                                     SectionDelimiters[0], sd.SectionName, SectionDelimiters[1]));

                //Write section keys
                foreach (KeyData kd in sd.Keys)
                {
                    //Write key comments
                    foreach (string keyComment in kd.Comments)
                    {
                        writer.WriteLine(string.Format("{0}{1}", CommentDelimiter, keyComment));
                    }

                    //Write key and value
                    writer.WriteLine(string.Format(
                                         "{0} {1} {2}",
                                         kd.KeyName, KeyValueDelimiter, kd.Value));
                }

                writer.WriteLine();                      //blank line
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new IniData instance using a previous
 /// <see cref="SectionDataCollection"/>.
 /// </summary>
 /// <param name="sdc">
 /// <see cref="SectionDataCollection"/> object containing the
 /// data with the sections of the file</param>
 public IniData(SectionDataCollection sdc)
 {
     _sections = (SectionDataCollection)sdc.Clone();
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes an empty IniData instance.
 /// </summary>
 public IniData()
 {
     _sections = new SectionDataCollection();
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="SectionDataCollection"/> class
 /// from a previous instance of <see cref="SectionDataCollection"/>.
 /// </summary>
 /// <remarks>
 /// Data is deeply copied
 /// </remarks>
 /// <param name="ori">
 /// The instance of the <see cref="SectionDataCollection"/> class
 /// used to create the new instance.</param>
 public SectionDataCollection(SectionDataCollection ori)
 {
     _sectionData = new Dictionary <string, SectionData> (ori._sectionData);
 }