コード例 #1
0
        internal static IEnumerable <FileSystemInfo> InternalEnumerateInfos(
            string path,
            string searchPattern,
            SearchTarget searchTarget,
            EnumerationOptions options)
        {
            Debug.Assert(path != null);
            if (searchPattern == null)
            {
                throw new ArgumentNullException(nameof(searchPattern));
            }

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

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

            case SearchTarget.Files:
                return(FileSystemEnumerableFactory.FileInfos(path, searchPattern, options));

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

            default:
                throw new ArgumentException(SR.ArgumentOutOfRange_Enum, nameof(searchTarget));
            }
        }
コード例 #2
0
ファイル: DirectoryInfo.cs プロジェクト: Maximys/runtime
        private IEnumerable <FileSystemInfo> InternalEnumerateInfos(
            string path,
            string searchPattern,
            SearchTarget searchTarget,
            EnumerationOptions options)
        {
            ArgumentNullException.ThrowIfNull(searchPattern);

            Debug.Assert(path != null);

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

            return(searchTarget switch
            {
                SearchTarget.Directories => FileSystemEnumerableFactory.DirectoryInfos(path, searchPattern, options, _isNormalized),
                SearchTarget.Files => FileSystemEnumerableFactory.FileInfos(path, searchPattern, options, _isNormalized),
                SearchTarget.Both => FileSystemEnumerableFactory.FileSystemInfos(path, searchPattern, options, _isNormalized),
                _ => throw new ArgumentException(SR.ArgumentOutOfRange_Enum, nameof(searchTarget)),
            });