/// <summary> /// Merges the current bumper sticker type with the specified bumper sticker type /// </summary> public void MergeWith(HudBumperStickerType bumperStickerType) { if (bumperStickerType == null) { return; } MinSample = bumperStickerType.MinSample; EnableBumperSticker = bumperStickerType.EnableBumperSticker; SelectedColor = bumperStickerType.SelectedColor; Name = bumperStickerType.Name; Description = bumperStickerType.Description; if (bumperStickerType.FilterModelCollection != null) { FilterModelCollection = new IFilterModelCollection(bumperStickerType.FilterModelCollection.Select(x => (IFilterModel)x.Clone())); } else { FilterModelCollection = new IFilterModelCollection(); } var statsToMerge = (from currentStat in Stats join stat in bumperStickerType.Stats on currentStat.Stat equals stat.Stat into gj from grouped in gj.DefaultIfEmpty() where grouped != null select new { CurrentStat = currentStat, Stat = grouped }).ToArray(); statsToMerge.ForEach(s => { s.CurrentStat.Low = s.Stat.Low; s.CurrentStat.High = s.Stat.High; }); }
private static bool AreEquals(IFilterModelCollection first, IFilterModelCollection second) { if (first == null && second == null) { return(true); } if (first == null || second == null) { return(false); } if (first.Count != second.Count) { return(false); } return(first.All(f => second.FirstOrDefault(s => f.Type == s.Type) != null)); }