using System.Diagnostics;
namespace BytecodeApi.IniParser;
///
/// Represents a section of an .
///
[DebuggerDisplay($"{nameof(IniSection)}: Name = {{Name}}, Properties: {{Properties.Count}}")]
public sealed class IniSection
{
///
/// Gets or sets the name of this INI section.
///
public string? Name { get; set; }
///
/// Gets the collection of INI properties associated with this section.
///
public IniPropertyCollection Properties { get; }
///
/// Initializes a new instance of the class.
///
/// A value specifying the name of this INI section.
public IniSection(string? name)
{
Name = name;
Properties = [];
}
///
/// Retrieves an with the specified name.
///
/// A specifying the name of the .
///
/// The with the specified name, or if no matching property was found.
///
public IniProperty? Property(string name)
{
return Property(name, false);
}
///
/// Retrieves an with the specified name.
///
/// A specifying the name of the .
/// to ignore character casing during name comparison.
///
/// The with the specified name, or if no matching property was found.
///
public IniProperty? Property(string name, bool ignoreCase)
{
Check.ArgumentNull(name);
return Properties.FirstOrDefault(property => property.Name.Equals(name, ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal));
}
}