public AtomicOperationOrderByBuilder(TActualContext context, IContextBundle bundle, IContractBundle contractBundle, params ILockTransactionMember[] transactionMembers)
 {
     this.context            = context;
     this.bundle             = bundle;
     this.contractBundle     = contractBundle;
     this.transactionMembers = transactionMembers.DefaultIfNull();
 }
Example #2
0
 public IResultContractContext <TResult> Copy(IContextBundle bundle          = null,
                                              IContractBundle contractBundle = null)
 {
     return(new ContractContext <TResult>(bundle ?? this.bundle,
                                          contractBundle ?? this.contractBundle,
                                          this.originalContext));
 }
Example #3
0
 public VoidReturnContractContext(IContextBundle bundle,
                                  IContractBundle contractBundle,
                                  ICopyableTrait <IBoilerplateContext> originalContext)
     : base(bundle, contractBundle)
 {
     this.originalContext = originalContext;
 }
Example #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;
 }
Example #6
0
 public ContractContext(IContextBundle bundle,
                        IContractBundle contractBundle,
                        IBoilerplateContext <TResult> originalContext)
 {
     this.bundle          = bundle;
     this.contractBundle  = contractBundle;
     this.originalContext = originalContext;
 }
Example #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();
 }
Example #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;
 }
Example #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)
 {
 }
Example #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();
            }
        }
Example #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();
            }
        }
Example #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));
        }
Example #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");
            }
        }
Example #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));
 }
Example #21
0
 public VoidReturnContractHandledContext(IContextBundle bundle,
                                         IContractBundle contractBundle,
                                         ICopyableTrait <IBoilerplateContext> originalContext)
     : base(bundle, contractBundle, originalContext)
 {
 }
Example #22
0
 public abstract TContext Copy(IContextBundle bundle          = null,
                               IContractBundle contractBundle = null);
Example #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;
 }
Example #25
0
 public AtomicOperationBuilder(TActualContext context, IContextBundle bundle, IContractBundle contractBundle)
 {
     this.context        = context;
     this.bundle         = bundle;
     this.contractBundle = contractBundle;
 }
Example #26
0
 public ThreadRestrictionContext Copy(IContextBundle bundle = null, IContractBundle contractBundle = null)
 {
     return(new ThreadRestrictionContext(contractBundle ?? this.contractBundle,
                                         bundle ?? this.bundle));
 }