Esempio n. 1
0
        public void CreateVoter(
            ITransactionVoterNotifyAsync2 voterNotification,
            IntPtr voterBallot)
        {
            if (IntPtr.Zero == voterBallot)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("voterBallot");
            }

            lock (this.syncRoot)
            {
                if (this.currentVoter != null)
                {
                    // transactions require failfasts to prevent corruption
                    DiagnosticUtility.FailFast("Assumption: proxy only needs one voter");
                }

                VoterBallot voter = new VoterBallot(voterNotification, this);
                if (this.currentTransaction != null)
                {
                    voter.SetTransaction(this.currentTransaction);
                }

                this.currentVoter = voter;

                IntPtr ppv = InterfaceHelper.GetInterfacePtrForObject(typeof(ITransactionVoterBallotAsync2).GUID, this.currentVoter);

                Marshal.WriteIntPtr(voterBallot, ppv);
            }
        }
 private void ClearTransaction(ProxyEnlistment enlistment)
 {
     lock (this.syncRoot)
     {
         if (this.currentTransaction == null)
         {
             DiagnosticUtility.FailFast("Clearing inactive TransactionProxy");
         }
         if (enlistment.Transaction != this.currentTransaction)
         {
             DiagnosticUtility.FailFast("Incorrectly working on multiple transactions");
         }
         this.currentTransaction = null;
         this.currentVoter       = null;
     }
 }
 public void CreateVoter(ITransactionVoterNotifyAsync2 voterNotification, IntPtr voterBallot)
 {
     if (IntPtr.Zero == voterBallot)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("voterBallot");
     }
     lock (this.syncRoot)
     {
         if (this.currentVoter != null)
         {
             DiagnosticUtility.FailFast("Assumption: proxy only needs one voter");
         }
         VoterBallot ballot = new VoterBallot(voterNotification, this);
         if (this.currentTransaction != null)
         {
             ballot.SetTransaction(this.currentTransaction);
         }
         this.currentVoter = ballot;
         IntPtr interfacePtrForObject = InterfaceHelper.GetInterfacePtrForObject(typeof(ITransactionVoterBallotAsync2).GUID, this.currentVoter);
         Marshal.WriteIntPtr(voterBallot, interfacePtrForObject);
     }
 }