From d195c8838a809454320bdeca18c64e0af9ea3c3d Mon Sep 17 00:00:00 2001 From: Mark Summerville Date: Mon, 8 Jan 2018 08:17:37 +0800 Subject: [PATCH] Resharper auto this. changes --- .../ItemsAndActions/ActionCopyMoveRename.cs | 96 +++++++++---------- 1 file changed, 46 insertions(+), 50 deletions(-) diff --git a/TVRename#/ItemsAndActions/ActionCopyMoveRename.cs b/TVRename#/ItemsAndActions/ActionCopyMoveRename.cs index c25902be6..2cf7c2a08 100644 --- a/TVRename#/ItemsAndActions/ActionCopyMoveRename.cs +++ b/TVRename#/ItemsAndActions/ActionCopyMoveRename.cs @@ -7,10 +7,6 @@ namespace TVRename using Alphaleonis.Win32.Filesystem; using System; using System.Windows.Forms; - using File = File; - using FileInfo = FileInfo; - using FileSystemInfo = FileSystemInfo; - public class ActionCopyMoveRename : ActionFileOperation { @@ -32,12 +28,12 @@ public enum Op public ActionCopyMoveRename(Op operation, FileInfo from, FileInfo to, ProcessedEpisode ep, TidySettings tidyup) { - this._tidyup = tidyup; - this.PercentDone = 0; - this.Episode = ep; - this.Operation = operation; - this.From = from; - this.To = to; + _tidyup = tidyup; + PercentDone = 0; + Episode = ep; + Operation = operation; + From = from; + To = to; } #region Action Members @@ -46,7 +42,7 @@ public ActionCopyMoveRename(Op operation, FileInfo from, FileInfo to, ProcessedE public override string Name => IsMoveRename() ? "Move" : "Copy"; - public override string ProgressText => this.To.Name; + public override string ProgressText => To.Name; // 0.0 to 100.0 @@ -58,7 +54,7 @@ public override bool Go(ref bool pause, TVRenameStats stats) FileSecurity security = null; try { - security = this.From.GetAccessControl(); + security = From.GetAccessControl(); } catch { @@ -68,32 +64,32 @@ public override bool Go(ref bool pause, TVRenameStats stats) try { //we use a temp name just in case we are interruted or some other problem occurs - string tempName = TempFor(this.To); + string tempName = TempFor(To); // If both full filenames are the same then we want to move it away and back //This deals with an issue on some systems (XP?) that case insensitive moves did not occur - if (IsMoveRename() || FileHelper.Same(this.From, this.To)) + if (IsMoveRename() || FileHelper.Same(From, To)) { // This step could be slow, so report progress - CopyMoveResult moveResult = File.Move(this.From.FullName, tempName, MoveOptions.CopyAllowed | MoveOptions.ReplaceExisting, CopyProgressCallback, null); + CopyMoveResult moveResult = File.Move(From.FullName, tempName, MoveOptions.CopyAllowed | MoveOptions.ReplaceExisting, CopyProgressCallback, null); if (moveResult.ErrorCode != 0) throw new Exception(moveResult.ErrorMessage); } else { //we are copying - Debug.Assert(this.Operation == Op.Copy); + Debug.Assert(Operation == Op.Copy); // This step could be slow, so report progress - CopyMoveResult copyResult = File.Copy(this.From.FullName, tempName, CopyOptions.None, true, CopyProgressCallback, null); + CopyMoveResult copyResult = File.Copy(From.FullName, tempName, CopyOptions.None, true, CopyProgressCallback, null); if (copyResult.ErrorCode != 0) throw new Exception(copyResult.ErrorMessage); } // Copying the temp file into the correct name is very quick, so no progress reporting - File.Move(tempName, this.To.FullName, MoveOptions.ReplaceExisting); + File.Move(tempName, To.FullName, MoveOptions.ReplaceExisting); - this.Done = true; + Done = true; - switch (this.Operation) + switch (Operation) { case Op.Move: stats.FilesMoved++; @@ -111,32 +107,32 @@ public override bool Go(ref bool pause, TVRenameStats stats) } catch (Exception e) { - this.Done = true; - this.Error = true; - this.ErrorText = e.Message; + Done = true; + Error = true; + ErrorText = e.Message; } // set NTFS permissions try { - if (security != null) this.To.SetAccessControl(security); + if (security != null) To.SetAccessControl(security); } catch { // ignored } - if (this.Operation == Op.Move && this._tidyup != null && this._tidyup.DeleteEmpty) + if (Operation == Op.Move && _tidyup != null && _tidyup.DeleteEmpty) { - DoTidyup(this.From.Directory ); + DoTidyup(From.Directory ); } - return !this.Error; + return !Error; } - public override string produces => this.To.FullName; + public override string produces => To.FullName; #region Item Members @@ -144,19 +140,19 @@ public override bool SameAs(Item o) { ActionCopyMoveRename cmr = o as ActionCopyMoveRename; - return (cmr != null) && (this.Operation == cmr.Operation) && FileHelper.Same(this.From, cmr.From) && - FileHelper.Same(this.To, cmr.To); + return (cmr != null) && (Operation == cmr.Operation) && FileHelper.Same(From, cmr.From) && + FileHelper.Same(To, cmr.To); } public override int Compare(Item o) { ActionCopyMoveRename cmr = o as ActionCopyMoveRename; - if (cmr == null || this.From.Directory == null || this.To.Directory == null || cmr.From.Directory == null || + if (cmr == null || From.Directory == null || To.Directory == null || cmr.From.Directory == null || cmr.To.Directory == null) return 0; - string s1 = this.From.FullName + (this.From.Directory.Root.FullName != this.To.Directory.Root.FullName ? "0" : "1"); + string s1 = From.FullName + (From.Directory.Root.FullName != To.Directory.Root.FullName ? "0" : "1"); string s2 = cmr.From.FullName + (cmr.From.Directory.Root.FullName != cmr.To.Directory.Root.FullName ? "0" : "1"); @@ -171,7 +167,7 @@ public override int Compare(Item o) - public override IgnoreItem Ignore => this.To == null ? null : new IgnoreItem(this.To.FullName); + public override IgnoreItem Ignore => To == null ? null : new IgnoreItem(To.FullName); #endregion public override ListViewItem ScanListViewItem @@ -180,7 +176,7 @@ public override ListViewItem ScanListViewItem { ListViewItem lvi = new ListViewItem(); - if (this.Episode == null) + if (Episode == null) { lvi.Text = ""; lvi.SubItems.Add(""); @@ -190,20 +186,20 @@ public override ListViewItem ScanListViewItem } else { - lvi.Text = this.Episode.TheSeries.Name; - lvi.SubItems.Add(this.Episode.SeasonNumber.ToString()); - lvi.SubItems.Add(this.Episode.NumsAsString()); - DateTime? dt = this.Episode.GetAirDateDT(true); + lvi.Text = Episode.TheSeries.Name; + lvi.SubItems.Add(Episode.SeasonNumber.ToString()); + lvi.SubItems.Add(Episode.NumsAsString()); + DateTime? dt = Episode.GetAirDateDT(true); if ((dt != null) && (dt.Value.CompareTo(DateTime.MaxValue) != 0)) lvi.SubItems.Add(dt.Value.ToShortDateString()); else lvi.SubItems.Add(""); } - lvi.SubItems.Add(this.From.DirectoryName); - lvi.SubItems.Add(this.From.Name); - lvi.SubItems.Add(this.To.DirectoryName); - lvi.SubItems.Add(this.To.Name); + lvi.SubItems.Add(From.DirectoryName); + lvi.SubItems.Add(From.Name); + lvi.SubItems.Add(To.DirectoryName); + lvi.SubItems.Add(To.Name); return lvi; } @@ -213,7 +209,7 @@ public override string ScanListViewGroup { get { - switch (this.Operation) + switch (Operation) { case Op.Rename: return "lvgActionRename"; @@ -227,7 +223,7 @@ public override string ScanListViewGroup } } - public override string TargetFolder => this.To?.DirectoryName; + public override string TargetFolder => To?.DirectoryName; #endregion @@ -235,11 +231,11 @@ public override string ScanListViewGroup public bool QuickOperation() { - if ((this.From == null) || (this.To == null) || (this.From.Directory == null) || (this.To.Directory == null)) + if ((From == null) || (To == null) || (From.Directory == null) || (To.Directory == null)) return false; return IsMoveRename() && - string.Equals(this.From.Directory.Root.FullName, this.To.Directory.Root.FullName, + string.Equals(From.Directory.Root.FullName, To.Directory.Root.FullName, StringComparison.InvariantCultureIgnoreCase); // same device ... TODO: UNC paths? } @@ -256,7 +252,7 @@ private static void KeepTimestamps(FileSystemInfo from, FileSystemInfo to) private CopyMoveProgressResult CopyProgressCallback(long TotalFileSize, long TotalBytesTransferred, long StreamSize, long StreamBytesTransferred, int StreamNumber, CopyMoveProgressCallbackReason CallbackReason, Object UserData) { double pct = TotalBytesTransferred * 100.0 / TotalFileSize; - this.PercentDone = pct > 100.0 ? 100.0 : pct; + PercentDone = pct > 100.0 ? 100.0 : pct; return CopyMoveProgressResult.Continue; } @@ -265,9 +261,9 @@ private CopyMoveProgressResult CopyProgressCallback(long TotalFileSize, long Tot // -------------------------------------------------------------------------------------------------------- public bool IsMoveRename() // same thing to the OS - => (this.Operation == Op.Move) || (this.Operation == Op.Rename); + => (Operation == Op.Move) || (Operation == Op.Rename); - public bool SameSource(ActionCopyMoveRename o) => FileHelper.Same(this.From, o.From); + public bool SameSource(ActionCopyMoveRename o) => FileHelper.Same(From, o.From); // ======================================================================================================== @@ -275,7 +271,7 @@ private long SourceFileSize() { try { - return this.From.Length; + return From.Length; } catch {