コード例 #1
0
        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);
                    }
                }
            }
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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);
                }
            }
        }
コード例 #4
0
        protected virtual void collectionChanged(object sender, NotifyCollectionChangedEventArgs e, string propertyName)
        {
            CollectionChangedHandlers.CollectionChangedHandler(sender, e, propertyName, this, notifyCombinedChanged, notifyCostChanged);

            if (propertyName == "ChildrenConnections")
            {
                raisePropertyChanged("ChildNetworkConnections");
            }
        }
コード例 #5
0
 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);
         }
     }
 }
コード例 #6
0
 private void scopeBranchesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     CollectionChangedHandlers.CollectionChangedHandler(sender, e, "ScopeBranches", this, notifyCombinedChanged);
 }
コード例 #7
0
 private void interlocksCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     CollectionChangedHandlers.CollectionChangedHandler(sender, e, "Interlocks", this, notifyCombinedChanged, notifyCostChanged, notifyPointChanged);
 }
コード例 #8
0
 private void collectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e, string propertyName)
 {
     CollectionChangedHandlers.CollectionChangedHandler(sender, e, propertyName, this,
                                                        notifyCombinedChanged, notifyReorder: false);
 }
コード例 #9
0
 private void controllersCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     CollectionChangedHandlers.CollectionChangedHandler(sender, e, "Controllers", this,
                                                        notifyCombinedChanged);
 }
コード例 #10
0
 private void connectionTypesCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     connection.UpdateProtocol(new TECHardwiredProtocol(ConnectionTypes));
     CollectionChangedHandlers.CollectionChangedHandler(sender, e, "ConnectionTypes", this, notifyCombinedChanged, notifyCostChanged);
 }
コード例 #11
0
 private void tables_collectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     CollectionChangedHandlers.CollectionChangedHandler(sender, e, "Tables", this,
                                                        notifyCombinedChanged, notifyReorder: false);
 }
コード例 #12
0
 private void pointsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     CollectionChangedHandlers.CollectionChangedHandler(sender, e, "Points", this, notifyCombinedChanged, notifyPoint: notifyPointChanged);
 }
コード例 #13
0
 private void SubScope_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     CollectionChangedHandlers.CollectionChangedHandler(sender, e, "SubScope", this, notifyCombinedChanged, notifyCostChanged, notifyPointChanged);
 }
コード例 #14
0
 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);
 }
コード例 #15
0
 private void containingScopeCollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
 {
     CollectionChangedHandlers.CollectionChangedHandler(sender, e, "ContainingScope", this, notifyCombinedChanged);
     raisePropertyChanged("DisplayName");
     raisePropertyChanged("AllScope");
 }