//
// DatItem.cs
//
// Copyright (c) František Boháček. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
namespace NosSmooth.Data.NOSFiles.Parsers.Dat;
///
/// An item from a dat file obtained using .
///
public struct DatItem
{
private readonly IReadOnlyDictionary> _entries;
///
/// Initializes a new instance of the struct.
///
/// The entries of the item.
public DatItem(IReadOnlyDictionary> entries)
{
_entries = entries;
}
///
/// Gets the entry with the given name.
///
/// The name of the entry.
/// An entry, or null, if not found.
public DatEntry? GetNullableEntry(string name)
{
return GetEntries(name)?.FirstOrDefault() ?? null;
}
///
/// Gets the entry with the given name.
///
/// The name of the entry.
/// An entry, or null, if not found.
public DatEntry GetEntry(string name)
{
return GetEntries(name).First();
}
///
/// Gets the entry with the given name.
///
/// The name of the entry.
/// An entry, or null, if not found.
public IReadOnlyList GetEntries(string name)
{
if (!_entries.ContainsKey(name))
{
return Array.Empty();
}
return _entries[name];
}
}