示例#1
0
 public override bool Execute()
 {
     base.Execute();
     From.Withdraw(Amount);  // throws InsufficientFundsException
     Success = To.Deposit(Amount);
     if (!Success)
     {
         From.Deposit(Amount);
         return(false);
     }
     return(true);
 }
示例#2
0
        public override bool Rollback()
        {
            if (!Success)
            {
                return(false);
            }

            base.Rollback();
            To.Withdraw(Amount); // throws InsufficientFundsException
            Reversed = From.Deposit(Amount);
            if (!Reversed)
            {
                To.Deposit(Amount);
                return(false);
            }
            return(true);
        }
        public override Transaction Rollback()
        {
            if (!Success)
            {
                throw new ArgumentOutOfRangeException(
                          "Not yet successfully completed. Nothing to rollback");
            }

            base.Rollback();
            To.Withdraw(Amount); // throws InsufficientFundsException
            Reversed = From.Deposit(Amount);
            if (!Reversed)
            {
                To.Deposit(Amount);
                return(this);
            }
            return(this);
        }