Created
October 17, 2020 08:00
-
-
Save RolandPheasant/7bda54a5cc37df248e9ddf780d14d2c3 to your computer and use it in GitHub Desktop.
Hashcode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using ReactiveUI; | |
using ReactiveUI.Fody.Helpers; | |
namespace WpfApp1 | |
{ | |
public class TestViewModel : ReactiveObject, IEquatable<TestViewModel> | |
{ | |
public TestViewModel(int ModelId, bool IsArchived) | |
{ | |
this.ModelId = ModelId; | |
this.IsArchived = IsArchived; | |
this.DisplayName = $"Item #{ModelId}"; | |
} | |
public int ModelId { get; } | |
[Reactive] public string DisplayName { get; set; } | |
[Reactive] public bool IsArchived { get; set; } | |
public override bool Equals(object obj) => Equals(obj as TestViewModel); | |
public bool Equals(TestViewModel other) => other != null && ModelId == other.ModelId; | |
public override int GetHashCode() => HashCode.Combine(ModelId); | |
public static bool operator ==(TestViewModel left, TestViewModel right) => EqualityComparer<TestViewModel>.Default.Equals(left, right); | |
public static bool operator !=(TestViewModel left, TestViewModel right) => !(left == right); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment