public bool Equals(LockState other) { //Check whether the compared object is null. if (Object.ReferenceEquals(other, null)) { return(false); } //Check whether the compared object references the same data. if (Object.ReferenceEquals(this, other)) { return(true); } if (Is) { return(At.Equals(other.At) && Expiration.Equals(other.Expiration) && By.Equals(other.By)); } else { if (other.Is) { return(false); } else { return(true); } } }