public IEnumerable <ICombatObject> AllAliveCombatObjects() { return (BackingList.SelectMany( group => group.Where(combatObject => !combatObject.IsDead) .Select(combatObject => combatObject))); }
private CopyOnWriteList(CopyOnWriteList <T> other) { _backing = other._backing; if (_backing != null) { lock (((ICollection)_backing).SyncRoot) { _backing.AddRef(); } } }
private void OnDependencyPropertyChanged(DependencyObject dependencyObject, DependencyPropertyChangedEventArgs args) { T item = (T)(LiveShapingItem <T>)dependencyObject; switch (GetCategoryOfDependencyProperty(args.Property)) { case LiveShapingCategory.Sorting: int originalBinarySearchIndex = InternalBinarySearchWithEqualityCheck(item); int actualIndex; int targetIndex; if (originalBinarySearchIndex >= 0) { Debug.Assert(BackingList[originalBinarySearchIndex].Equals(item)); actualIndex = originalBinarySearchIndex; targetIndex = FindCorrectLocation(item); } else { actualIndex = LinearSearch(item); targetIndex = ~originalBinarySearchIndex; } LiveShapingItems[item].IsSortDirty = false; if (actualIndex >= 0) { // adjust targetIndex if the item at actualIndex will no longer be there if (actualIndex < targetIndex) { targetIndex--; } if (targetIndex != actualIndex) { BackingList.Move(actualIndex, targetIndex); OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Move, item, targetIndex, actualIndex)); } } break; case LiveShapingCategory.Filtering: var passesFilter = PassesFilter(item); if (passesFilter) { if (FilteredItems.Remove(item)) { var insertionIndex = base.Add(item); OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Add, item, insertionIndex)); } } else { if (!FilteredItems.Contains(item)) { var removalIndex = IndexOf(item); // It is possible that the liveshapingitem has been registered but the item has not yet been added to this collection (causing index = -1), in which case this is a noop if (removalIndex >= 0) { base.RemoveAt(removalIndex); OnCollectionChanged(new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Remove, item, removalIndex)); FilteredItems.Add(item); } } } break; default: throw new ArgumentOutOfRangeException(); } /* Debug.WriteLine(args.Property + " " + string.Join(", ", * BackingList.OfType<GameFolderPair>() * .Select( * folderPair => { * if (folderPair.DestinationEntry == null) return "-99"; * * return SizeToStringConverter.Instance.Convert(folderPair.DestinationEntry?.Size) + (LiveShapingItems[folderPair as T].IsSortDirty ? "" : "✓"); + }) + ));*/ }
private int LinearSearch(T item) => BackingList.IndexOf(item);
public override string ToString() { return(string.Join(" ", BackingList.ToArray())); }
public override void WriteXml(XmlWriter writer) { writer.WriteAttributeString("override", Override.ToString().ToLower()); writer.WriteString(string.Join(" ", BackingList.ToArray())); }
public override void WriteXml(XmlWriter writer) { writer.WriteString(string.Join(" ", BackingList.ToArray())); }
public Enumerator(BackingList backing) { _backing = backing; _inner = _backing.GetEnumerator(); _backing.AddRef(); }
public override string ToString() { return(new string(BackingList.ToArray())); }
private void ObjectAdded(PersistableObjectList <ICombatObject> persistableObjectList, ICombatObject combatObject) { combatObject.GroupId = Id; BackingList.Sort((combatObject1, combatObject2) => combatObject1.Id.CompareTo(combatObject2.Id)); CombatObjectAdded(this, combatObject); }
public bool IsDead() { return(BackingList.All(combatObject => combatObject.IsDead)); }
private void ObjectAdded(PersistableObjectList <ICombatGroup> list, ICombatGroup item) { BackingList.Sort((combatGroup1, combatGroup2) => combatGroup1.Id.CompareTo(combatGroup2.Id)); }
public IEnumerable <ICombatObject> AllCombatObjects() { return(BackingList.SelectMany(group => group.Select(combatObject => combatObject))); }