Skip to content
This repository was archived by the owner on Oct 29, 2025. It is now read-only.

Commit bc2bd23

Browse files
committed
Post Resharper
1 parent bef2741 commit bc2bd23

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+4493
-4592
lines changed

TidyBackups/Compress.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,14 @@
2323
namespace TidyBackups
2424
{
2525
/// <summary>
26-
/// Class for the Compression logic
26+
/// Class for the Compression logic
2727
/// </summary>
2828
internal class Compress
2929
{
3030
protected internal static void Archive(string path, bool safe)
3131
{
32-
string[] files = Directory.GetFiles(path);
33-
foreach (string file in files)
32+
var files = Directory.GetFiles(path);
33+
foreach (var file in files)
3434
{
3535
if (Name.ToCompress(file))
3636
{
@@ -40,17 +40,17 @@ protected internal static void Archive(string path, bool safe)
4040
}
4141

4242
/// <summary>
43-
/// Runs logic for creating zip, it'll do a bit of last min checking first.
43+
/// Runs logic for creating zip, it'll do a bit of last min checking first.
4444
/// </summary>
4545
/// <param name="path"></param>
4646
/// <param name="safe"></param>
4747
protected internal static void CompressZip(string path, bool safe)
4848
{
49-
string dir = Name.GetDir(path);
50-
string nam = Name.GetName(path);
51-
string ext = Name.GetExt(path);
52-
DateTime created = Stamp.Get(path);
53-
string name = path.Replace(ext, ".zip");
49+
var dir = Name.GetDir(path);
50+
var nam = Name.GetName(path);
51+
var ext = Name.GetExt(path);
52+
var created = Stamp.Get(path);
53+
var name = path.Replace(ext, ".zip");
5454
if (!File.Exists(name))
5555
{
5656
Write(name, dir, nam);
@@ -67,8 +67,8 @@ protected internal static void CompressZip(string path, bool safe)
6767
else
6868
{
6969
// If the compressed file is not corrupt. We'll give it a new name, based on the time.
70-
string dt = String.Format("_{0:yyyy-MM-dd_hh-mm-ss}.zip", DateTime.Now);
71-
string newname = path.Replace(ext, dt);
70+
var dt = String.Format("_{0:yyyy-MM-dd_hh-mm-ss}.zip", DateTime.Now);
71+
var newname = path.Replace(ext, dt);
7272
Write(newname, dir, nam);
7373
Stamp.Set(newname, created);
7474
Message.Print(" COMPRESSED " + path);
@@ -79,15 +79,15 @@ protected internal static void CompressZip(string path, bool safe)
7979
}
8080

8181
/// <summary>
82-
/// Checks zip is able to be opened and valid.
82+
/// Checks zip is able to be opened and valid.
8383
/// </summary>
8484
/// <param name="path"></param>
8585
/// <param name="name"></param>
8686
/// <param name="safe"></param>
8787
/// <returns></returns>
8888
protected internal static bool Read(string path, string name, bool safe)
8989
{
90-
bool value = false;
90+
var value = false;
9191
try
9292
{
9393
using (var s = new ZipInputStream(File.OpenRead(path)))
@@ -131,7 +131,7 @@ protected internal static bool Read(string path, string name, bool safe)
131131
}
132132

133133
/// <summary>
134-
/// Creates the zip
134+
/// Creates the zip
135135
/// </summary>
136136
/// <param name="filename"></param>
137137
/// <param name="dir"></param>

TidyBackups/Days.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
11
using System;
22
using System.IO;
3+
using TidyBackups.Item;
34

45
namespace TidyBackups
56
{
6-
static class Days
7+
internal static class Days
78
{
8-
static public int Age(string TBfile)
9+
public static int Age(string TBfile)
910
{
1011
// Sets default
11-
int value = 99999;
12-
DateTime TBfileTS = new DateTime(9999, 12, 30, 12, 59, 59);
13-
DateTime Today = DateTime.Now;
12+
var value = 99999;
13+
var TBfileTS = new DateTime(9999, 12, 30, 12, 59, 59);
14+
var Today = DateTime.Now;
1415

1516
if (File.Exists(TBfile))
1617
{
17-
TBfileTS = Item.Stamp.Get(TBfile);
18-
TimeSpan diff = Today.Subtract(TBfileTS);
18+
TBfileTS = Stamp.Get(TBfile);
19+
var diff = Today.Subtract(TBfileTS);
1920
value = diff.Days;
2021
}
2122
else
@@ -24,13 +25,13 @@ static public int Age(string TBfile)
2425
Console.WriteLine(TBfile + " does not exist - Error at Tidybackups.Days.Age");
2526
}
2627

27-
#if MS_TEST
28-
// DEBUG
28+
#if MS_TEST
29+
// DEBUG
2930
Console.WriteLine(value);
3031
Console.ReadLine();
3132
#endif
3233

3334
return value;
3435
}
3536
}
36-
}
37+
}

TidyBackups/Debugging/Admin.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ protected internal static bool IsAdmin
2727
get
2828
{
2929
Thread.GetDomain().SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal);
30-
return ((WindowsPrincipal)Thread.CurrentPrincipal).IsInRole(WindowsBuiltInRole.Administrator);
30+
return ((WindowsPrincipal) Thread.CurrentPrincipal).IsInRole(WindowsBuiltInRole.Administrator);
3131
}
3232
}
3333
}
34-
}
34+
}

