public AtomicOperationOrderByBuilder(TActualContext context, IContextBundle bundle, IContractBundle contractBundle, params ILockTransactionMember[] transactionMembers)
 {
     this.context            = context;
     this.bundle             = bundle;
     this.contractBundle     = contractBundle;
     this.transactionMembers = transactionMembers.DefaultIfNull();
 }
Beispiel #2
0
 public IResultContractContext <TResult> Copy(IContextBundle bundle          = null,
                                              IContractBundle contractBundle = null)
 {
     return(new ContractContext <TResult>(bundle ?? this.bundle,
                                          contractBundle ?? this.contractBundle,
                                          this.originalContext));
 }
Beispiel #3
0
 public VoidReturnContractContext(IContextBundle bundle,
                                  IContractBundle contractBundle,
                                  ICopyableTrait <IBoilerplateContext> originalContext)
     : base(bundle, contractBundle)
 {
     this.originalContext = originalContext;
 }
Beispiel #4
0
 public IBoilerplateContext Copy(IContextBundle bundle          = null,
                                 IContractBundle contractBundle = null)
 {
     return(new InitialBoilerplateContext <TContract>(bundle ?? this.bundle,
                                                      this.Identity,
                                                      contractBundle ?? this.contractBundle));
 }
 public ContractContext(IContextBundle bundle,
                        IContractBundle contractBundle,
                        IElevatableContext originalContext)
     : base(bundle, contractBundle)
 {
     this.originalContext = originalContext;
 }
Beispiel #6
0
 public ContractContext(IContextBundle bundle,
                        IContractBundle contractBundle,
                        IBoilerplateContext <TResult> originalContext)
 {
     this.bundle          = bundle;
     this.contractBundle  = contractBundle;
     this.originalContext = originalContext;
 }
Beispiel #7
0
 internal InitialBoilerplateContext(IContextBundle bundle,
                                    IIdentity identity,
                                    IContractBundle contractBundle         = null,
                                    IImmutableQueue <TimeSpan> callTimings = null)
     : base(contractBundle, bundle)
 {
     this.Identity    = identity;
     this.callTimings = callTimings.DefaultIfNull();
 }
Beispiel #8
0
 public IBoilerplateContext <TResult> Elevate <TResult>(IContextBundle bundle          = null,
                                                        IContractBundle contractBundle = null,
                                                        TResult result = default(TResult))
 {
     return(new ResultBoilerplateContext <TResult>(bundle ?? this.bundle,
                                                   this.Identity,
                                                   contractBundle ?? this.contractBundle,
                                                   result,
                                                   this.callTimings));
 }
 public TypeAccessBuilder(IIdentity identity,
                          IContextBundle bundle,
                          IContractBundle contractBundle,
                          IBoilerplateContext context)
     : base(bundle)
 {
     this.identity       = identity;
     this.contractBundle = contractBundle;
     this.context        = context;
 }
Beispiel #10
0
 internal ResultBoilerplateContext(IContextBundle bundle,
                                   IIdentity identity,
                                   IContractBundle contractBundle,
                                   TResult result,
                                   IImmutableQueue <TimeSpan> callTimings)
     : base(contractBundle, bundle)
 {
     this.Identity    = identity;
     this.Result      = result;
     this.callTimings = callTimings;
 }
        public ImmutableContractAwareContext(IContractBundle contractBundle, IContextBundle bundle)
            : base(bundle)
        {
            this.contractBundle     = contractBundle ?? new ContractBundle();
            this.restrictionContext = new ThreadRestrictionContext(contractBundle, bundle);

            if (this.contractBundle is LockTransactionContractBundle)
            {
                this.transactionContractBundle = (LockTransactionContractBundle)this.contractBundle;
            }
        }
 public LockTransactionContractBundle(IContractBundle contractBundle, LockOrder lockOrder = LockOrder.Unknown, ILockTransactionMember[] transactionMembers = null)
     : this(contractBundle.Preconditions,
            contractBundle.PostconditionsOnReturn,
            contractBundle.PostconditionsOnThrow,
            contractBundle.InstanceValidations,
            contractBundle.ThreadCountRestriction,
            contractBundle.ThreadCountRestrictionTimeout,
            contractBundle.ThreadWaitHandleSignalRestriction,
            contractBundle.ThreadWaitHandleSignalRestrictionTimeout,
            transactionMembers,
            lockOrder)
 {
 }
