TransactionOption 列舉
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
指定元件要求的自動交易類型。
public enum class TransactionOption
[System.Serializable]
public enum TransactionOption
[<System.Serializable>]
type TransactionOption =
Public Enum TransactionOption
- 繼承
- 屬性
欄位
Disabled | 0 | 忽略目前內容中的任何交易。 |
NotSupported | 1 | 在未管理任何交易的內容中建立元件。 |
Required | 3 | 共用交易 (如果存在的話),並且建立新交易 (如果有必要的話)。 |
RequiresNew | 4 | 不論目前內容的狀態如何,都使用新交易建立元件。 |
Supported | 2 | 共用交易 (如果存在的話)。 |
範例
下列程式代碼範例示範型別的使用 TransactionOption 。
#using <System.EnterpriseServices.dll>
using namespace System;
using namespace System::EnterpriseServices;
using namespace System::Reflection;
// References:
// System.EnterpriseServices
// An instance of this class will not participate in transactions, but can
// share its caller's context even if its caller is configured as
// NotSupported, Supported, Required, or RequiresNew.
[Transaction(TransactionOption::Disabled)]
public ref class TransactionDisabled : public ServicedComponent
{
};
// An instance of this class will not participate in transactions, and will
// share its caller's context only if its caller is also configured as
// NotSupported.
[Transaction(TransactionOption::NotSupported)]
public ref class TransactionNotSupported : public ServicedComponent
{
};
// An instance of this class will participate in its caller's transaction
// if one exists.
[Transaction(TransactionOption::Supported)]
public ref class TransactionSupported : public ServicedComponent
{
};
// An instance of this class will participate in its caller's transaction
// if one exists. If not, a new transaction will be created for it.
[Transaction(TransactionOption::Required)]
public ref class TransactionRequired : public ServicedComponent
{
};
// A new transaction will always be created for an instance of this class.
[Transaction(TransactionOption::RequiresNew)]
public ref class TransactionRequiresNew : public ServicedComponent
{
};
using System;
using System.EnterpriseServices;
using System.Reflection;
// References:
// System.EnterpriseServices
// An instance of this class will not participate in transactions, but can
// share its caller's context even if its caller is configured as
// NotSupported, Supported, Required, or RequiresNew.
[Transaction(TransactionOption.Disabled)]
public class TransactionAttribute_TransactionDisabled : ServicedComponent
{
}
// An instance of this class will not participate in transactions, and will
// share its caller's context only if its caller is also configured as
// NotSupported.
[Transaction(TransactionOption.NotSupported)]
public class TransactionAttribute_TransactionNotSupported : ServicedComponent
{
}
// An instance of this class will participate in its caller's transaction
// if one exists.
[Transaction(TransactionOption.Supported)]
public class TransactionAttribute_TransactionSupported : ServicedComponent
{
}
// An instance of this class will participate in its caller's transaction
// if one exists. If not, a new transaction will be created for it.
[Transaction(TransactionOption.Required)]
public class TransactionAttribute_TransactionRequired : ServicedComponent
{
}
// A new transaction will always be created for an instance of this class.
[Transaction(TransactionOption.RequiresNew)]
public class TransactionAttribute_TransactionRequiresNew : ServicedComponent
{
}
Imports System.EnterpriseServices
Imports System.Reflection
' References:
' System.EnterpriseServices
' An instance of this class will not participate in transactions, but can
' share its caller's context even if its caller is configured as
' NotSupported, Supported, Required, or RequiresNew.
<Transaction(TransactionOption.Disabled)> _
Public Class TransactionAttribute_TransactionDisabled
Inherits ServicedComponent
End Class
' An instance of this class will not participate in transactions, and will
' share its caller's context only if its caller is also configured as
' NotSupported.
<Transaction(TransactionOption.NotSupported)> _
Public Class TransactionAttribute_TransactionNotSupported
Inherits ServicedComponent
End Class
' An instance of this class will participate in its caller's transaction
' if one exists.
<Transaction(TransactionOption.Supported)> _
Public Class TransactionAttribute_TransactionSupported
Inherits ServicedComponent
End Class
' An instance of this class will participate in its caller's transaction
' if one exists. If not, a new transaction will be created for it.
<Transaction(TransactionOption.Required)> _
Public Class TransactionAttribute_TransactionRequired
Inherits ServicedComponent
End Class
' A new transaction will always be created for an instance of this class.
<Transaction(TransactionOption.RequiresNew)> _
Public Class TransactionAttribute_TransactionRequiresNew
Inherits ServicedComponent
End Class
備註
使用 .NET 安裝工具 (Regsvcs.exe) 時,預設為 ServicedComponentDisabled的交易選項。