public TransferTaskStatusChangedEventArgs(ITransferTaskToken token, TransferTaskStatusEnum oldStatus, TransferTaskStatusEnum newStatus)
        {
            if (!oldStatus.CanConvertedTo(newStatus))
            {
                throw new InvalidOperationException($"{oldStatus} can not converted to {newStatus}");
            }

            Token     = token;
            OldStatus = oldStatus;
            NewStatus = newStatus;
        }
예제 #2
0
 public static bool IsEndStatus(this TransferTaskStatusEnum self) => self == TransferTaskStatusEnum.Completed ||
 self == TransferTaskStatusEnum.Canceled;
예제 #3
0
 public static bool CanConvertedTo(this TransferTaskStatusEnum self, TransferTaskStatusEnum other) =>
 !self.IsEndStatus() &&                       // The end status cannot be converted.
 (other == TransferTaskStatusEnum.Canceled || // Any status can be Canceled except the end status.
  StatusChangeMapping[self].Contains(other));