internal static EditingScope TryCreateImmediateEditingScope(ModelTreeManager manager, string editingScopeDescription) { if (manager.CanCreateImmediateEditingScope()) { return manager.CreateEditingScope(editingScopeDescription, true); } return null; }
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; }
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); }
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); } }