System.Configuration.UrlPath.IsEqualOrSubpath C# (CSharp) Метод

IsEqualOrSubpath() статический приватный Метод

static private IsEqualOrSubpath ( string path, string subpath ) : bool
path string
subpath string
Результат bool
        internal static bool IsEqualOrSubpath(string path, string subpath) {
            if (String.IsNullOrEmpty(path))
                return true;

            if (String.IsNullOrEmpty(subpath))
                return false;

            //
            // Compare up to but not including trailing slash
            //
            int lPath = path.Length;
            if (path[lPath - 1] == '/') {
                lPath -= 1;
            }

            int lSubpath = subpath.Length;
            if (subpath[lSubpath - 1] == '/') {
                lSubpath -= 1;
            }

            if (lSubpath < lPath)
                return false;

            if (String.Compare(path, 0, subpath, 0, lPath, StringComparison.OrdinalIgnoreCase) != 0)
                return false;

            // Check subpath that character following length of path is a slash
            if (lSubpath > lPath && subpath[lPath] != '/')
                return false;

            return true;
        }