public void BeginReserved(string reservationName, RocketUnitOfWorkOptions options) { if (!TryBeginReserved(reservationName, options)) { throw new RocketException($"Could not find a reserved unit of work with reservation name: {reservationName}"); } }
public virtual void Initialize(RocketUnitOfWorkOptions options) { Check.NotNull(options, nameof(options)); if (Options != null) { throw new RocketException("This unit of work is already initialized before!"); } Options = _defaultOptions.Normalize(options.Clone()); IsReserved = false; }
internal RocketUnitOfWorkOptions Normalize(RocketUnitOfWorkOptions options) { if (options.IsolationLevel == null) { options.IsolationLevel = IsolationLevel; } if (options.Timeout == null) { options.Timeout = Timeout; } return(options); }
private RocketUnitOfWorkOptions CreateOptions(IRocketMethodInvocation invocation, [CanBeNull] UnitOfWorkAttribute unitOfWorkAttribute) { var options = new RocketUnitOfWorkOptions(); unitOfWorkAttribute?.SetOptions(options); if (unitOfWorkAttribute?.IsTransactional == null) { options.IsTransactional = _defaultOptions.CalculateIsTransactional( autoValue: !invocation.Method.Name.StartsWith("Get", StringComparison.InvariantCultureIgnoreCase) ); } return(options); }
public IUnitOfWork Begin(RocketUnitOfWorkOptions options, bool requiresNew = false) { Check.NotNull(options, nameof(options)); var currentUow = Current; if (currentUow != null && !requiresNew) { return(new ChildUnitOfWork(currentUow)); } var unitOfWork = CreateNewUnitOfWork(); unitOfWork.Initialize(options); return(unitOfWork); }
//TODO: 考虑实现更多的构造方法 public virtual void SetOptions(RocketUnitOfWorkOptions options) { if (IsTransactional.HasValue) { options.IsTransactional = IsTransactional.Value; } if (Timeout.HasValue) { options.Timeout = Timeout; } if (IsolationLevel.HasValue) { options.IsolationLevel = IsolationLevel; } }
public bool TryBeginReserved(string reservationName, RocketUnitOfWorkOptions options) { Check.NotNull(reservationName, nameof(reservationName)); var uow = _ambientUnitOfWork.UnitOfWork; //工作单元解析 while (uow != null && !uow.IsReservedFor(reservationName)) { uow = uow.Outer; } if (uow == null) { return(false); } uow.Initialize(options); return(true); }
public void Initialize(RocketUnitOfWorkOptions options) { _parent.Initialize(options); }