コード例 #1
0
ファイル: PathInformation.cs プロジェクト: wulouvre/PiWeb-Api
        /// <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
ファイル: PathInformation.cs プロジェクト: wulouvre/PiWeb-Api
        /// <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
ファイル: PathInformation.cs プロジェクト: wulouvre/PiWeb-Api
        /// <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
ファイル: PathInformation.cs プロジェクト: wulouvre/PiWeb-Api
 /// <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);
 }