Пример #1
0
 private void EntitiesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Reset)
     {
         foreach (var item in TargetConfig.Entities)
         {
             item.Parent.Remove(item);
             GlobalTrigger.OnRemoved(TargetConfig, item);
         }
         foreach (var item in TargetConfig.Entities)
         {
             GlobalTrigger.OnAdded(TargetConfig, item);
         }
         return;
     }
     if (e.NewItems != null)
     {
         foreach (EntityConfig item in e.NewItems)
         {
             GlobalTrigger.OnAdded(TargetConfig, item);
         }
     }
     if (e.OldItems == null)
     {
         return;
     }
     foreach (EntityConfig item in e.OldItems)
     {
         item.Parent.Remove(item);
         GlobalTrigger.OnRemoved(TargetConfig, item);
     }
 }
Пример #2
0
        private static void OnPropertiesCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            if (NotificationObject.IsLoadingMode || _inPropertiesCollectionChanged)
            {
                return;
            }
            var entity = sender as EntityConfig;

            if (entity == null)
            {
                return;
            }
            try
            {
                _inPropertiesCollectionChanged = true;

                if (!entity.IsModify)
                {
                    entity.IsModify = true;
                }

                switch (e.Action)
                {
                case NotifyCollectionChangedAction.Reset:
                    entity.LastProperties.Clear();
                    entity.LastProperties.AddRange(entity.Properties.Where(p => !p.Discard));
                    foreach (var property in entity.LastProperties)
                    {
                        property.StatusChanged += OnFieldStatusChanged;
                        GlobalTrigger.OnLoad(property);
                    }
                    return;
                }
                if (e.NewItems != null && e.NewItems.Count > 0)
                {
                    foreach (PropertyConfig property in e.NewItems)
                    {
                        property.Identity = ++entity.MaxIdentity;
                        property.Index    = entity.Properties.Max(p => p.Index) + 1;
                        entity.LastProperties.Add(property);
                        property.StatusChanged += OnFieldStatusChanged;
                        GlobalTrigger.OnAdded(entity, property);
                    }
                }
                if (e.OldItems != null && e.OldItems.Count > 0)
                {
                    foreach (PropertyConfig property in e.OldItems)
                    {
                        entity.LastProperties.Remove(property);
                        property.StatusChanged -= OnFieldStatusChanged;
                        GlobalTrigger.OnRemoved(entity, property);
                    }
                }
            }
            finally
            {
                _inPropertiesCollectionChanged = false;
            }
        }
Пример #3
0
 private void ConfigCollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
 {
     if (e.Action == NotifyCollectionChangedAction.Reset)
     {
         OnLoad(TargetConfig);
         return;
     }
     if (e.NewItems != null)
     {
         foreach (ConfigBase item in e.NewItems)
         {
             GlobalTrigger.OnAdded(TargetConfig, item);
         }
     }
     if (e.OldItems == null)
     {
         return;
     }
     foreach (ConfigBase item in e.OldItems)
     {
         GlobalTrigger.OnRemoved(TargetConfig, item);
     }
 }