Пример #1
0
        public void ResolveKeyPath(KeyPath keyPath, int depth, List <KeyPath> accumulator, KeyPath currentPartialKeyPath)
        {
            if (!keyPath.Matches(Name, depth))
            {
                return;
            }

            if (!"__container".Equals(Name))
            {
                currentPartialKeyPath = currentPartialKeyPath.AddKey(Name);

                if (keyPath.FullyResolvesTo(Name, depth))
                {
                    accumulator.Add(currentPartialKeyPath.Resolve(this));
                }
            }

            if (keyPath.PropagateToChildren(Name, depth))
            {
                int newDepth = depth + keyPath.IncrementDepthBy(Name, depth);
                for (int i = 0; i < _contents.Count; i++)
                {
                    var content = _contents[i];
                    if (content is IKeyPathElement element)
                    {
                        element.ResolveKeyPath(keyPath, newDepth, accumulator, currentPartialKeyPath);
                    }
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Helper method for any <see cref="IKeyPathElementContent"/> that will check if the content
 /// fully matches the keypath then will add itself as the final key, resolve it, and add
 /// it to the accumulator list.
 ///
 /// Any <see cref="IKeyPathElementContent"/> should call through to this as its implementation of
 /// <see cref="IKeyPathElement.ResolveKeyPath"/>.
 /// </summary>
 /// <param name="keyPath"></param>
 /// <param name="depth"></param>
 /// <param name="accumulator"></param>
 /// <param name="currentPartialKeyPath"></param>
 /// <param name="content"></param>
 public static void ResolveKeyPath(KeyPath keyPath, int depth, List <KeyPath> accumulator, KeyPath currentPartialKeyPath, IKeyPathElementContent content)
 {
     if (keyPath.FullyResolvesTo(content.Name, depth))
     {
         currentPartialKeyPath = currentPartialKeyPath.AddKey(content.Name);
         accumulator.Add(currentPartialKeyPath.Resolve(content));
     }
 }