/// <summary> /// Executes ExceptionManger Dispose. Register the associated promises for the catch and finnaly blocks. /// </summary> public void Dispose() { foreach (var exception in Exceptions.Values) { //Adds a promise for every catch appended. AsyncBuilder.AddPromise(exception, _viewManager.Async(exception), PromiseType.Catch); } if (this.Finally != null) { //Adds a promise for the finally block AsyncBuilder.AddPromise(this.Finally, _viewManager.Async(this.Finally), PromiseType.Finally); } }
/// <summary> /// Indicates that a void method has made a return inside a promise. /// The following promises are removed in the same family are removed. /// </summary> public void Return() { //A dummy promise is insert in the Queue to ensure that the following promises (if any) are going to be marked as Skipped. Action action = () => { return; }; if (_currentBuilders != null) { bool isTempBuilder = false; IAsyncBuilder builder; if (_currentBuilders.Count == 0) { //If has no context a new builder is going to be created based in the current promise information builder = (IAsyncBuilder)this.AsyncBuilder(false); isTempBuilder = true; } else { builder = _currentBuilders.Peek(); } ////Discard the following promises in the same family ((AsyncBuilder)builder).Return(action); //This builder was created only to register the return promise and must be removed from the stack if (isTempBuilder) { builder.Dispose(); } } else if (_viewManager.State.ExecutingPromiseInfo != null) { var promise = _viewManager.Async(action) as BasePromiseInfo; promise.FamilyId = _viewManager.State.ExecutingPromiseInfo.FamilyId; promise.PromiseType = PromiseType.Return; } else { var promise = _viewManager.Async(action) as BasePromiseInfo; promise.FamilyId = _stateManager.UniqueIDGenerator.GetFamilyUniqueID(); promise.PromiseType = PromiseType.Return; } }
private void AppendLoop(Func <bool> conditionFunc, Action bodyAction, Action incrementAction) { this.AddPromise(null, viewManager.Async(conditionFunc, bodyAction, incrementAction)); }