예제 #1
0
        public void OnAdded(NamedNode child)
        {
            if (child?.LookupKey == null)
            {
                return;
            }

            EnsureCacheCreated();

            var key = new ChildrenCacheKey(child.GetType(), child.LookupKey);

            childrenCache[key] = child;
        }
예제 #2
0
        public T FindNode <T>(string name) where T : NamedNode
        {
            EnsureCacheCreated();

            var key = new ChildrenCacheKey(typeof(T), name);

            if (!childrenCache.TryGetValue(key, out var result))
            {
                for (int i = 0; i < Count; i++)
                {
                    if (this[i] is T t && t.LookupKey == name)
                    {
                        childrenCache[key] = t;
                        return(t);
                    }
                }
            }

            return((T)result);
        }
 public bool Equals(ChildrenCacheKey other)
 {
     return(_type == other._type && string.Equals(_name, other._name, StringComparison.OrdinalIgnoreCase));
 }
 public bool Equals(ChildrenCacheKey other)
 {
     return(_type == other._type && _name == other._name);
 }