Beispiel #1
0
        /// <summary>
        /// Invoke a single progress handler.
        /// </summary>
        private void InvokeProgressHandler(Action <float> callback, IRejectable rejectable, float progress)
        {
//            Argument.NotNull(() => callback);
//            Argument.NotNull(() => rejectable);

            try
            {
                callback(progress);
            }
            catch (Exception ex)
            {
                rejectable.Reject(ex);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Invoke a single handler.
        /// </summary>
        private void InvokeHandler <T>(Action <T> callback, IRejectable rejectable, T value)
        {
//            Argument.NotNull(() => callback);
//            Argument.NotNull(() => rejectable);

            try
            {
                callback(value);
            }
            catch (Exception ex)
            {
                rejectable.Reject(ex);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Invoke a single resolve handler.
        /// </summary>
        private void InvokeResolveHandler(Action callback, IRejectable rejectable)
        {
//            Argument.NotNull(() => callback);
//            Argument.NotNull(() => rejectable);

            try
            {
                callback();
            }
            catch (Exception ex)
            {
                rejectable.Reject(ex);
            }
        }
        /// <summary>
        /// Add a progress handler for this promise.
        /// </summary>
        private void AddProgressHandler(Action <float> onProgress, IRejectable rejectable)
        {
            lock (this)
            {
                if (progressHandlers == null)
                {
                    progressHandlers = new List <ProgressHandler>();
                }

                progressHandlers.Add(new ProgressHandler {
                    callback = onProgress, rejectable = rejectable
                });
            }
        }
        /// <summary>
        /// Invoke a single error handler.
        /// </summary>
        private void InvokeRejectHandler(Action <Exception> callback, IRejectable rejectable, Exception value)
        {
            Argument.NotNull(() => callback);
            Argument.NotNull(() => rejectable);

            try
            {
                callback(value);
            }
            catch (Exception ex)
            {
                rejectable.Reject(ex);
            }
        }
Beispiel #6
0
 private void ActionHandlers(IRejectable resultPromise, Action <PromisedT> resolveHandler, Action <Exception> rejectHandler)
 {
     if (CurState == PromiseState.Resolved)
     {
         InvokeHandler(resolveHandler, resultPromise, resolveValue);
         return;
     }
     if (CurState == PromiseState.Rejected)
     {
         InvokeHandler(rejectHandler, resultPromise, rejectionException);
         return;
     }
     AddResolveHandler(resolveHandler, resultPromise);
     AddRejectHandler(rejectHandler, resultPromise);
 }
        /// <summary>
        /// Invoke a single error handler.
        /// </summary>
        private void InvokeRejectHandler(Action <Exception> callback, IRejectable rejectable, Exception value)
        {
//            Argument.NotNull(() => callback);
//            Argument.NotNull(() => rejectable);

            try
            {
                callback(value);
            }
            catch (Exception ex)
            {
                RSGUtil.LogCaughtException(ex);
                rejectable.Reject(ex);
            }
        }
Beispiel #8
0
        /// <summary>
        /// Add a resolve handler for this promise.
        /// </summary>
        private void AddResolveHandler(Action <PromisedT> onResolved, IRejectable rejectable)
        {
            if (resolveCallbacks == null)
            {
                resolveCallbacks = new List <Action <PromisedT> >();
            }

            if (resolveRejectables == null)
            {
                resolveRejectables = new List <IRejectable>();
            }

            resolveCallbacks.Add(onResolved);
            resolveRejectables.Add(rejectable);
        }
        /// <summary>
        /// Add a resolve handler for this promise.
        /// </summary>
        private void AddResolveHandler(Action onResolved, IRejectable rejectable)
        {
            lock (this)
            {
                if (resolveHandlers == null)
                {
                    resolveHandlers = new List <ResolveHandler>();
                }

                resolveHandlers.Add(new ResolveHandler
                {
                    callback   = onResolved,
                    rejectable = rejectable
                });
            }
        }
Beispiel #10
0
 /// <summary>
 /// Helper function to invoke or register resolve/reject handlers.
 /// </summary>
 private void ActionHandlers(IRejectable resultPromise, Action resolveHandler, Action <Exception> rejectHandler)
 {
     if (CurState == PromiseState.Resolved)
     {
         InvokeResolveHandler(resolveHandler, resultPromise);
     }
     else if (CurState == PromiseState.Rejected)
     {
         InvokeRejectHandler(rejectHandler, resultPromise, rejectionException);
     }
     else
     {
         AddResolveHandler(resolveHandler, resultPromise);
         AddRejectHandler(rejectHandler, resultPromise);
     }
 }
Beispiel #11
0
        /// <summary>
        /// Invoke a single handler.
        /// </summary>
        private void InvokeHandler <T>(Action <T> callback, IRejectable rejectable, T value)
        {
//            Argument.NotNull(() => callback);
//            Argument.NotNull(() => rejectable);

            try
            {
                callback(value);
            }
            catch (Exception ex)
            {
                Debug.LogError("PROMISE ERROR: " + ex);
                rejectable.Reject(ex);
                throw;
            }
        }
Beispiel #12
0
 /// <summary>
 /// Helper function to invoke or register resolve/reject handlers.
 /// </summary>
 void ActionHandlers(IRejectable resultPromise, Action <PromisedT> resolveHandler, Action <Exception> rejectHandler)
 {
     if (CurrentState.Equals(PromiseState.Resolved))
     {
         InvokeHandler(resolveHandler, resultPromise, resolveValue);
     }
     else if (CurrentState.Equals(PromiseState.Rejected))
     {
         InvokeHandler(rejectHandler, resultPromise, rejectionException);
     }
     else
     {
         AddResolveHandler(resolveHandler, resultPromise);
         AddRejectHandler(rejectHandler, resultPromise);
     }
 }
Beispiel #13
0
 /// <summary>
 /// Helper function to invoke or register resolve/reject handlers.
 /// </summary>
 void ActionHandlers(IRejectable resultPromise, Action resolveHandler, Action <Exception> rejectHandler)
 {
     if (this.CurState == PromiseState.Resolved)
     {
         this.InvokeResolveHandler(resolveHandler, resultPromise);
     }
     else if (this.CurState == PromiseState.Rejected)
     {
         this.InvokeRejectHandler(rejectHandler, resultPromise, this.rejectionException);
     }
     else
     {
         this.AddResolveHandler(resolveHandler, resultPromise);
         this.AddRejectHandler(rejectHandler, resultPromise);
     }
 }
Beispiel #14
0
 private void actionHandlers(IRejectable resultPromise, Action resolveHandler, Action <Exception> rejectHandler)
 {
     if (this.curState == PromiseState.Resolved)
     {
         this.executeResolveHandler(resolveHandler, resultPromise);
     }
     else if (this.curState == PromiseState.Rejected)
     {
         this.executeRejectHandler(rejectHandler, resultPromise, this.rejectionException);
     }
     else
     {
         this.addResolveHandler(resolveHandler, resultPromise);
         this.addRejectHandler(rejectHandler, resultPromise);
     }
 }
Beispiel #15
0
        /// <summary>
        /// Initializes a new instance of the ResultSummaryRecord class.
        /// </summary>
        /// <param name="verb">
        /// The verb whose execution this is the result of.
        /// </param>
        /// <param name="disposition">
        /// The disposition of the verb execution.
        /// </param>
        /// <param name="outputs">
        /// The build objects that were produced by this verb execution.
        /// </param>
        /// <param name="isRejectableFailure">
        /// Whether this result is a rejectable failure.
        /// </param>
        internal ResultSummaryRecord(
            IVerb verb,
            Disposition disposition,
            IEnumerable <BuildObjectValuePointer> outputs,
            bool isRejectableFailure)
        {
            this.verb                = verb;
            this.disposition         = disposition;
            this.outputs             = new List <BuildObjectValuePointer>(outputs);
            this.isRejectableFailure = isRejectableFailure;

            IRejectable rejectableVerb = verb as IRejectable;

            if (rejectableVerb != null)
            {
                this.isRejectableFailure = rejectableVerb.resultWasRejectableFailure();
            }
        }
Beispiel #16
0
        /// <summary>
        /// Invoke a single handler.
        /// </summary>
        private void InvokeHandler <T>(Action <T> callback, IRejectable rejectable, T value)
        {
//            Argument.NotNull(() => callback);
//            Argument.NotNull(() => rejectable);

            try
            {
                callback(value);
            }
            catch (Exception ex)
            {
                if (Promise.DoNotHandleExceptions && !(ex is RejectableException))
                {
                    throw;
                }
                rejectable.Reject(ex);
            }
        }
Beispiel #17
0
        /// <summary>
        /// Invoke a single handler.
        /// </summary>
        private void InvokeHandler <T>(Action <T> callback, IRejectable rejectable, T value)
        {
            //            Argument.NotNull(() => callback);
            //            Argument.NotNull(() => rejectable);

            lock (this)
            {
                try
                {
                    callback(value);
                }
                catch (Exception ex)
                {
                    Log.Error("Promise {promise} rejected due to unhandled exception: {exception}", this, ex);
                    rejectable.Reject(ex);
                }
            }
        }
Beispiel #18
0
 public ResolveHandler(IRejectable rejectable, Action callback)
 {
     Rejectable = rejectable;
     Callback   = callback;
 }
 private void ActionHandlers(IRejectable resultPromise, Action <PromisedT> resolveHandler, Action <Exception> rejectHandler)
 {
 }
 private void InvokeHandler <T>(Action <T> callback, IRejectable rejectable, T value)
 {
 }
 private void AddResolveHandler(Action <PromisedT> onResolved, IRejectable rejectable)
 {
 }
 public void AddResolver(Action onResolved, IRejectable rejectable)
 {
     _resolvers.Add(new AsyncHandler { Callback = onResolved, Rejectable = rejectable });
 }
Beispiel #23
0
        }                           // 0x00525770-0x00525800

        // Methods
        private void InvokeRejectHandler(Action <Exception> callback, IRejectable rejectable, Exception value)
        {
        }                                                                                                                // 0x00525140-0x00525240
 public void AddRejector(Action <Exception> onRejected, IRejectable rejectable)
 {
     _rejectors.Add(new AsyncHandler <Exception> {
         Callback = onRejected, Rejectable = rejectable
     });
 }
Beispiel #25
0
 public RejectHandler(IRejectable rejectable, Action <Exception> callback)
 {
     Rejectable = rejectable;
     Callback   = callback;
 }
 public void AddRejector(Action<Exception> onRejected, IRejectable rejectable)
 {
     _rejectors.Add(new AsyncHandler<Exception> { Callback = onRejected, Rejectable = rejectable });
 }
 // Methods
 private void AddRejectHandler(Action <Exception> onRejected, IRejectable rejectable)
 {
 }
 public void AddResolver(Action onResolved, IRejectable rejectable)
 {
     _resolvers.Add(new AsyncHandler {
         Callback = onResolved, Rejectable = rejectable
     });
 }
Beispiel #29
0
 protected void InvokeReject(Action <Exception> callback, Exception exception, IRejectable rejectable)
 {
     Argument.NotNull(rejectable);
     try {
         callback.SafeInvoke(exception);
     } catch (Exception ex) {
         if (rejectable != this)
         {
             rejectable.Reject(ex);
         }
     }
 }