XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFESystem

【Rust】XFE系统,基于Rust和汇编

公开
关注 0 Fork 0 Star 0
UTF-8
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();
}