Skip to content

Commit 5691240

Browse files
committed
RECS0091: Use 'var' keyword
1 parent d0e305f commit 5691240

7 files changed

Lines changed: 30 additions & 30 deletions

File tree

ICSharpCode.SharpZipLib.Samples/cs/CreateZipFile/CreateZipFile.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public static void Main(string[] args)
6969

7070
// Using GetFileName makes the result compatible with XP
7171
// as the resulting path is not absolute.
72-
ZipEntry entry = new ZipEntry(Path.GetFileName(file));
72+
var entry = new ZipEntry(Path.GetFileName(file));
7373

7474
// Setup the entry data as required.
7575

ICSharpCode.SharpZipLib.Samples/cs/FastZip/Main.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ enum Operation
4747
static void ListZipFile(string fileName, string fileFilter, string directoryFilter)
4848
{
4949
using (ZipFile zipFile = new ZipFile(fileName)) {
50-
PathFilter localFileFilter = new PathFilter(fileFilter);
51-
PathFilter localDirFilter = new PathFilter(directoryFilter);
50+
var localFileFilter = new PathFilter(fileFilter);
51+
var localDirFilter = new PathFilter(directoryFilter);
5252

5353
if ( zipFile.Count == 0 ) {
5454
Console.WriteLine("No entries to list");
@@ -92,7 +92,7 @@ void ListDir(object sender, DirectoryEventArgs e)
9292

9393
void ListFileSystem(string directory, bool recurse, string fileFilter, string directoryFilter)
9494
{
95-
FileSystemScanner scanner = new FileSystemScanner(fileFilter, directoryFilter);
95+
var scanner = new FileSystemScanner(fileFilter, directoryFilter);
9696
scanner.ProcessDirectory += new ProcessDirectoryHandler(ListDir);
9797
scanner.ProcessFile += new ProcessFileHandler(ListFile);
9898
scanner.Scan(directory, recurse);
@@ -304,7 +304,7 @@ void Run(string[] args)
304304
}
305305
}
306306

307-
FastZip fastZip = new FastZip(events);
307+
var fastZip = new FastZip(events);
308308
fastZip.CreateEmptyDirectories = createEmptyDirs;
309309
fastZip.RestoreAttributesOnExtract = restoreAttributes;
310310
fastZip.RestoreDateTimeOnExtract = restoreDates;
@@ -376,7 +376,7 @@ void Run(string[] args)
376376
/// <param name="args">The arguments provided to this process.</param>
377377
public static void Main(string[] args)
378378
{
379-
MainClass main = new MainClass();
379+
var main = new MainClass();
380380
main.Run(args);
381381
}
382382
}

ICSharpCode.SharpZipLib.Samples/cs/minibzip2/Main.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public Command Command
143143
public static void Main(string[] args)
144144
{
145145

146-
ArgumentParser parser = new ArgumentParser(args);
146+
var parser = new ArgumentParser(args);
147147

148148
switch ( parser.Command ) {
149149
case Command.Help:

ICSharpCode.SharpZipLib.Samples/cs/minigzip/Main.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public static void Main(string[] args)
145145
{
146146
byte[] dataBuffer = new byte[4096];
147147

148-
ArgumentParser parser = new ArgumentParser(args);
148+
var parser = new ArgumentParser(args);
149149

150150
switch ( parser.Command ) {
151151
case Command.Compress:

ICSharpCode.SharpZipLib.Samples/cs/sz/sz.cs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ bool SetArgs(string[] args) {
476476
}
477477

478478
if (fileSpecs.Count > 0 && operation == Operation.Create) {
479-
string checkPath = (string)fileSpecs[0];
479+
var checkPath = (string)fileSpecs[0];
480480
int deviceCheck = checkPath.IndexOf(':');
481481
#if NETCF_1_0
482482
if (checkPath.IndexOfAny(Path.InvalidPathChars) >= 0
@@ -603,7 +603,7 @@ void ListZip(string fileName) {
603603
const string headerTitles = "Name Length Ratio Size Date & time CRC-32";
604604
const string headerUnderline = "--------------- ---------- ----- ---------- ------------------- --------";
605605

606-
FileInfo fileInfo = new FileInfo(fileName);
606+
var fileInfo = new FileInfo(fileName);
607607

608608
if (fileInfo.Exists == false) {
609609
Console.WriteLine("No such file exists {0}", fileName);
@@ -682,7 +682,7 @@ void ListZipViaZipFile(string fileName) {
682682
const string headerTitles = "Name Length Ratio Size Date & time CRC-32 Attr";
683683
const string headerUnderline = "------------ ---------- ----- ---------- ------------------- -------- ------";
684684

685-
FileInfo fileInfo = new FileInfo(fileName);
685+
var fileInfo = new FileInfo(fileName);
686686

687687
if (fileInfo.Exists == false) {
688688
Console.WriteLine("No such file exists {0}", fileName);
@@ -837,8 +837,8 @@ string CookZipEntryName(string name)
837837
/// </summary>
838838
void AddFileSeekableOutput(string file, string entryPath)
839839
{
840-
ZipEntry entry = new ZipEntry(entryPath);
841-
FileInfo fileInfo = new FileInfo(file);
840+
var entry = new ZipEntry(entryPath);
841+
var fileInfo = new FileInfo(file);
842842
entry.DateTime = fileInfo.LastWriteTime; // or DateTime.Now or whatever, for now use the file
843843
entry.ExternalFileAttributes = (int)fileInfo.Attributes;
844844
entry.Size = fileInfo.Length;
@@ -904,7 +904,7 @@ void AddFolder(string folderName)
904904
folderName = folderName + '/';
905905
}
906906

907-
ZipEntry zipEntry = new ZipEntry(folderName);
907+
var zipEntry = new ZipEntry(folderName);
908908
outputStream.PutNextEntry(zipEntry);
909909
}
910910

@@ -947,7 +947,7 @@ int CompressFolder(string basePath, bool recursiveSearch, string searchPattern)
947947
/// </summary>
948948
void Create(ArrayList fileSpecifications)
949949
{
950-
string zipFileName = fileSpecifications[0] as string;
950+
var zipFileName = fileSpecifications[0] as string;
951951
if (Path.GetExtension(zipFileName).Length == 0) {
952952
zipFileName = Path.ChangeExtension(zipFileName, ".zip");
953953
}
@@ -1162,7 +1162,7 @@ void Extract(ArrayList fileSpecifications)
11621162

11631163
void Test(ArrayList fileSpecs)
11641164
{
1165-
string zipFileName = fileSpecs[0] as string;
1165+
var zipFileName = fileSpecs[0] as string;
11661166
if (Path.GetExtension(zipFileName).Length == 0) {
11671167
zipFileName = Path.ChangeExtension(zipFileName, ".zip");
11681168
}
@@ -1182,7 +1182,7 @@ void Test(ArrayList fileSpecs)
11821182
/// <param name="fileSpecs">The file specs to operate on.</param>
11831183
void Delete(ArrayList fileSpecs)
11841184
{
1185-
string zipFileName = fileSpecs[0] as string;
1185+
var zipFileName = fileSpecs[0] as string;
11861186
if (Path.GetExtension(zipFileName).Length == 0) {
11871187
zipFileName = Path.ChangeExtension(zipFileName, ".zip");
11881188
}
@@ -1198,7 +1198,7 @@ void Delete(ArrayList fileSpecs)
11981198

11991199
void Add(ArrayList fileSpecs)
12001200
{
1201-
string zipFileName = fileSpecs[0] as string;
1201+
var zipFileName = fileSpecs[0] as string;
12021202
if (Path.GetExtension(zipFileName).Length == 0) {
12031203
zipFileName = Path.ChangeExtension(zipFileName, ".zip");
12041204
}
@@ -1264,7 +1264,7 @@ void Execute(string[] args) {
12641264
/// </param>
12651265
public static void Main(string[] args) {
12661266

1267-
SharpZipArchiver sza = new SharpZipArchiver();
1267+
var sza = new SharpZipArchiver();
12681268
sza.Execute(args);
12691269
}
12701270

ICSharpCode.SharpZipLib.Samples/cs/tar/tar.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public Tar()
142142
/// </summary>
143143
public static void Main(string[] argv)
144144
{
145-
Tar tarApp = new Tar();
145+
var tarApp = new Tar();
146146
tarApp.InstanceMain(argv);
147147
}
148148

@@ -555,7 +555,7 @@ static string DecodeMode(int mode)
555555
const int S_IXOTH = 0x0001;
556556

557557

558-
System.Text.StringBuilder result = new System.Text.StringBuilder();
558+
var result = new System.Text.StringBuilder();
559559
result.Append((mode & S_IRUSR) != 0 ? 'r' : '-');
560560
result.Append((mode & S_IWUSR) != 0 ? 'w' : '-');
561561
result.Append((mode & S_ISUID) != 0

ICSharpCode.SharpZipLib.Samples/cs/zf/zf.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ bool SetArgs(string[] args)
353353

354354
if (fileSpecs_.Count > 0)
355355
{
356-
string checkPath = (string)fileSpecs_[0];
356+
var checkPath = (string)fileSpecs_[0];
357357
int deviceCheck = checkPath.IndexOf(':');
358358
#if NET_VER_1
359359
if (checkPath.IndexOfAny(Path.InvalidPathChars) >= 0
@@ -544,7 +544,7 @@ void ListArchiveContents(string fileName)
544544
{
545545
try
546546
{
547-
FileInfo fileInfo = new FileInfo(fileName);
547+
var fileInfo = new FileInfo(fileName);
548548

549549
if (!fileInfo.Exists)
550550
{
@@ -616,7 +616,7 @@ void List(ArrayList fileSpecs)
616616
/// </summary>
617617
void Create(ArrayList fileSpecs)
618618
{
619-
string zipFileName = fileSpecs[0] as string;
619+
var zipFileName = fileSpecs[0] as string;
620620
if (Path.GetExtension(zipFileName).Length == 0)
621621
{
622622
zipFileName = Path.ChangeExtension(zipFileName, ".zip");
@@ -649,7 +649,7 @@ void Create(ArrayList fileSpecs)
649649

650650
zf.NameTransform = new ZipNameTransform(path);
651651

652-
FileSystemScanner scanner = new FileSystemScanner(WildcardToRegex(fileSpec));
652+
var scanner = new FileSystemScanner(WildcardToRegex(fileSpec));
653653
scanner.ProcessFile = new ProcessFileHandler(ProcessFile);
654654
scanner.ProcessDirectory = new ProcessDirectoryHandler(ProcessDirectory);
655655
scanner.Scan(path, recursive_);
@@ -962,7 +962,7 @@ void TestResultHandler(TestStatus status, string message)
962962
/// <param name="fileSpecs">The files to test.</param>
963963
void Test(ArrayList fileSpecs)
964964
{
965-
string zipFileName = fileSpecs[0] as string;
965+
var zipFileName = fileSpecs[0] as string;
966966
if (Path.GetExtension(zipFileName).Length == 0)
967967
{
968968
zipFileName = Path.ChangeExtension(zipFileName, ".zip");
@@ -1000,7 +1000,7 @@ void Test(ArrayList fileSpecs)
10001000
/// <param name="fileSpecs">The file specs to operate on.</param>
10011001
void Delete(ArrayList fileSpecs)
10021002
{
1003-
string zipFileName = fileSpecs[0] as string;
1003+
var zipFileName = fileSpecs[0] as string;
10041004
if (Path.GetExtension(zipFileName).Length == 0)
10051005
{
10061006
zipFileName = Path.ChangeExtension(zipFileName, ".zip");
@@ -1063,7 +1063,7 @@ void ProcessDirectory(object sender, DirectoryEventArgs args)
10631063
/// <param name="fileSpecs">The specification for files to add.</param>
10641064
void Add(ArrayList fileSpecs)
10651065
{
1066-
string zipFileName = fileSpecs[0] as string;
1066+
var zipFileName = fileSpecs[0] as string;
10671067
if (Path.GetExtension(zipFileName).Length == 0)
10681068
{
10691069
zipFileName = Path.ChangeExtension(zipFileName, ".zip");
@@ -1100,7 +1100,7 @@ void Add(ArrayList fileSpecs)
11001100

11011101
zipFile.NameTransform = new ZipNameTransform(path);
11021102

1103-
FileSystemScanner scanner = new FileSystemScanner(WildcardToRegex(fileSpec));
1103+
var scanner = new FileSystemScanner(WildcardToRegex(fileSpec));
11041104
scanner.ProcessFile = new ProcessFileHandler(ProcessFile);
11051105
scanner.ProcessDirectory = new ProcessDirectoryHandler(ProcessDirectory);
11061106
scanner.Scan(path, recursive_);
@@ -1397,7 +1397,7 @@ static string WildcardToRegex(string wildcard)
13971397
/// </param>
13981398
public static void Main(string[] args)
13991399
{
1400-
ZipFileArchiver zf = new ZipFileArchiver();
1400+
var zf = new ZipFileArchiver();
14011401
zf.Execute(args);
14021402
}
14031403

0 commit comments

Comments
 (0)