Ejemplo n.º 1
0
		protected override void InnerBegin()
		{
		retry:
			// we have a ongoing current transaction, join it!
			if (System.Transactions.Transaction.Current != null)
			{
				var ktx = TransactionInterop.GetDtcTransaction(System.Transactions.Transaction.Current)
						  as IKernelTransaction;

				// check for race-condition.
				if (ktx == null)
					goto retry;

				SafeTxHandle handle;
				ktx.GetHandle(out handle);

				// even though _TransactionHandle can already contain a handle if this thread 
				// had been yielded just before setting this reference, the "safe"-ness of the wrapper should
				// not dispose the other handle which is now removed
				_TransactionHandle = handle; // see the link in the remarks to the class for more details about async exceptions
				IsAmbient = true;
			}
			else _TransactionHandle = createTransaction(string.Format("{0} Transaction", _TheName));
			if (!_TransactionHandle.IsInvalid) return;

			throw new TransactionException(
				"Cannot begin file transaction because we got a null pointer back from CreateTransaction.",
				LastEx());
		}
Ejemplo n.º 2
0
 private static extern SafeFindHandle FindFirstFileTransactedW(
     [In, MarshalAs(UnmanagedType.LPWStr)] string lpFileName,
     [In] FINDEX_INFO_LEVELS fInfoLevelId,             // TODO: Won't work.
     [Out] out WIN32_FIND_DATA lpFindFileData,
     [In] FINDEX_SEARCH_OPS fSearchOp,
     IntPtr lpSearchFilter,
     [In] uint dwAdditionalFlags,
     [In] SafeTxHandle hTransaction);
Ejemplo n.º 3
0
 private static extern SafeFileHandle CreateFileTransactedW(
     [In, MarshalAs(UnmanagedType.LPWStr)] string lpFileName,
     [In] NativeFileAccess dwDesiredAccess,
     [In] NativeFileShare dwShareMode,
     [In] IntPtr lpSecurityAttributes,
     [In] NativeFileMode dwCreationDisposition,
     [In] uint dwFlagsAndAttributes,
     [In] IntPtr hTemplateFile,
     [In] SafeTxHandle hTransaction,
     [In] IntPtr pusMiniVersion,
     [In] IntPtr pExtendedParameter);
Ejemplo n.º 4
0
        protected override void InnerBegin()
        {
retry:
            // we have a ongoing current transaction, join it!
            if (System.Transactions.Transaction.Current != null)
            {
                var ktx = TransactionInterop.GetDtcTransaction(System.Transactions.Transaction.Current)
                          as IKernelTransaction;

                // check for race-condition.
                if (ktx == null)
                {
                    goto retry;
                }

                SafeTxHandle handle;
                ktx.GetHandle(out handle);

                // even though _TransactionHandle can already contain a handle if this thread
                // had been yielded just before setting this reference, the "safe"-ness of the wrapper should
                // not dispose the other handle which is now removed
                _TransactionHandle = handle;                 // see the link in the remarks to the class for more details about async exceptions
                IsAmbient          = true;
            }
            else
            {
                _TransactionHandle = createTransaction(string.Format("{0} Transaction", theName));
            }
            if (!_TransactionHandle.IsInvalid)
            {
                return;
            }

            throw new TransactionException(
                      "Cannot begin file transaction because we got a null pointer back from CreateTransaction.",
                      LastEx());
        }
Ejemplo n.º 5
0
		private static extern bool DeleteFileTransactedW(
			[MarshalAs(UnmanagedType.LPWStr)] string file,
			SafeTxHandle transaction);
Ejemplo n.º 6
0
		private static extern bool RollbackTransaction(SafeTxHandle transaction);
Ejemplo n.º 7
0
		private static extern bool CommitTransaction(SafeTxHandle transaction);
Ejemplo n.º 8
0
 private static extern bool RemoveDirectoryTransactedW(
     [MarshalAs(UnmanagedType.LPWStr)] string lpPathName,
     SafeTxHandle hTransaction);
Ejemplo n.º 9
0
 private static extern bool CreateDirectoryTransactedW(
     [MarshalAs(UnmanagedType.LPWStr)] string lpTemplateDirectory,
     [MarshalAs(UnmanagedType.LPWStr)] string lpNewDirectory,
     IntPtr lpSecurityAttributes,
     SafeTxHandle hTransaction);
Ejemplo n.º 10
0
 private static extern bool DeleteFileTransactedW(
     [MarshalAs(UnmanagedType.LPWStr)] string file,
     SafeTxHandle transaction);
Ejemplo n.º 11
0
 private static extern bool MoveFileTransacted([In] string lpExistingFileName,
                                               [In] string lpNewFileName, [In] IntPtr lpProgressRoutine,
                                               [In] IntPtr lpData,
                                               [In] MoveFileFlags dwFlags,
                                               [In] SafeTxHandle hTransaction);
Ejemplo n.º 12
0
 private static extern bool CreateHardLinkTransacted([In] string lpFileName,
                                                     [In] string lpExistingFileName,
                                                     [In] IntPtr lpSecurityAttributes,
                                                     [In] SafeTxHandle hTransaction);
Ejemplo n.º 13
0
 private static extern bool RollbackTransaction(SafeTxHandle transaction);
Ejemplo n.º 14
0
 private static extern bool CommitTransaction(SafeTxHandle transaction);
Ejemplo n.º 15
0
		private static extern bool CreateDirectoryTransactedW(
			[MarshalAs(UnmanagedType.LPWStr)] string lpTemplateDirectory,
			[MarshalAs(UnmanagedType.LPWStr)] string lpNewDirectory,
			IntPtr lpSecurityAttributes,
			SafeTxHandle hTransaction);
Ejemplo n.º 16
0
		private static extern bool RemoveDirectoryTransactedW(
			[MarshalAs(UnmanagedType.LPWStr)] string lpPathName,
			SafeTxHandle hTransaction);
Ejemplo n.º 17
0
 private static extern int GetFullPathNameTransactedW(
     [In, MarshalAs(UnmanagedType.LPWStr)] string lpFileName,
     [In] int nBufferLength,
     [Out] StringBuilder lpBuffer,
     [In, Out] ref IntPtr lpFilePart,
     [In] SafeTxHandle hTransaction);