internal static EditingScope TryCreateImmediateEditingScope(ModelTreeManager manager, string editingScopeDescription)
        {
            if (manager.CanCreateImmediateEditingScope())
            {
                return manager.CreateEditingScope(editingScopeDescription, true);
            }

            return null;
        }
Exemplo n.º 2
0
        internal static EditingScope TryCreateImmediateEditingScope(ModelTreeManager manager, string editingScopeDescription)
        {
            if (manager.CanCreateImmediateEditingScope())
            {
                return(manager.CreateEditingScope(editingScopeDescription, true));
            }

            return(null);
        }
        internal static ModelEditingScope ModelItemBeginEdit(ModelTreeManager modelTreeManager, string description, bool shouldApplyChangesImmediately)
        {
            if (shouldApplyChangesImmediately && modelTreeManager.Context.Services.GetService<UndoEngine>().IsBookmarkInPlace)
            {
                throw FxTrace.Exception.AsError(new InvalidOperationException(SR.InvalidNestedModelItemBeginEditExceptionMessage));
            }

            EditingScope editingScope = modelTreeManager.CreateEditingScope(description, shouldApplyChangesImmediately);

            if (shouldApplyChangesImmediately && editingScope == null)
            {
                throw FxTrace.Exception.AsError(new InvalidOperationException(SR.InvalidNestedModelItemBeginEditExceptionMessage));
            }

            return editingScope;
        }
Exemplo n.º 4
0
        internal static ModelEditingScope ModelItemBeginEdit(ModelTreeManager modelTreeManager, string description, bool shouldApplyChangesImmediately)
        {
            if (shouldApplyChangesImmediately && modelTreeManager.Context.Services.GetService <UndoEngine>().IsBookmarkInPlace)
            {
                throw FxTrace.Exception.AsError(new InvalidOperationException(SR.InvalidNestedModelItemBeginEditExceptionMessage));
            }

            EditingScope editingScope = modelTreeManager.CreateEditingScope(description, shouldApplyChangesImmediately);

            if (shouldApplyChangesImmediately && editingScope == null)
            {
                throw FxTrace.Exception.AsError(new InvalidOperationException(SR.InvalidNestedModelItemBeginEditExceptionMessage));
            }

            return(editingScope);
        }
Exemplo n.º 5
0
        internal static void TryCreateImmediateEditingScopeAndExecute(EditingContext context, string editingScopeDescription, Action <EditingScope> modelEditingWork)
        {
            Fx.Assert(context != null, "context should not be null.");
            Fx.Assert(modelEditingWork != null, "modelEditingWork should not be null.");

            ModelTreeManager manager = context.Services.GetRequiredService <ModelTreeManager>();

            if (manager.CanCreateImmediateEditingScope())
            {
                using (EditingScope editingScope = manager.CreateEditingScope(editingScopeDescription, true))
                {
                    modelEditingWork(editingScope);
                }
            }
            else
            {
                modelEditingWork(null);
            }
        }