Пример #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(PathInformationDto 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="PathInformationDto"/> instance.
        /// </summary>
        public static PathInformationDto Combine(PathInformationDto path, PathElementDto elem)
        {
            if (elem == null || elem.IsEmpty)
            {
                return(path);
            }

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

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

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

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

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

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

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

            return(new PathInformationDto(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(PathInformationDto path)
 {
     return(path == null || path.IsRoot);
 }