public void EntityEventsOnIndirectUpdate()
        {
            EntitySet <City>        entitySet;
            EntityCollection <City> entityCollection = this.CreateEntityCollection(out entitySet);

            EntityCollectionChangedEventArgs <City> eventArgs = null;
            EventHandler <EntityCollectionChangedEventArgs <City> > handler = (sender, e) =>
            {
                Assert.IsNull(eventArgs,
                              "Only a single event should have occurred.");
                eventArgs = e;
            };

            entityCollection.EntityAdded   += handler;
            entityCollection.EntityRemoved += handler;

            // Add
            eventArgs = null;
            City city = this.CreateLocalCity("Enumclaw");

            entitySet.Attach(city);

            Assert.IsTrue(entityCollection.Contains(city),
                          "EntityCollection should contain entity after add.");
            Assert.IsNotNull(eventArgs,
                             "Event should not be null after adding an entity.");
            Assert.AreEqual(city, eventArgs.Entity,
                            "Entities should be equal after adding.");

            // Remove
            eventArgs = null;
            city      = this.CreateLocalCity("Duvall");
            entitySet.Attach(city);

            Assert.IsTrue(entityCollection.Contains(city),
                          "EntityCollection should contain entity after second add.");

            eventArgs = null;
            entitySet.Detach(city);

            Assert.IsFalse(entityCollection.Contains(city),
                           "EntityCollection should not contain entity after remove.");
            Assert.IsNotNull(eventArgs,
                             "Event should not be null after removing an entity.");
            Assert.AreEqual(city, eventArgs.Entity,
                            "Entities shoudl be equal after removing.");
        }
Beispiel #2
0
 private void GraphicInstances_EntityRemoved(object sender, EntityCollectionChangedEventArgs <GraphicInstance> e)
 {
     if (e.Entity is RootInstance)
     {
         RootInstances.Remove(e.Entity as RootInstance);
         if (CanvasRootElement == e.Entity)
         {
             UpdateCanvasInstancesSource();
         }
     }
     else
     {
         if (CanvasInstancesSource.Contains(e.Entity))
         {
             CanvasInstancesSource.Remove(e.Entity);
         }
     }
 }
Beispiel #3
0
 private void OnEntityAdded(object sender, EntityCollectionChangedEventArgs <TLinkTable> e)
 {
     EntityAdded?.Invoke(this, new EntityCollectionChangedEventArgs <TEntity>(_getEntity(e.Entity)));
 }
Beispiel #4
0
 private void UnassignedImageLocations_CollectionChanged(object sender, EntityCollectionChangedEventArgs e)
 {
     this.Dispatcher.Invoke(new Action(() =>
                                       this.ReloadUnassignedImages(e.ForceUpdate)
                                       ), System.Windows.Threading.DispatcherPriority.ApplicationIdle);
 }
Beispiel #5
0
 private void _unassignedImageLocations_CollectionChanged(object sender, EntityCollectionChangedEventArgs e)
 {
     this.UnassignedVisible = e.Entities.Count > 0;
 }
Beispiel #6
0
        void LocationsEntityRemoved(object sender, EntityCollectionChangedEventArgs<Location> e)
        {
            //Remove the BillingLocation from this client if it is a billing location
            if (e.Entity.IsDefaultBillingLocation == true)
                e.Entity.IsDefaultBillingLocation = true;

            var exists = this.Locations.FirstOrDefault(l => l.IsDefaultBillingLocation == true);
 
            //If there is no DefaultBillingLocation. Set the DefaultBillingLocation to the first location this client 
            if (exists != null)
                exists.IsDefaultBillingLocation = true; 
        }
Beispiel #7
0
 void LocationsEntityAdded(object sender, EntityCollectionChangedEventArgs<Location> e)
 {
     var exists = this.Locations.FirstOrDefault(l => l.IsDefaultBillingLocation == true);
     //Only set the DefaultBillingLocation if one does not already exist
     if (exists != null) 
         exists.IsDefaultBillingLocation = true; 
 }
Beispiel #8
0
 private void EdgeChildren_EntityAdded(object sender, EntityCollectionChangedEventArgs <EdgeInstance> e)
 {
     Children.Add(e.Entity);
 }
Beispiel #9
0
 void EdgeChildren_EntityRemoved(object sender, EntityCollectionChangedEventArgs <EdgeInstance> e)
 {
     Children.Remove(e.Entity);
 }
Beispiel #10
0
 private void NodeChildren_EntityRemoved(object sender, EntityCollectionChangedEventArgs <NodeInstance> e)
 {
     Children.Remove(e.Entity);
 }
 private void OnEntityAdded(object sender,
                            EntityCollectionChangedEventArgs<Customer> entityCollectionChangedEventArgs)
 {
     customers.Add(entityCollectionChangedEventArgs.Entity);
 }
Beispiel #12
0
 private void GraphicInstances_EntityAdded(object sender, EntityCollectionChangedEventArgs <GraphicInstance> e)
 {
     AddInstance(e.Entity);
 }