src/Misc/EFTools/XmlCore/UI/ViewModels/Explorer/ExplorerViewModelHelper.cs
/// <summary>
///     this is called by the handler in ExplorerFrame so that we can catch
///     exceptions and reload the UI if needed - don't call this from anywhere else
/// </summary>
this is called by the handler in ExplorerFrame so that we can catch
exceptions and reload the UI if needed - don't call this from anywhere else
this is called by the handler in ExplorerFrame so that we can catch exceptions and reload the UI if needed - don ' t call this from anywhere else
internal void ProcessModelChangesCommitted(EditingContext ctx, EfiChangedEventArgs e)
        {
            if (ctx == null)
            {
                return;
            }
            var xref = ModelToExplorerModelXRef.GetModelToBrowserModelXRef(ctx);
            var artifacts = GetCurrentArtifactsInView(ctx);
            foreach (var change in e.ChangeGroup.Changes)
            {
                if (artifacts.Contains(change.Changed.Artifact) == false)
                {
                    continue;
                }
                switch (change.Type)
                {
                    case EfiChange.EfiChangeType.Create:
                    case EfiChange.EfiChangeType.Delete:
                        if (!ProcessCreateOrDeleteChange(ctx, xref, change))
                        {
                            return;
                        }
                        break;
                    case EfiChange.EfiChangeType.Update:
                        var updatedElement = change.Changed as EFElement;
                        if (updatedElement != null)
                        {
                            var explorerItem = xref.GetExisting(updatedElement);
                            if (explorerItem != null)
                            {
                                foreach (var propName in change.Properties.Keys)
                                {
                                    explorerItem.OnModelPropertyChanged(propName);
                                }
                            }
                        }
                        else
                        {
                            var defaultableValue = change.Changed as DefaultableValue;
                            if (defaultableValue != null)
                            {
                                updatedElement = defaultableValue.Parent as EFElement;
                                if (updatedElement != null)
                                {
                                    var explorerItem = xref.GetExisting(updatedElement);
                                    if (explorerItem != null)
                                    {
                                        explorerItem.OnModelPropertyChanged(defaultableValue.PropertyName);
                                    }
                                }
                            }
                        }
                        break;
                }
            }
        }
internal void ProcessModelChangesCommitted ( EditingContext ctx , EfiChangedEventArgs e ) { if ( ctx == null ) { return ; } var xref = ModelToExplorerModelXRef . GetModelToBrowserModelXRef ( ctx ) ; var artifacts = GetCurrentArtifactsInView ( ctx ) ; foreach ( var change in e . ChangeGroup . Changes ) { if ( artifacts . Contains ( change . Changed . Artifact ) == false ) { continue ; } switch ( change . Type ) { case EfiChange . EfiChangeType . Create : case EfiChange . EfiChangeType . Delete : if ( ! ProcessCreateOrDeleteChange ( ctx , xref , change ) ) { return ; } break ; case EfiChange . EfiChangeType . Update : var updatedElement = change . Changed as EFElement ; if ( updatedElement != null ) { var explorerItem = xref . GetExisting ( updatedElement ) ; if ( explorerItem != null ) { foreach ( var propName in change . Properties . Keys ) { explorerItem . OnModelPropertyChanged ( propName ) ; } } } else { var defaultableValue = change . Changed as DefaultableValue ; if ( defaultableValue != null ) { updatedElement = defaultableValue . Parent as EFElement ; if ( updatedElement != null ) { var explorerItem = xref . GetExisting ( updatedElement ) ; if ( explorerItem != null ) { explorerItem . OnModelPropertyChanged ( defaultableValue . PropertyName ) ; } } } } break ; } } }
this is called by the handler in ExplorerFrame so that we can catch
exceptions and reload the UI if needed - don't call this from anywhere else
this is called by the handler in ExplorerFrame so that we can catch exceptions and reload the UI if needed - don ' t call this from anywhere else
// some other view has caused the context and/or artifact to close & reload // and we are still in the middle of firing the ModelChangesCommitted event // so just exit // only process changes for the artifact this view model is associated with // Create and Delete have the same action at the moment // don't process any more
ctx
EditingContext
e
EfiChangedEventArgs