Пример #1
0
        /// <summary> Checks if this path is below <paramref name="path"/> or is equal to <paramref name="path"/>.
        /// Also checks the path elements type!
        /// </summary>
        public bool IsBelow(PathInformation path)
        {
            if (path == null || path.Count > Count)
            {
                return(false);
            }

            return(!path.Where((t, i) => !this[i].Equals(t)).Any());
        }
Пример #2
0
        /// <summary>
        /// Combines the path <paramref name="path"/> and the path element <paramref name="elem"/> to a new <see cref="PathInformation"/> instance.
        /// </summary>
        public static PathInformation Combine(PathInformation path, PathElement elem)
        {
            if (elem == null || elem.IsEmpty)
            {
                return(path);
            }

            if (path == null)
            {
                return(new PathInformation(elem));
            }

            var newpath = new List <PathElement>(path.Count + 1);

            newpath.AddRange(path);
            newpath.Add(elem);

            return(new PathInformation(newpath));
        }
Пример #3
0
        /// <summary>
        /// Combines the path <paramref name="p1"/> and the path <paramref name="p2"/> to a new <see cref="PathInformation"/> instance.
        /// </summary>
        public static PathInformation Combine(PathInformation p1, PathInformation p2)
        {
            if (p1 == null || p1.IsRoot)
            {
                return(p2);
            }

            if (p2 == null || p2.IsRoot)
            {
                return(p1);
            }

            var newpath = new List <PathElement>(p1.Count + p2.Count);

            newpath.AddRange(p1);
            newpath.AddRange(p2);

            return(new PathInformation(newpath));
        }
Пример #4
0
 /// <summary> Checks if the <paramref name="path"/> is <code>null</code> or the root part. </summary>
 /// <returns>True, if the <paramref name="path"/> is <code>null</code> or the root part otherwise false.</returns>
 public static bool IsNullOrRoot(PathInformation path)
 {
     return(path == null || path.IsRoot);
 }