Exemplo n.º 1
0
        internal static IEnumerable <string> InternalEnumeratePaths(
            string path,
            string searchPattern,
            SearchTarget searchTarget,
            EnumerationOptions options)
        {
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }
            if (searchPattern == null)
            {
                throw new ArgumentNullException(nameof(searchPattern));
            }

            FileSystemEnumerableFactory.NormalizeInputs(ref path, ref searchPattern, options);

            switch (searchTarget)
            {
            case SearchTarget.Files:
                return(FileSystemEnumerableFactory.UserFiles(path, searchPattern, options));

            case SearchTarget.Directories:
                return(FileSystemEnumerableFactory.UserDirectories(path, searchPattern, options));

            case SearchTarget.Both:
                return(FileSystemEnumerableFactory.UserEntries(path, searchPattern, options));

            default:
                throw new ArgumentOutOfRangeException(nameof(searchTarget));
            }
        }
Exemplo n.º 2
0
        internal static IEnumerable <string> InternalEnumeratePaths(
            string path,
            string searchPattern,
            SearchTarget searchTarget,
            EnumerationOptions options)
        {
            ArgumentNullException.ThrowIfNull(path);
            ArgumentNullException.ThrowIfNull(searchPattern);

            FileSystemEnumerableFactory.NormalizeInputs(ref path, ref searchPattern, options.MatchType);

            return(searchTarget switch
            {
                SearchTarget.Files => FileSystemEnumerableFactory.UserFiles(path, searchPattern, options),
                SearchTarget.Directories => FileSystemEnumerableFactory.UserDirectories(path, searchPattern, options),
                SearchTarget.Both => FileSystemEnumerableFactory.UserEntries(path, searchPattern, options),
                _ => throw new ArgumentOutOfRangeException(nameof(searchTarget)),
            });