<commit_before>﻿using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;

namespace System.Ini
{
    public class IniManager
    {
        OrderedDictionary p_Sections = new OrderedDictionary();

        /// <summary>
        /// Gets the amount of properties across all sections.
        /// </summary>
        public int CountProperties
        {
            get
            {
                int count = 0;

                foreach (DictionaryEntry entry in p_Sections)
                {
                    count += (entry.Value as IniSection).Count;
                }

                return count;
            }
        }
        /// <summary>
        /// Gets the amount of sections.
        /// </summary>
        public int CountSections
        {
            get { return p_Sections.Count; }
        }
        /// <summary>
        /// Gets the filename of the current configuration file.
        /// </summary>
        public string Filename { get; private set; }
        /// <summary>
        /// Gets the sections of the configuration file with properties as read-only.
        /// </summary>
        public OrderedDictionary Sections
        {
            get { return p_Sections.AsReadOnly(); }
        }

        /// <summary>
        /// Initializes a new instance of the System.Ini.IniManager class. Does not load until Load method is called.
        /// </summary>
        /// <param name="filename">The complete file path to write and read configuration file.</param>
        public IniManager(string filename)
        {
            this.Filename = filename;
        }

        /// <summary>
        /// Backs up the configuration file.
        /// </summary>
        /// <param name="file">Path to save backup file to.</param>
        /// <param name="applyChanges">True if changes should be written, false to just copy the configuration file.</param>
        public void Backup(string file, bool applyChanges)
        {
            if (applyChanges)
            {
                this.Save(file);
            }
            else
            {
                if (!File.Exists(this.Filename))
                    throw new FileNotFoundException("INI file not found", this.Filename);

                File.Copy(this.Filename, file);
            }
        }

        /// <summary>
        /// Deletes property from section in configuration file.
        /// </summary>
        /// <param name="section">The section of the property.</param>
        /// <param name="key">The key of the property.</param>
        public void Delete(string section, string key)
        {
            IniSection properties = this.GetSection(section);

            if (properties == null)<commit_msg>Add Contains methods<commit_after>﻿using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;

namespace System.Ini
{
    public class IniManager
    {
        OrderedDictionary p_Sections = new OrderedDictionary();

        /// <summary>
        /// Gets the amount of properties across all sections.
        /// </summary>
        public int CountProperties
        {
            get
            {
                int count = 0;

                foreach (DictionaryEntry entry in p_Sections)
                {
                    count += (entry.Value as IniSection).Count;
                }

                return count;
            }
        }
        /// <summary>
        /// Gets the amount of sections.
        /// </summary>
        public int CountSections
        {
            get { return p_Sections.Count; }
        }
        /// <summary>
        /// Gets the filename of the current configuration file.
        /// </summary>
        public string Filename { get; private set; }
        /// <summary>
        /// Gets the sections of the configuration file with properties as read-only.
        /// </summary>
        public OrderedDictionary Sections
        {
            get { return p_Sections.AsReadOnly(); }
        }

        /// <summary>
        /// Initializes a new instance of the System.Ini.IniManager class. Does not load until Load method is called.
        /// </summary>
        /// <param name="filename">The complete file path to write and read configuration file.</param>
        public IniManager(string filename)
        {
            this.Filename = filename;
        }

        /// <summary>
        /// Backs up the configuration file.
        /// </summary>
        /// <param name="file">Path to save backup file to.</param>
        /// <param name="applyChanges">True if changes should be written, false to just copy the configuration file.</param>
        public void Backup(string file, bool applyChanges)
        {
            if (applyChanges)
            {
                this.Save(file);
            }
            else
            {
                if (!File.Exists(this.Filename))
                    throw new FileNotFoundException("INI file not found", this.Filename);

                File.Copy(this.Filename, file);
            }
        }

        /// <summary>
        /// Determine whether a section exists.
        /// </summary>
        /// <param name="section">The section to find.</param>
        public bool Contains(string section)
        {
            return this.p_Sections.Contains(section);
        }

        /// <summary>
        /// Determine whether a property within a given section exists.
        /// </summary>
        /// <param name="section">The section to find.</param>
        /// <param name="key">The key of the property to find.</param>
        public bool Contains(string section, string key)
        {
            return this.GetSection(section).Contains(key);
        }

        /// <summary>
        /// Deletes property from section in configuration file.
        /// </summary>
        /// <param name="section">The section of the property.</param>
        /// <param name="key">The key of the property.</param>
        public void Delete(string section, string key)
        {
            IniSection properties = this.GetSection(section);

            if (properties == null)
{'fraction_non_alphanumeric': 0.10535685385984787, 'fraction_numerical': 0.0003236769703835572, 'mean_word_length': 1.5091352009744214, 'pattern_counts': {'":': 0, '<': 61, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3569239', 'n_tokens_mistral': 1496, 'n_tokens_neox': 1450, 'n_words': 469}