Esempio n. 1
0
        private SegmentHierarchyNode <TItem> FindOrCreateNode(BaseUriWithWildcard baseUri)
        {
            Fx.Assert(baseUri != null, "FindOrCreateNode: baseUri is null");

            string[] path = UriSegmenter.ToPath(baseUri.BaseAddress, baseUri.HostNameComparisonMode, _includePortInComparison);
            SegmentHierarchyNode <TItem> current = _root;

            for (int i = 0; i < path.Length; ++i)
            {
                if (!current.TryGetChild(path[i], out SegmentHierarchyNode <TItem> next))
                {
                    next = new SegmentHierarchyNode <TItem>(path[i], _useWeakReferences);
                    current.SetChildNode(path[i], next);
                }
                current = next;
            }
            return(current);
        }
Esempio n. 2
0
        private SegmentHierarchyNode <TItem> FindDataNode(string[] path, out bool exactMatch)
        {
            Fx.Assert(path != null, "FindDataNode: path is null");

            exactMatch = false;
            SegmentHierarchyNode <TItem> current = _root;
            SegmentHierarchyNode <TItem> result  = null;

            for (int i = 0; i < path.Length; ++i)
            {
                if (!current.TryGetChild(path[i], out SegmentHierarchyNode <TItem> next))
                {
                    break;
                }
                else if (next.Data != null)
                {
                    result     = next;
                    exactMatch = (i == path.Length - 1);
                }
                current = next;
            }
            return(result);
        }