Beispiel #13
0
        public IBoilerplateContext <TResult> Copy(IContextBundle bundle          = null,
                                                  IContractBundle contractBundle = null,
                                                  TResult result = default(TResult))
        {
            var resultWasProvided = !EqualityComparer <TResult> .Default.Equals(result, default(TResult));

            var actualResult = (resultWasProvided) ? result : this.Result;

            return(new ResultBoilerplateContext <TResult>(bundle ?? this.bundle,
                                                          this.Identity,
                                                          contractBundle ?? this.contractBundle,
                                                          actualResult,
                                                          this.callTimings));
        }
 public LockTransactionContractBundle(IContractBundle contractBundle, LockOrder lockOrder = LockOrder.Unknown, ILockTransactionMember[] transactionMembers = null)
     :this(contractBundle.Preconditions,
           contractBundle.PostconditionsOnReturn,
           contractBundle.PostconditionsOnThrow,
           contractBundle.InstanceValidations,
           contractBundle.ThreadCountRestriction,
           contractBundle.ThreadCountRestrictionTimeout,
           contractBundle.ThreadWaitHandleSignalRestriction,
           contractBundle.ThreadWaitHandleSignalRestrictionTimeout,
           transactionMembers,
           lockOrder)
 {
                
 }
        public LockTransactionContext(IContractBundle contractBundle, IContextBundle contextBundle):base(contextBundle)
        {
            this.contractBundle = contractBundle ?? new ContractBundle();

            var transactionContractBundle = this.contractBundle as LockTransactionContractBundle;
            this.isValidTransaction = transactionContractBundle != null;
            this.transactionMembers = this.isValidTransaction ? transactionContractBundle.TransactionMembers : new ILockTransactionMember[0];
            this.lockOrder = this.isValidTransaction ? transactionContractBundle.LockOrder : LockOrder.Unknown;

            if (this.isValidTransaction)
            {
                Info("Atomic transaction operation is in effect with {0} atomic members".WithValues(this.transactionMembers.Length));
                this.transactionMembers = OrderLocksBy(this.transactionMembers, this.lockOrder).ToArray();
            }
        }
Beispiel #16
0
        public LockTransactionContext(IContractBundle contractBundle, IContextBundle contextBundle) : base(contextBundle)
        {
            this.contractBundle = contractBundle ?? new ContractBundle();

            var transactionContractBundle = this.contractBundle as LockTransactionContractBundle;

            this.isValidTransaction = transactionContractBundle != null;
            this.transactionMembers = this.isValidTransaction ? transactionContractBundle.TransactionMembers : new ILockTransactionMember[0];
            this.lockOrder          = this.isValidTransaction ? transactionContractBundle.LockOrder : LockOrder.Unknown;

            if (this.isValidTransaction)
            {
                Info("Atomic transaction operation is in effect with {0} atomic members".WithValues(this.transactionMembers.Length));
                this.transactionMembers = OrderLocksBy(this.transactionMembers, this.lockOrder).ToArray();
            }
        }
Beispiel #17
0
        public IBoilerplateContext <TResult> MergeCopy(IContextBundle settings        = null,
                                                       IIdentity account              = null,
                                                       IContractBundle contractBundle = null,
                                                       TResult result = default(TResult),
                                                       IImmutableQueue <TimeSpan> callTimings = null)
        {
            var resultWasProvided = !EqualityComparer <TResult> .Default.Equals(result, default(TResult));

            var actualResult = (resultWasProvided) ? result : this.Result;

            return(new ResultBoilerplateContext <TResult>(settings ?? this.bundle,
                                                          account ?? this.Identity,
                                                          contractBundle ?? this.contractBundle,
                                                          actualResult,
                                                          callTimings));
        }
Beispiel #18
0
        public ThreadRestrictionContext(IContractBundle contractBundle, IContextBundle bundle) : base(bundle)
        {
            this.contractBundle = contractBundle ?? new ContractBundle();
            var threadCountRestriction = this.contractBundle.ThreadCountRestriction;

            this.threadRestrictor   = (threadCountRestriction > 0) ? new Semaphore(threadCountRestriction, threadCountRestriction) : null;
            this.waitHandle         = this.contractBundle.ThreadWaitHandleSignalRestriction;
            this.transactionContext = new LockTransactionContext(this.contractBundle, bundle);

            if (this.threadRestrictor != null)
            {
                Info("Thread count restriction (count <= {0}) is in effect".WithValues(threadCountRestriction));
            }

            if (this.waitHandle != null)
            {
                Info("Thread wait handle restriction is in effect");
            }
        }
Beispiel #19
0
 public ContractHandledContext(IContextBundle bundle,
                               IContractBundle contractBundle,
                               IBoilerplateContext <TResult> originalContext)
     : base(bundle, contractBundle, originalContext)
 {
 }
 public override IInitialContractContext Copy(IContextBundle bundle = null, IContractBundle contractBundle = null)
 {
     return(new ContractContext(bundle ?? this.bundle,
                                contractBundle ?? this.contractBundle,
                                this.originalContext));
 }
Beispiel #21
0
 public VoidReturnContractHandledContext(IContextBundle bundle,
                                         IContractBundle contractBundle,
                                         ICopyableTrait <IBoilerplateContext> originalContext)
     : base(bundle, contractBundle, originalContext)
 {
 }
Beispiel #22
0
 public abstract TContext Copy(IContextBundle bundle          = null,
                               IContractBundle contractBundle = null);
Beispiel #23
0
 public ContractContextBase(IContextBundle bundle,
                            IContractBundle contractBundle)
 {
     this.bundle         = bundle;
     this.contractBundle = contractBundle;
 }
 public ThreadRestrictionBuilder(TActualContext context, IContextBundle bundle, IContractBundle contractBundle)
 {
     this.context        = context;
     this.bundle         = bundle;
     this.contractBundle = contractBundle;
 }
Beispiel #25
0
 public AtomicOperationBuilder(TActualContext context, IContextBundle bundle, IContractBundle contractBundle)
 {
     this.context        = context;
     this.bundle         = bundle;
     this.contractBundle = contractBundle;
 }
Beispiel #26
0
 public ThreadRestrictionContext Copy(IContextBundle bundle = null, IContractBundle contractBundle = null)
 {
     return(new ThreadRestrictionContext(contractBundle ?? this.contractBundle,
                                         bundle ?? this.bundle));
 }