Exemplo n.º 1
0
        public static IUnitOfWork Start(UnitOfWorkOption unitOfWorkOption)
        {
            if (!Enum.IsDefined(typeof(UnitOfWorkOption), unitOfWorkOption))
                throw new InvalidEnumArgumentException(nameof(unitOfWorkOption), (int)unitOfWorkOption,
                    typeof(UnitOfWorkOption));

            //IUnitOfWorkFactory factory = IContainerAdapter.GetInstance<IUnitOfWorkFactory>();

            IUnitOfWorkFactory factory = UnitOfWorkFactory.Instance;

            return factory.Create(unitOfWorkOption);
        }
Exemplo n.º 2
0
        public IUnitOfWork Create(UnitOfWorkOption unitOfWorkOption = UnitOfWorkOption.Reuse)
        {
            IUnitOfWork previousUnitOfWork = this.Current;

            if (unitOfWorkOption == UnitOfWorkOption.Reuse && previousUnitOfWork != null)
            {
                return previousUnitOfWork;
            }

            INestableUnitOfWork newUnitOfWork = InternalCreate(previousUnitOfWork);
            this.Current = newUnitOfWork;
            return newUnitOfWork;
        }
Exemplo n.º 3
0
        public IUnitOfWork Create(UnitOfWorkOption unitOfWorkOption = UnitOfWorkOption.Reuse)
        {
            IUnitOfWork previousUnitOfWork = this.Current;

            if (unitOfWorkOption == UnitOfWorkOption.Reuse && previousUnitOfWork != null)
            {
                return(previousUnitOfWork);
            }

            INestableUnitOfWork newUnitOfWork = InternalCreate(previousUnitOfWork);

            this.Current = newUnitOfWork;
            return(newUnitOfWork);
        }
Exemplo n.º 4
0
        public IUnitOfWork Create(UnitOfWorkOption unitOfWorkOption)
        {
            if (!Enum.IsDefined(typeof(UnitOfWorkOption), unitOfWorkOption))
                throw new InvalidEnumArgumentException(nameof(unitOfWorkOption), (int)unitOfWorkOption,
                    typeof(UnitOfWorkOption));
            IUnitOfWork previousUnitOfWork = this.Current;

            if (unitOfWorkOption == UnitOfWorkOption.Reuse && previousUnitOfWork != null)
            {
                return previousUnitOfWork;
            }

            INestableUnitOfWork newUnitOfWork = InternalCreate(previousUnitOfWork);
            this.Current = newUnitOfWork;
            return newUnitOfWork;
        }
Exemplo n.º 5
0
 public UnitOfWork(UnitOfWorkOption option)
 {
     list = new List<OperatorInfo>();
     Maplist = new List<Map>();
     this.isShadow = false;
     this.Option = option;
     if (this.Option == UnitOfWorkOption.Required)
     {
         UnitOfWork currentUnitOfWork = GetCurrentUnitOfWork();
         if (currentUnitOfWork == null)
         {
             this.list = new List<OperatorInfo>();
         }
         else
         {
             this.list = currentUnitOfWork.list;
             this.isShadow = true;
         }
     }
     UnitOfWorkStack.Push(this);
 }
 public UnitOfWork(UnitOfWorkOption option)
 {
     _list     = new List <OperatorInfo>();
     _maplist  = new List <Map>();
     _isShadow = false;
     Option    = option;
     if (Option == UnitOfWorkOption.Required)
     {
         var currentUnitOfWork = GetCurrentUnitOfWork();
         if (currentUnitOfWork == null)
         {
             _list = new List <OperatorInfo>();
         }
         else
         {
             _list     = currentUnitOfWork._list;
             _isShadow = true;
         }
     }
     UnitOfWorkStack.Push(this);
 }
Exemplo n.º 7
0
 public UnitOfWork(UnitOfWorkOption option)
 {
     list          = new List <OperatorInfo>();
     Maplist       = new List <Map>();
     this.isShadow = false;
     this.Option   = option;
     if (this.Option == UnitOfWorkOption.Required)
     {
         UnitOfWork currentUnitOfWork = GetCurrentUnitOfWork();
         if (currentUnitOfWork == null)
         {
             this.list = new List <OperatorInfo>();
         }
         else
         {
             this.list     = currentUnitOfWork.list;
             this.isShadow = true;
         }
     }
     UnitOfWorkStack.Push(this);
 }
Exemplo n.º 8
0
        public override void Begin(UnitOfWorkOption options)
        {
            if (options?.IsTransactional != true)
            {
                return;
            }

            var transactionOptions = new TransactionOptions
            {
                IsolationLevel = (IsolationLevel)options?.IsolationLevel.GetValueOrDefault(IsolationLevel.ReadUncommitted),
            };

            if (options?.Timeout != null)
            {
                transactionOptions.Timeout = options.Timeout.Value;
            }
            CurrentTransaction = new TransactionScope(
                (TransactionScopeOption)options?.Scope.GetValueOrDefault(TransactionScopeOption.Required),
                transactionOptions,
                (TransactionScopeAsyncFlowOption)options?.AsyncFlowOption.GetValueOrDefault(TransactionScopeAsyncFlowOption.Enabled)
                );

            Begin();
        }
Exemplo n.º 9
0
 public static IUnitOfWork Start(UnitOfWorkOption unitOfWorkOption = UnitOfWorkOption.Reuse)
 {
     IUnitOfWorkFactory factory = IoC.GetInstance<IUnitOfWorkFactory>();
     return factory.Create(unitOfWorkOption);
 }
Exemplo n.º 10
0
        public static IUnitOfWork Start(UnitOfWorkOption unitOfWorkOption = UnitOfWorkOption.Reuse)
        {
            IUnitOfWorkFactory factory = IoC.GetInstance <IUnitOfWorkFactory>();

            return(factory.Create(unitOfWorkOption));
        }