TidyBackups/Debugging/Assembly.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,19 @@ internal class Assembly
2424
{
2525
protected internal static string Version
2626
{
27-
get
28-
{
29-
return ((object)System.Reflection.Assembly.GetExecutingAssembly().GetName().Version).ToString();
30-
}
27+
get { return System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString(); }
3128
}
3229

3330
protected internal static string Title
3431
{
3532
get
3633
{
37-
object[] customAttributes = System.Reflection.Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), false);
34+
var customAttributes =
35+
System.Reflection.Assembly.GetExecutingAssembly()
36+
.GetCustomAttributes(typeof (AssemblyTitleAttribute), false);
3837
if (customAttributes.Length > 0)
3938
{
40-
AssemblyTitleAttribute assemblyTitleAttribute = (AssemblyTitleAttribute)customAttributes[0];
39+
var assemblyTitleAttribute = (AssemblyTitleAttribute) customAttributes[0];
4140
if (assemblyTitleAttribute.Title != "")
4241
return assemblyTitleAttribute.Title;
4342
}

TidyBackups/Debugging/Files.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
using System.IO;
19-
using TidyBackups;
2019
using TidyBackups.Item;
2120

2221
namespace TidyBackups.Debug
@@ -25,13 +24,13 @@ internal class Files
2524
{
2625
protected internal static void Filtered(string path)
2726
{
28-
foreach (string str in Directory.GetFiles(path))
27+
foreach (var str in Directory.GetFiles(path))
2928
{
3029
if (Name.Type(str))
31-
Message.Print(" " + (object)str + " - Age:" + (string)(object)Days.Age(str) + "days");
30+
Message.Print(" " + (object) str + " - Age:" + (string) (object) Days.Age(str) + "days");
3231
else
3332
Message.Print(" IGNORING: " + str);
3433
}
3534
}
3635
}
37-
}
36+
}

TidyBackups/Debugging/OS.cs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,7 @@ internal class Os
2323
{
2424
protected internal static string Version
2525
{
26-
get
27-
{
28-
return Environment.OSVersion.VersionString;
29-
}
26+
get { return Environment.OSVersion.VersionString; }
3027
}
3128
}
32-
}
29+
}

TidyBackups/Debugging/Output.cs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
*/
1717

1818
using System;
19-
using TidyBackups;
2019
using TidyBackups.Item;
2120

2221
namespace TidyBackups.Debug
@@ -38,15 +37,15 @@ internal static void Info(string[] args, bool compress, int days, string path, i
3837
Message.Print("Free space: " + Disc.FreeSpace(path));
3938
Message.Print("Username: " + Environment.UserName);
4039
Message.Print("Domain: " + Environment.UserDomainName);
41-
Message.Print("Arguments:" + Output.StrArg(args));
42-
Message.Print("Days: " + (object)days);
40+
Message.Print("Arguments:" + StrArg(args));
41+
Message.Print("Days: " + days);
4342
Message.Print("Path: " + path);
4443
Files.Filtered(path);
4544
Message.Print("Path permission: " + Permissions.View(path));
46-
Message.Print("Preserve: " + (object)preserve);
45+
Message.Print("Preserve: " + preserve);
4746
Message.Print("Safe: " + safe);
4847
Message.Print("Archive: " + compress);
49-
bool flag = true;
48+
var flag = true;
5049
if (Message.Logfile == "")
5150
flag = false;
5251
Message.Print("Log: " + flag);
@@ -58,13 +57,13 @@ internal static void Info(string[] args, bool compress, int days, string path, i
5857

5958
private static string StrArg(string[] args)
6059
{
61-
string str1 = "";
62-
for (int index = 0; index < args.Length; ++index)
60+
var str1 = "";
61+
for (var index = 0; index < args.Length; ++index)
6362
{
64-
string str2 = args[index].ToUpper();
63+
var str2 = args[index].ToUpper();
6564
str1 = str1 + " " + str2;
6665
}
6766
return str1;
6867
}
6968
}
70-
}
69+
}

