From a5d09db0caec7c880e9b280d72a2fafeb122815b Mon Sep 17 00:00:00 2001 From: sr55 Date: Fri, 18 Aug 2017 20:39:51 +0100 Subject: [PATCH] WinGui: Give the QueueTask object a distinct surrogate key #854 --- .../Services/Queue/Model/QueueTask.cs | 77 +++++-------------- 1 file changed, 18 insertions(+), 59 deletions(-) diff --git a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs index e8813930d..28e66ba59 100644 --- a/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs +++ b/win/CS/HandBrakeWPF/Services/Queue/Model/QueueTask.cs @@ -20,15 +20,9 @@ namespace HandBrakeWPF.Services.Queue.Model /// public class QueueTask : PropertyChangedBase { - #region Constants and Fields - - /// - /// The status. - /// + private static int id = 0; private QueueItemStatus status; - #endregion - #region Properties /// @@ -37,6 +31,8 @@ namespace HandBrakeWPF.Services.Queue.Model public QueueTask() { this.Status = QueueItemStatus.Waiting; + id = id + 1; + this.Id = id; } /// @@ -57,12 +53,17 @@ namespace HandBrakeWPF.Services.Queue.Model this.Configuration = configuration; this.Status = QueueItemStatus.Waiting; this.ScannedSourcePath = scannedSourcePath; + + id = id + 1; + this.Id = id; } + public int Id { get; private set; } + /// /// Gets or sets ScannedSource. /// - public string ScannedSourcePath { get; set; } + public string ScannedSourcePath { get; set; } /// /// Gets or sets Status. @@ -93,64 +94,22 @@ namespace HandBrakeWPF.Services.Queue.Model #endregion - /// - /// The equals. - /// - /// - /// The obj. - /// - /// - /// The . - /// - public override bool Equals(object obj) + protected bool Equals(QueueTask other) { - if (ReferenceEquals(null, obj)) - { - return false; - } - - if (ReferenceEquals(this, obj)) - { - return true; - } - - if (obj.GetType() != this.GetType()) - { - return false; - } - - return this.Equals((QueueTask)obj); + return this.Id == other.Id; } - /// - /// The get hash code. - /// - /// - /// The . - /// - public override int GetHashCode() + public override bool Equals(object obj) { - unchecked - { - int hashCode = (this.ScannedSourcePath != null ? this.ScannedSourcePath.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (this.Task != null ? this.Task.GetHashCode() : 0); - hashCode = (hashCode * 397) ^ (int)this.status; - return hashCode; - } + if (ReferenceEquals(null, obj)) return false; + if (ReferenceEquals(this, obj)) return true; + if (obj.GetType() != this.GetType()) return false; + return Equals((QueueTask)obj); } - /// - /// The equals. - /// - /// - /// The other. - /// - /// - /// The . - /// - protected bool Equals(QueueTask other) + public override int GetHashCode() { - return Equals(this.ScannedSourcePath, other.ScannedSourcePath) && Equals(this.Task, other.Task) && this.status == other.status; + return this.Id; } } } \ No newline at end of file -- 2.40.0