/// <summary> /// Deals with the next operation, if it is an <see cref="AtomicOperation"/> it is executed, /// if it is a <see cref="CompositeOperation"/> its single operations are pushed on the execution stack. /// </summary> /// <remarks>If an error occurs during the execution the operation is aborted and the operation /// is pushed on the stack again.<br/> /// If the execution was successful <see cref="EngineBase.OnOperationExecuted"/> is called.</remarks> protected virtual void ProcessNextOperation(bool logOperations, CancellationToken cancellationToken) { IAtomicOperation atomicOperation = CurrentOperation as IAtomicOperation; OperationCollection operations = CurrentOperation as OperationCollection; if (atomicOperation != null && operations != null) throw new InvalidOperationException("Current operation is both atomic and an operation collection"); if (atomicOperation != null) { if (logOperations) Log.LogMessage(string.Format("Performing atomic operation {0}", Utils.Name(atomicOperation))); PerformAtomicOperation(atomicOperation, cancellationToken); } else if (operations != null) { if (logOperations) Log.LogMessage("Expanding operation collection"); ExecutionStack.AddRange(operations.Reverse()); CurrentOperation = null; } else if (ExecutionStack.Count > 0) { if (logOperations) Log.LogMessage("Popping execution stack"); CurrentOperation = ExecutionStack.Last(); ExecutionStack.RemoveAt(ExecutionStack.Count - 1); } else { if (logOperations) Log.LogMessage("Nothing to do"); } OperatorTrace.Regenerate(CurrentAtomicOperation); }
public OperationContent(IOperation operation) { Operation = operation; Collection = operation as OperationCollection; AtomicOperation = operation as IAtomicOperation; ExecutionContext = operation as ExecutionContext; if (AtomicOperation != null) { Name = Utils.Name(AtomicOperation); if (AtomicOperation.Operator != null && AtomicOperation.Operator.Breakpoint) { Icon = VSImageLibrary.BreakpointActive; } else { Icon = VSImageLibrary.Method; } } else if (Collection != null) { Name = string.Format("{0} Operations", Collection.Count); Icon = VSImageLibrary.Module; } else { Name = ""; Icon = VSImageLibrary.Nothing; } }