TidyBackups/Exit.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@
2020
namespace TidyBackups
2121
{
2222
/// <summary>
23-
/// Exit class
23+
/// Exit class
2424
/// </summary>
2525
internal class Exit
2626
{
2727
/// <summary>
28-
/// Exits safely, will produce exit message and exit code.
28+
/// Exits safely, will produce exit message and exit code.
2929
/// </summary>
3030
/// <param name="code"></param>
3131
protected internal static void End(int code)
@@ -45,7 +45,7 @@ protected internal static void End(int code)
4545
}
4646

4747
/// <summary>
48-
/// Makes exit codes friendly.
48+
/// Makes exit codes friendly.
4949
/// </summary>
5050
/// <param name="code"></param>
5151
/// <returns></returns>

TidyBackups/Filter.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ namespace TidyBackups
2525
internal class Filter
2626
{
2727
/// <summary>
28-
/// This is really messy.
28+
/// This is really messy.
2929
/// </summary>
3030
/// <param name="path"></param>
3131
/// <param name="preserve"></param>
@@ -34,8 +34,8 @@ protected internal static ArrayList Filtered(string path, int preserve)
3434
{
3535
var unfilteredFiles = new ArrayList();
3636

37-
string[] files = Directory.GetFiles(path);
38-
foreach (string file in files) // note: file is full path
37+
var files = Directory.GetFiles(path);
38+
foreach (var file in files) // note: file is full path
3939
{
4040
if (Name.Type(file))
4141
{
@@ -58,8 +58,8 @@ protected internal static ArrayList Filtered(string path, int preserve)
5858
// Popular the database Hashtable
5959
foreach (string file in unfilteredFiles)
6060
{
61-
string filename = Name.GetName(file);
62-
string db = Default.Database(filename);
61+
var filename = Name.GetName(file);
62+
var db = Default.Database(filename);
6363
if (db != null)
6464
{
6565
// Adds db to the dbs Hashtable
@@ -73,17 +73,17 @@ protected internal static ArrayList Filtered(string path, int preserve)
7373
{
7474
foreach (string file in unfilteredFiles)
7575
{
76-
string t1 = Default.Database(Name.GetName(file));
77-
string t2 = db.Key.ToString();
76+
var t1 = Default.Database(Name.GetName(file));
77+
var t2 = db.Key.ToString();
7878
if (t1 == t2)
7979
{
8080
tmp.Add(Stamp.Get(file) + @"|" + file);
8181
}
8282
}
8383
tmp.Reverse();
84-
for (int i = 0; i < tmp.Count; i++)
84+
for (var i = 0; i < tmp.Count; i++)
8585
{
86-
int c = i + 1;
86+
var c = i + 1;
8787
var value = tmp[i] as string;
8888
if (c > preserve)
8989
{
@@ -110,14 +110,14 @@ protected internal static ArrayList Filtered(string path, int preserve)
110110
}
111111

112112
/// <summary>
113-
/// clean
114-
/// Because this is a messy way of working, we have to clean our faces as we go
113+
/// clean
114+
/// Because this is a messy way of working, we have to clean our faces as we go
115115
/// </summary>
116116
/// <param name="value"></param>
117117
/// <returns></returns>
118118
private static string Clean(string value)
119119
{
120-
string[] parts = value.Split('|');
120+
var parts = value.Split('|');
121121
return parts[1];
122122
}
123123
}

TidyBackups/Global.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,15 @@
2020
namespace TidyBackups
2121
{
2222
/// <summary>
23-
///
2423
/// </summary>
2524
internal class Global
2625
{
2726
/// <summary>
28-
/// Debug is a Boolean, it is used to hold wheither the application is in "debug" mode.
29-
/// If set to true, it will not perform any actual work, it will operate in report mode. It
30-
/// will output basic information about the system, what settings have been set, what it files
31-
/// it can "see", what files it's going to ignore. What files would to be compressed, if the
32-
/// /ZIP switch is used, what the /LOG will be be, again, if set.
27+
/// Debug is a Boolean, it is used to hold wheither the application is in "debug" mode.
28+
/// If set to true, it will not perform any actual work, it will operate in report mode. It
29+
/// will output basic information about the system, what settings have been set, what it files
30+
/// it can "see", what files it's going to ignore. What files would to be compressed, if the
31+
/// /ZIP switch is used, what the /LOG will be be, again, if set.
3332
/// </summary>
3433
protected internal static bool Debug;
3534

0 commit comments

Comments
 (0)