1
0
mirror of https://github.com/chylex/Backup-Essentials.git synced 2025-08-02 09:59:09 +02:00

Addressed some concerns by code analysis

This commit is contained in:
chylex 2015-04-30 16:35:12 +02:00
parent 0daa4b1633
commit 80cf01319a
8 changed files with 19 additions and 17 deletions

View File

@ -42,7 +42,7 @@ namespace BackupEssentials.Backup{
key = key+'=';
foreach(string line in SplitByLine(_plain)){
if (line.Length > 0 && line[0] == 'V' && line.Substring(1).StartsWith(key))return line.Substring(key.Length+1);
if (line.Length > 0 && line[0] == 'V' && line.Substring(1).StartsWith(key,StringComparison.Ordinal))return line.Substring(key.Length+1);
}
return defaultValue;
@ -52,7 +52,7 @@ namespace BackupEssentials.Backup{
key = key+'=';
foreach(string line in SplitByLine(_plain)){
if (line.Length > 0 && line[0] == 'V' && line.Substring(1).StartsWith(key)){
if (line.Length > 0 && line[0] == 'V' && line.Substring(1).StartsWith(key,StringComparison.Ordinal)){
int value;
return int.TryParse(line.Substring(key.Length+1),out value) ? value : defaultValue;
}

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
@ -52,7 +53,7 @@ namespace BackupEssentials.Backup{
bool ignoreRoot = false;
if (src[0].EndsWith(@":\")){
if (src[0].EndsWith(@":\",StringComparison.Ordinal)){
if (src.Length == 1){
srcParent = src[0];
@ -182,9 +183,9 @@ namespace BackupEssentials.Backup{
reportBuilder.Add(BackupReport.Constants.Date,Settings.Default.DateFormat.ParseDate(DateTime.Now));
reportBuilder.Add("");
reportBuilder.Add("= Files and folders =");
reportBuilder.Add(BackupReport.Constants.EntriesAdded,actions.Count((entry) => entry.Action == IOAction.Create).ToString());
reportBuilder.Add(BackupReport.Constants.EntriesUpdated,actions.Count((entry) => entry.Action == IOAction.Replace).ToString());
reportBuilder.Add(BackupReport.Constants.EntriesDeleted,actions.Count((entry) => entry.Action == IOAction.Delete).ToString());
reportBuilder.Add(BackupReport.Constants.EntriesAdded,actions.Count((entry) => entry.Action == IOAction.Create).ToString(CultureInfo.InvariantCulture));
reportBuilder.Add(BackupReport.Constants.EntriesUpdated,actions.Count((entry) => entry.Action == IOAction.Replace).ToString(CultureInfo.InvariantCulture));
reportBuilder.Add(BackupReport.Constants.EntriesDeleted,actions.Count((entry) => entry.Action == IOAction.Delete).ToString(CultureInfo.InvariantCulture));
reportBuilder.Add("");
reportBuilder.Add("= Starting backup =");

View File

@ -5,7 +5,7 @@ using System.Windows.Threading;
namespace BackupEssentials.Controls{
public class ButtonMainMenu:Button{
public static DependencyProperty ClickPageProperty = DependencyProperty.Register("ClickPage",typeof(string),typeof(ButtonMainMenu));
public static readonly DependencyProperty ClickPageProperty = DependencyProperty.Register("ClickPage",typeof(string),typeof(ButtonMainMenu));
public string ClickPage {
get { return (string)base.GetValue(ClickPageProperty); }

View File

@ -3,11 +3,11 @@ using System.Windows.Controls;
namespace BackupEssentials.Controls{
public class ButtonTitleBar:Button{
public static DependencyProperty PathDataProperty = DependencyProperty.Register("CXPathData",typeof(string),typeof(ButtonTitleBar));
public static DependencyProperty PathWidthProperty = DependencyProperty.Register("CXPathWidth",typeof(string),typeof(ButtonTitleBar));
public static DependencyProperty PathHeightProperty = DependencyProperty.Register("CXPathHeight",typeof(string),typeof(ButtonTitleBar));
public static DependencyProperty PathMarginProperty = DependencyProperty.Register("CXPathMargin",typeof(string),typeof(ButtonTitleBar));
public static DependencyProperty PathRotationProperty = DependencyProperty.Register("CXPathRotation",typeof(double),typeof(ButtonTitleBar));
public static readonly DependencyProperty PathDataProperty = DependencyProperty.Register("CXPathData",typeof(string),typeof(ButtonTitleBar));
public static readonly DependencyProperty PathWidthProperty = DependencyProperty.Register("CXPathWidth",typeof(string),typeof(ButtonTitleBar));
public static readonly DependencyProperty PathHeightProperty = DependencyProperty.Register("CXPathHeight",typeof(string),typeof(ButtonTitleBar));
public static readonly DependencyProperty PathMarginProperty = DependencyProperty.Register("CXPathMargin",typeof(string),typeof(ButtonTitleBar));
public static readonly DependencyProperty PathRotationProperty = DependencyProperty.Register("CXPathRotation",typeof(double),typeof(ButtonTitleBar));
public string CXPathData{
get { return (string)base.GetValue(PathDataProperty); }

View File

@ -29,7 +29,7 @@ namespace BackupEssentials.Data{
public string this[string key, params string[] data] {
get {
string text = this[key];
for(int a = data.Length-1; a >= 0; a--)text = text.Replace("$"+a,data[a]);
for(int a = data == null ? -1 : data.Length-1; a >= 0; a--)text = text.Replace("$"+a,data[a]);
return text;
}
}

View File

@ -36,7 +36,7 @@ namespace BackupEssentials.Pages{
private void ClickBackup(object sender, RoutedEventArgs e){
if (FileList.Length == 0 || Running)return;
if (FileList.Length == 1 && FileList[0].EndsWith(@":\")){
if (FileList.Length == 1 && FileList[0].EndsWith(@":\",StringComparison.Ordinal)){
if (MessageBox.Show(App.Window,"When backing up a drive, the contents of "+Path.GetFileName(DataStorage.BackupLocationList[LocationsListView.SelectedIndex].Directory)+" will match the contents of the drive, which means that any unwanted files and folders will be deleted. Do you want to proceed?","Drive backup warning",MessageBoxButton.YesNo,MessageBoxImage.Asterisk) != MessageBoxResult.Yes)return;
}

View File

@ -6,8 +6,8 @@ using System.Windows.Forms;
namespace BackupEssentials.Pages{
public partial class BackupEdit : Page, IPageShowData{
public BackupLocation EditLocation;
public BackupLocation TargetLocation;
public BackupLocation EditLocation { get; private set; }
public BackupLocation TargetLocation { get; private set; }
private string LastWarningDirectory;

View File

@ -2,6 +2,7 @@
using BackupEssentials.Backup.History;
using System.Collections.Generic;
using System.ComponentModel;
using System.Globalization;
using System.Windows;
using System.Windows.Controls;
@ -103,7 +104,7 @@ namespace BackupEssentials.Pages{
int kept = AppSettings.HistoryEntriesKept.Value, existing = DataStorage.HistoryEntryList.Count;
if (kept != -1 && kept < existing){
MessageBox.Show(App.Window,AppSettings.Language["Settings.Message.HistoryWarning.PartOne.",existing,existing.ToString()]+AppSettings.Language["Settings.Message.HistoryWarning.PartTwo.",existing-kept,(existing-kept).ToString()],AppSettings.Language["Settings.Message.HistoryWarning.Title"],MessageBoxButton.OK,MessageBoxImage.Exclamation);
MessageBox.Show(App.Window,AppSettings.Language["Settings.Message.HistoryWarning.PartOne.",existing,existing.ToString(CultureInfo.CurrentCulture)]+AppSettings.Language["Settings.Message.HistoryWarning.PartTwo.",existing-kept,(existing-kept).ToString(CultureInfo.CurrentCulture)],AppSettings.Language["Settings.Message.HistoryWarning.Title"],MessageBoxButton.OK,MessageBoxImage.Exclamation);
}
}
}