System.Transactions.TransactionInterop.GetTransactionFromExportCookie C# (CSharp) Method

GetTransactionFromExportCookie() public static method

public static GetTransactionFromExportCookie ( byte cookie ) : Transaction
cookie byte
return Transaction
        public static Transaction GetTransactionFromExportCookie(byte[] cookie)
        {
            if (null == cookie)
            {
                throw new ArgumentNullException(nameof(cookie));
            }

            if (cookie.Length < 32)
            {
                throw new ArgumentException(SR.InvalidArgument, nameof(cookie));
            }

            TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
            if (etwLog.IsEnabled())
            {
                etwLog.MethodEnter(TraceSourceType.TraceSourceDistributed, "TransactionInterop.GetTransactionFromExportCookie");
            }

            var cookieCopy = new byte[cookie.Length];
            Buffer.BlockCopy(cookie, 0, cookieCopy, 0, cookie.Length);
            cookie = cookieCopy;

            // Extract the transaction guid from the propagation token to see if we already have a
            // transaction object for the transaction.
            byte[] guidByteArray = new byte[16];
            for (int i = 0; i < guidByteArray.Length; i++)
            {
                // In a cookie, the transaction guid is preceeded by a signature guid.
                guidByteArray[i] = cookie[i + 16];
            }
            Guid txId = new Guid(guidByteArray);

            // First check to see if there is a promoted LTM transaction with the same ID.  If there
            // is, just return that.
            Transaction transaction = TransactionManager.FindPromotedTransaction(txId);
            if (transaction != null)
            {
                if (etwLog.IsEnabled())
                {
                    etwLog.MethodExit(TraceSourceType.TraceSourceDistributed, "TransactionInterop.GetTransactionFromExportCookie");
                }

                return transaction;
            }

            // Find or create the promoted transaction.
            DistributedTransaction dTx = DistributedTransactionManager.GetTransactionFromExportCookie(cookieCopy, txId);
            transaction = TransactionManager.FindOrCreatePromotedTransaction(txId, dTx);

            if (etwLog.IsEnabled())
            {
                etwLog.MethodExit(TraceSourceType.TraceSourceDistributed, "TransactionInterop.GetTransactionFromExportCookie");
            }

            return transaction;
        }

Same methods

TransactionInterop::GetTransactionFromExportCookie ( byte cookie ) : System.Transactions.Transaction