// --------------------------------------------------------------------------------------------------------------------
// <copyright file="IniDataCaseInsensitive.cs" company="">
//   
// </copyright>
// <summary>
//   <para>
//   Represents all data from an INI file exactly as the
//   <see cref="IniData" />
//   </para>
//   <para>
//   class, but searching for sections and keys names is done with a case
//   insensitive search.
//   </para>
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace RatiocinationLibrary.Config
{
    using System;

    /// <summary>
    ///     <para>
    ///         Represents all data from an INI file exactly as the
    ///         <see cref="IniData" />
    ///     </para>
    ///     <para>
    ///         class, but searching for sections and keys names is done with a case
    ///         insensitive search.
    ///     </para>
    /// </summary>
    public class IniDataCaseInsensitive : IniData
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="IniDataCaseInsensitive"/> class. 
        ///     Initializes an empty <see cref="IniData"/> instance.
        /// </summary>
        public IniDataCaseInsensitive()
            : base(new SectionDataCollection(StringComparer.OrdinalIgnoreCase))
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="IniDataCaseInsensitive"/> class. 
        /// Initializes a new <see cref="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 IniDataCaseInsensitive(SectionDataCollection sdc)
            : base(new SectionDataCollection(sdc, StringComparer.OrdinalIgnoreCase))
        {
        }

        /// <summary>
        /// Initializes a new instance of the <see cref="IniDataCaseInsensitive"/> class. 
        /// Copies an instance of the <see cref="IniDataCaseInsensitive"/>
        ///     class
        /// </summary>
        /// <param name="ori">
        /// Original
        /// </param>
        public IniDataCaseInsensitive(IniData ori)
            : this(
                new SectionDataCollection(
                    ori.Sections, 
                    StringComparer.OrdinalIgnoreCase))
        {
            this.Global = (KeyDataCollection)ori.Global.Clone();
            this.Configuration = ori.Configuration.Clone();
        }
    }
}