Skip to content

Commit 39af851

Browse files
VLADVLAD
VLAD
authored and
VLAD
committed
Some exceptions have been added.
1 parent ad4fcc0 commit 39af851

File tree

4 files changed

+34
-20
lines changed

4 files changed

+34
-20
lines changed

FastSearchLibrary/DirectorySearcher/DirectorySearcherMultiple.cs

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using System.IO;
4-
using System.Linq;
5-
using System.Text;
64
using System.Threading;
75
using System.Threading.Tasks;
86

@@ -75,9 +73,8 @@ protected virtual void OnSearchCompleted(bool isCanceled)
7573
/// <exception cref="ArgumentException"></exception>
7674
/// <exception cref="ArgumentNullException"></exception>
7775
public DirectorySearcherMultiple(List<string> folders, Func<DirectoryInfo, bool> isValid, CancellationTokenSource tokenSource, ExecuteHandlers handlerOption, bool suppressOperationCanceledException)
78-
{
79-
foreach (var folder in folders)
80-
CheckFolder(folder);
76+
{
77+
CheckFolders(folders);
8178

8279
CheckDelegate(isValid);
8380

@@ -142,9 +139,7 @@ public DirectorySearcherMultiple(List<string> folders, Func<DirectoryInfo, bool>
142139
/// <exception cref="ArgumentNullException"></exception>
143140
public DirectorySearcherMultiple(List<string> folders, string pattern, CancellationTokenSource tokenSource, ExecuteHandlers handlerOption, bool suppressOperationCanceledException)
144141
{
145-
146-
foreach (var folder in folders)
147-
CheckFolder(folder);
142+
CheckFolders(folders);
148143

149144
CheckPattern(pattern);
150145

@@ -209,6 +204,19 @@ public DirectorySearcherMultiple(List<string> folders, CancellationTokenSource t
209204

210205

211206
#region Checking methods
207+
208+
private void CheckFolders(List<string> folders)
209+
{
210+
if (folders == null)
211+
throw new ArgumentNullException(nameof(folders), "Argument is null.");
212+
213+
if (folders.Count == 0)
214+
throw new ArgumentException("Argument is an empty list.", nameof(folders));
215+
216+
foreach (var folder in folders)
217+
CheckFolder(folder);
218+
}
219+
212220

213221
private void CheckFolder(string folder)
214222
{

FastSearchLibrary/FastSearchLibrary.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1616
<DebugSymbols>true</DebugSymbols>
1717
<DebugType>full</DebugType>
18-
<Optimize>false</Optimize>
18+
<Optimize>true</Optimize>
1919
<OutputPath>bin\Debug\</OutputPath>
2020
<DefineConstants>DEBUG;TRACE</DefineConstants>
2121
<ErrorReport>prompt</ErrorReport>

FastSearchLibrary/FileSearcher/FileSearcherMultiple.cs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
using System;
22
using System.Collections.Generic;
33
using System.IO;
4-
using System.Linq;
5-
using System.Text;
64
using System.Threading;
75
using System.Threading.Tasks;
86

@@ -74,9 +72,8 @@ protected virtual void OnSearchCompleted(bool isCanceled)
7472
/// <exception cref="ArgumentException"></exception>
7573
/// <exception cref="ArgumentNullException"></exception>
7674
public FileSearcherMultiple(List<string> folders, Func<FileInfo, bool> isValid, CancellationTokenSource tokenSource, ExecuteHandlers handlerOption, bool suppressOperationCanceledException)
77-
{
78-
foreach (var folder in folders)
79-
CheckFolder(folder);
75+
{
76+
CheckFolders(folders);
8077

8178
CheckDelegate(isValid);
8279

@@ -140,9 +137,7 @@ public FileSearcherMultiple(List<string> folders, Func<FileInfo, bool> isValid,
140137
/// <exception cref="ArgumentNullException"></exception>
141138
public FileSearcherMultiple(List<string> folders, string pattern, CancellationTokenSource tokenSource, ExecuteHandlers handlerOption, bool suppressOperationCanceledException)
142139
{
143-
144-
foreach (var folder in folders)
145-
CheckFolder(folder);
140+
CheckFolders(folders);
146141

147142
CheckPattern(pattern);
148143

@@ -206,6 +201,18 @@ public FileSearcherMultiple(List<string> folders, CancellationTokenSource tokenS
206201

207202

208203
#region Checking methods
204+
private void CheckFolders(List<string> folders)
205+
{
206+
if (folders == null)
207+
throw new ArgumentNullException(nameof(folders), "Argument is null.");
208+
209+
if (folders.Count == 0)
210+
throw new ArgumentException("Argument is an empty list.", nameof(folders));
211+
212+
foreach (var folder in folders)
213+
CheckFolder(folder);
214+
}
215+
209216

210217
private void CheckFolder(string folder)
211218
{

FastSearchLibrary/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Reflection;
2-
using System.Runtime.CompilerServices;
32
using System.Runtime.InteropServices;
43

54
// General Information about an assembly is controlled through the following
@@ -32,5 +31,5 @@
3231
// You can specify all the values or you can default the Build and Revision Numbers
3332
// by using the '*' as shown below:
3433
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.1.6.0")]
36-
[assembly: AssemblyFileVersion("1.1.6.0")]
34+
[assembly: AssemblyVersion("1.1.6.1")]
35+
[assembly: AssemblyFileVersion("1.1.6.1")]

0 commit comments

Comments
 (0)