Files
2026-05-31 11:06:50 +02:00

36 lines
1.4 KiB
C#

using EonaCat.FirstLight.SaveTransfer.VdfGenerator.KeyValue.Interfaces;
namespace EonaCat.FirstLight.SaveTransfer.VdfGenerator.KeyValue.Models;
/// <summary>
/// Represents a hierarchical group of key-value nodes, allowing organization of nested key-value pairs and groups.
/// </summary>
/// <param name="key">The key that identifies this group. Cannot be null.</param>
public class KeyValueGroup(string key) : IKeyValueNode
{
public string Key { get; } = key;
public List<IKeyValueNode> Nodes { get; } = [];
/// <summary>
/// Adds a new key-value pair to the group.
/// </summary>
/// <param name="key">The key to associate with the value. Cannot be null.</param>
/// <param name="value">The value to associate with the key. Cannot be null.</param>
/// <returns>The current instance with the new key-value pair added.</returns>
public KeyValueGroup Add(string key, string value)
{
Nodes.Add(new KeyValuePair(key, value));
return this;
}
/// <summary>
/// Adds the specified group to the collection of nodes.
/// </summary>
/// <param name="group">The group to add to the collection. Cannot be null.</param>
/// <returns>The current instance with the added group, enabling method chaining.</returns>
public KeyValueGroup Add(KeyValueGroup group)
{
Nodes.Add(group);
return this;
}
}