protected virtual void handleCollectionChanged(object sender, NotifyCollectionChangedEventArgs e, string propertyName) { CollectionChangedHandlers.CollectionChangedHandler(sender, e, propertyName, this, notifyCombinedChanged, notifyCostChanged, notifyPointChanged, onAdd, onRemove); void onAdd(object obj) { if (obj is TECEquipment equip) { equip.SubScope.CollectionChanged += handleSubScopeCollectionChanged; } } void onRemove(object obj) { if (obj is TECEquipment equip) { equip.SubScope.CollectionChanged -= handleSubScopeCollectionChanged; handleEquipmentRemoval(equip); foreach (TECSubScope ss in equip.SubScope) { handleSubScopeRemoval(ss); } } } }
public void CollectionChangedHandlerTest_Typical() { bool notifiedTEC = false; CostBatch notifiedCost = null; int notifiedPoint = 0; bool notifiedAdd = false; bool notifiedRemoved = false; NotifyMockParent parent = new NotifyMockParent(); parent.IsTypical = true; parent.Collection.CollectionChanged += Collection_CollectionChanged; void Collection_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { CollectionChangedHandlers.CollectionChangedHandler(sender, e, "Collection", parent, (change, prop, par, obj, item) => notifiedTEC = true, cost => notifiedCost = cost, points => notifiedPoint = points, obj => notifiedAdd = true, obj => notifiedRemoved = true); } parent.Collection.Add(new NotifyMock()); Assert.IsTrue(notifiedTEC); Assert.IsTrue(new CostBatch().CostsEqual(notifiedCost)); Assert.AreEqual(0, notifiedPoint); Assert.IsTrue(notifiedAdd); parent.Collection.Remove(parent.Collection.First()); Assert.IsTrue(notifiedRemoved); }
protected override void handleCollectionChanged(object sender, NotifyCollectionChangedEventArgs e, string propertyName) { if (propertyName == "Instances") { CollectionChangedHandlers.CollectionChangedHandler(sender, e, propertyName, this, notifyCombinedChanged, invokeCostChanged, invokePointChanged, onAdd: instanceAdded, onRemove: instanceRemoved, setTypical: false); } else { base.handleCollectionChanged(sender, e, propertyName); } void instanceRemoved(object item) { if (item is TECSystem instance) { handleInstanceRemoved(instance); } } void instanceAdded(object item) { if (item is TECSystem instance) { buildConnectionDictionary(instance, connectionInstances); } } }
protected virtual void collectionChanged(object sender, NotifyCollectionChangedEventArgs e, string propertyName) { CollectionChangedHandlers.CollectionChangedHandler(sender, e, propertyName, this, notifyCombinedChanged, notifyCostChanged); if (propertyName == "ChildrenConnections") { raisePropertyChanged("ChildNetworkConnections"); } }
private void devicesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { CollectionChangedHandlers.CollectionChangedHandler(sender, e, "Devices", this, notifyCombinedChanged, notifyCostChanged, notifyPointChanged); if (e.Action == NotifyCollectionChangedAction.Remove) { if (this.Connection != null && !this.AvailableProtocols.Contains(this.Connection.Protocol)) { this.Connection.ParentController.Disconnect(this); } } }
private void scopeBranchesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { CollectionChangedHandlers.CollectionChangedHandler(sender, e, "ScopeBranches", this, notifyCombinedChanged); }
private void interlocksCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { CollectionChangedHandlers.CollectionChangedHandler(sender, e, "Interlocks", this, notifyCombinedChanged, notifyCostChanged, notifyPointChanged); }
private void collectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e, string propertyName) { CollectionChangedHandlers.CollectionChangedHandler(sender, e, propertyName, this, notifyCombinedChanged, notifyReorder: false); }
private void controllersCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { CollectionChangedHandlers.CollectionChangedHandler(sender, e, "Controllers", this, notifyCombinedChanged); }
private void connectionTypesCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { connection.UpdateProtocol(new TECHardwiredProtocol(ConnectionTypes)); CollectionChangedHandlers.CollectionChangedHandler(sender, e, "ConnectionTypes", this, notifyCombinedChanged, notifyCostChanged); }
private void tables_collectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { CollectionChangedHandlers.CollectionChangedHandler(sender, e, "Tables", this, notifyCombinedChanged, notifyReorder: false); }
private void pointsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { CollectionChangedHandlers.CollectionChangedHandler(sender, e, "Points", this, notifyCombinedChanged, notifyPoint: notifyPointChanged); }
private void SubScope_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { CollectionChangedHandlers.CollectionChangedHandler(sender, e, "SubScope", this, notifyCombinedChanged, notifyCostChanged, notifyPointChanged); }
protected virtual void taggedCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e, string propertyName) //Is virtual so that it can be overridden in TECTypical { CollectionChangedHandlers.CollectionChangedHandler(sender, e, propertyName, this, notifyCombinedChanged); }
private void containingScopeCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) { CollectionChangedHandlers.CollectionChangedHandler(sender, e, "ContainingScope", this, notifyCombinedChanged); raisePropertyChanged("DisplayName"); raisePropertyChanged("AllScope"); }