示例#1
0
 public void Abort(RedisMessage[] messages)
 {
     if (messages != null)
     {
         for (int i = 0; i < messages.Length; i++)
         {
             var reply = RedisResult.Cancelled;
             RedisConnectionBase.CallbackMode callbackMode;
             var ctx = parent.ProcessReply(ref reply, messages[i], out callbackMode);
             RedisConnectionBase.Trace("transaction", "{0} = {1}", ctx, reply);
             parent.ProcessCallbacks(ctx, reply, callbackMode);
         }
     }
 }
        void IMessageResult.Complete(RedisResult result)
        {
            if (result.IsCancellation)
            {
                completion.SetCanceled();
                SetInnerReplies(result);
            }
            else if (result.IsError)
            {
                completion.SetException(result.Error());
                SetInnerReplies(result);
            }
            else
            {
                try
                {
                    if (result.IsNil)
                    {
                        // aborted
                        SetInnerReplies(RedisResult.Cancelled);
                        completion.SetResult(false);
                    }
                    else
                    {
                        RedisResult[] items = result.ValueItems;
                        if (items.Length != (queued == null ? 0 : queued.Length))
                        {
                            throw new InvalidOperationException(string.Format("{0} results expected, {1} received",
                                                                              queued.Length, items.Length));
                        }

                        for (int i = 0; i < items.Length; i++)
                        {
                            RedisResult reply = items[i];
                            object      ctx   = parent.ProcessReply(ref reply, queued[i].InnerMessage);
                            parent.ProcessCallbacks(ctx, reply);
                        }
                        completion.SetResult(true);
                    }
                }
                catch (Exception ex)
                {
                    completion.SetException(ex);
                    throw;
                }
            }
        }