namespace Qrakhen.Qamp.Core.Values.Objects; public class Structure(IEnumerable> data) : ItemProvider(ValueType.Structure) { public bool Sealed; public Dictionary Data = new(data); protected override void InnerSet(string index, Value value) { Data[index] = value; } protected override Value InnerGet(string index) { return Data[index]; } protected override void AssertValidAccesor(string index) { if (Sealed && !Data.ContainsKey(index)) throw new ItemProviderException($"Can not set non-existent key '{index}' of sealed structure.", this); } protected override string ExtractIndex(Value value) { string index; if (value.IsString) index = value.Ptr.As()!.Value!; else throw new ItemProviderException($"Can not use {value} as an accessor, as it is not a string.", this); return index; } public override string ToString() => ToString(true); public string ToString(bool detail) => detail ? $"{{{string.Join("\n,", Data)}}}" : $"Structure{{{Data.Count}}}"; }