예제 #1
0
 public ExecutedHistoryMementoEventArgs(HistoryMemento newHistoryMemento)
 {
     this.newHistoryMemento = newHistoryMemento;
 }
예제 #2
0
        /// <summary>
        /// Executes the HistoryFunction.
        /// </summary>
        /// <returns>
        /// A HistoryMemento instance if an operation was performed successfully,
        /// or null for success but no operation was performed.</returns>
        /// <exception cref="HistoryFunctionNonFatalException">
        /// There was error while performing the operation. No changes have been made to the HistoryWorkspace (no-op).
        /// </exception>
        /// <remarks>
        /// If this HistoryFunction's ActionFlags contain the HistoryFlags.Cancellable bit, then it will be executed in
        /// a background thread.
        /// </remarks>
        public HistoryMemento Execute(IHistoryWorkspace historyWorkspace)
        {
            SystemLayer.Tracing.LogFeature("HF(" + GetType().Name + ")");

            HistoryMemento returnVal = null;
            Exception      exception = null;

            try
            {
                try
                {
                    if (this.executed)
                    {
                        throw new InvalidOperationException("Already executed this HistoryFunction");
                    }

                    this.executed = true;

                    returnVal = OnExecute(historyWorkspace);
                    return(returnVal);
                }

                catch (ArgumentOutOfRangeException aoorex)
                {
                    if (this.criticalRegionCount > 0)
                    {
                        throw;
                    }
                    else
                    {
                        throw new HistoryFunctionNonFatalException(null, aoorex);
                    }
                }

                catch (OutOfMemoryException oomex)
                {
                    if (this.criticalRegionCount > 0)
                    {
                        throw;
                    }
                    else
                    {
                        throw new HistoryFunctionNonFatalException(null, oomex);
                    }
                }
            }

            catch (Exception ex)
            {
                if (IsAsync)
                {
                    exception = ex;
                    return(returnVal);
                }
                else
                {
                    throw;
                }
            }

            finally
            {
                if (IsAsync)
                {
                    OnFinished(returnVal, exception);
                }
            }
        }