public void UpdateSkillsFromGems(IReadOnlyList <IReadOnlyList <Skill> > toAdd) { var slotsWithGemsOrItemSkills = _gems.Select(gs => gs.First().ItemSlot).Append(Skill.Default.ItemSlot).ToHashSet(); var changedSlots = toAdd.Select(ss => ss.First().ItemSlot); var toRemove = Collection .Where(ss => !slotsWithGemsOrItemSkills.Contains(ss.First().ItemSlot) || changedSlots.Contains(ss.First().ItemSlot)) .ToList(); Collection.ExceptAndUnionWith(toRemove, toAdd.Select(Update)); }
public void SetOperationsTest() { var values = new[] { 15, 14, 89, 56, 8, 68, 17, 39, 31, 93, 78, 80, 87, 85, 57, 20, 6, 1 }; var people = new ObservableSet <Observable>(values.Select(x => new Observable(x)).ToList()); var transfList = new DynamicTransformingReadOnlyObservableList <Observable, int>(people, x => x.Subject); var copy = new TransformingReadOnlyObservableList <int, int>(transfList, x => x); Assert.AreEqual(people.Count, transfList.Count); Assert.IsTrue(new HashSet <int>(people.Select(x => x.Prop)).SetEquals(transfList)); Assert.IsTrue(new HashSet <int>(people.Select(x => x.Prop)).SetEquals(copy)); people.Add(new Observable(19)); people.First().Prop = 82; people.Remove(people.Last()); Assert.AreEqual(people.Count, transfList.Count); Assert.IsTrue(new HashSet <int>(people.Select(x => x.Prop)).SetEquals(transfList)); Assert.IsTrue(new HashSet <int>(people.Select(x => x.Prop)).SetEquals(copy)); }