using System.Collections;
namespace XFESystem.Browser;
/// <summary>A computed declaration map with a shared, immutable custom-property
/// environment. Descendants without overrides do not copy the whole theme.</summary>
internal sealed class CssPropertyMap(IReadOnlyDictionary<string, string> own, IReadOnlyDictionary<string, string> custom)
: IReadOnlyDictionary<string, string>
{
public int Count => own.Count + custom.Count;
public IEnumerable<string> Keys => own.Keys.Concat(custom.Keys);
public IEnumerable<string> Values => own.Values.Concat(custom.Values);
public string this[string key] => TryGetValue(key, out var value) ? value : throw new KeyNotFoundException();
public bool ContainsKey(string key) => own.ContainsKey(key) || custom.ContainsKey(key);
public bool TryGetValue(string key, out string value) => own.TryGetValue(key, out value!) || custom.TryGetValue(key, out value!);
public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
{
foreach (var pair in own) yield return pair;
foreach (var pair in custom) yield return pair;
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}
using System.Collections;
namespace XFESystem.Browser;
/// <summary>A computed declaration map with a shared, immutable custom-property
/// environment. Descendants without overrides do not copy the whole theme.</summary>
internal sealed class CssPropertyMap(IReadOnlyDictionary<string, string> own, IReadOnlyDictionary<string, string> custom)
: IReadOnlyDictionary<string, string>
{
public int Count => own.Count + custom.Count;
public IEnumerable<string> Keys => own.Keys.Concat(custom.Keys);
public IEnumerable<string> Values => own.Values.Concat(custom.Values);
public string this[string key] => TryGetValue(key, out var value) ? value : throw new KeyNotFoundException();
public bool ContainsKey(string key) => own.ContainsKey(key) || custom.ContainsKey(key);
public bool TryGetValue(string key, out string value) => own.TryGetValue(key, out value!) || custom.TryGetValue(key, out value!);
public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
{
foreach (var pair in own) yield return pair;
foreach (var pair in custom) yield return pair;
}
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
}