public bool IsEqualTo(ISelectionState selection) { if (selection == null) { throw new ArgumentNullException("selection", "selection is null in SelectionState comparison"); } if (ReferenceEquals(this, selection)) { return(true); } if (selection.Id != Id) { throw new Exception("Cannot compare two selections with different Ids"); } bool ret = (selection.Name == null || selection.Name == this.Name) && this.Price == selection.Price && this.Tradability == selection.Tradability && this.Status == selection.Status; if (IsRollingSelection) { ret &= Line == selection.Line; } if (Result != null) { if (selection.Result == null) { return(false); } ret &= Result.IsEqualTo(selection.Result); } else if (selection.Result != null) { return(false); } if (PlaceResult != null) { if (selection.PlaceResult == null) { return(false); } ret &= PlaceResult.IsEqualTo(selection.PlaceResult); } else if (selection.PlaceResult != null) { return(false); } return(ret); }