private void InnerBegin()
		{
			Contract.Ensures(_State == TransactionState.Active);
			// we have a ongoing current transaction, join it!
			if (System.Transactions.Transaction.Current != null)
			{
				var ktx = (IKernelTransaction) TransactionInterop.GetDtcTransaction(System.Transactions.Transaction.Current);

				SafeKernelTransactionHandle 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;
				//IsAmbient = true; // TODO: Perhaps we created this item and we need to notify the transaction manager...
			}
			else _TransactionHandle = NativeMethods.createTransaction(string.Format("{0} Transaction", _Name));

			if (!_TransactionHandle.IsInvalid)
			{
				_State = TransactionState.Active;
				return;
			}

			throw new TransactionException(
				"Cannot begin file transaction. CreateTransaction failed and there's no ambient transaction.",
				LastEx());
		}
Пример #2
0
		internal static extern bool RemoveDirectoryTransactedW(
			[MarshalAs(UnmanagedType.LPWStr)] string lpPathName,
			SafeKernelTransactionHandle hTransaction);
Пример #3
0
		internal static extern bool CommitTransaction(SafeKernelTransactionHandle transaction);
Пример #4
0
		internal static extern bool CreateDirectoryTransactedW(
			[MarshalAs(UnmanagedType.LPWStr)] string lpTemplateDirectory,
			[MarshalAs(UnmanagedType.LPWStr)] string lpNewDirectory,
			IntPtr lpSecurityAttributes,
			SafeKernelTransactionHandle hTransaction);
Пример #5
0
		/// <summary>
		/// Not extern
		/// </summary>
		internal static SafeFindHandle FindFirstFileTransactedW(string lpFileName,
			SafeKernelTransactionHandle kernelTxHandle, out WIN32_FIND_DATA lpFindFileData)
		{
			return FindFirstFileTransactedW(lpFileName, FINDEX_INFO_LEVELS.FindExInfoStandard,
											out lpFindFileData,
											FINDEX_SEARCH_OPS.FindExSearchNameMatch,
											IntPtr.Zero, 0,
											kernelTxHandle);
		}
Пример #6
0
		/// <summary>
		/// Not extern
		/// </summary>
		internal static SafeFindHandle FindFirstFileTransacted(string filePath, bool directory, SafeKernelTransactionHandle kernelTxHandle)
		{
			WIN32_FIND_DATA data;

#if MONO
			const uint caseSensitive = 0x1;
#else
			const uint caseSensitive = 0;
#endif

			return FindFirstFileTransactedW(filePath,
											FINDEX_INFO_LEVELS.FindExInfoStandard, out data,
											directory
												? FINDEX_SEARCH_OPS.FindExSearchLimitToDirectories
												: FINDEX_SEARCH_OPS.FindExSearchNameMatch,
											IntPtr.Zero, caseSensitive, kernelTxHandle);
		}
Пример #7
0
		internal static extern bool DeleteFileTransactedW(
			[MarshalAs(UnmanagedType.LPWStr)] string file,
			SafeKernelTransactionHandle transaction);
Пример #8
0
		internal static extern bool RollbackTransaction(SafeKernelTransactionHandle transaction);