public void BeginReserved(string reservationName, PlusUnitOfWorkOptions options) { if (!TryBeginReserved(reservationName, options)) { throw new PlusException($"Could not find a reserved unit of work with reservation name: {reservationName}"); } }
public virtual void Initialize(PlusUnitOfWorkOptions options) { Check.NotNull(options, nameof(options)); if (Options != null) { throw new PlusException("This unit of work is already initialized before!"); } Options = _defaultOptions.Normalize(options.Clone()); IsReserved = false; }
internal PlusUnitOfWorkOptions Normalize(PlusUnitOfWorkOptions options) { if (options.IsolationLevel == null) { options.IsolationLevel = IsolationLevel; } if (options.Timeout == null) { options.Timeout = Timeout; } return(options); }
private PlusUnitOfWorkOptions CreateOptions(IPlusMethodInvocation invocation, [CanBeNull] UnitOfWorkAttribute unitOfWorkAttribute) { var options = new PlusUnitOfWorkOptions(); unitOfWorkAttribute?.SetOptions(options); if (unitOfWorkAttribute?.IsTransactional == null) { options.IsTransactional = _defaultOptions.CalculateIsTransactional( autoValue: !invocation.Method.Name.StartsWith("Get", StringComparison.InvariantCultureIgnoreCase) ); } return(options); }
//TODO: More constructors! public virtual void SetOptions(PlusUnitOfWorkOptions options) { if (IsTransactional.HasValue) { options.IsTransactional = IsTransactional.Value; } if (Timeout.HasValue) { options.Timeout = Timeout; } if (IsolationLevel.HasValue) { options.IsolationLevel = IsolationLevel; } }
public IUnitOfWork Begin(PlusUnitOfWorkOptions 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); }
public bool TryBeginReserved(string reservationName, PlusUnitOfWorkOptions options) { Check.NotNull(reservationName, nameof(reservationName)); var uow = _ambientUnitOfWork.UnitOfWork; //Find reserved unit of work starting from current and going to outers while (uow != null && !uow.IsReservedFor(reservationName)) { uow = uow.Outer; } if (uow == null) { return(false); } uow.Initialize(options); return(true); }
public void Initialize(PlusUnitOfWorkOptions options) { _parent.Initialize(options); }