TransactionOption 枚举

指定组件请求的自动事务类型。

**命名空间:**System.EnterpriseServices
**程序集:**System.EnterpriseServices(在 system.enterpriseservices.dll 中)

语法

声明
<SerializableAttribute> _
Public Enumeration TransactionOption
用法
Dim instance As TransactionOption
[SerializableAttribute] 
public enum TransactionOption
[SerializableAttribute] 
public enum class TransactionOption
/** @attribute SerializableAttribute() */ 
public enum TransactionOption
SerializableAttribute 
public enum TransactionOption

成员

  成员名称 说明
Disabled 忽略当前上下文中的任何事务。 
NotSupported 使用非受控事务在上下文中创建组件。 
Required 如果事务存在,则共享该事务;如有必要,则创建新事务。 
RequiresNew 使用新事务创建组件,而与当前上下文的状态无关。 
Supported 如果事务存在,则共享该事务。 

备注

在使用 .NET 安装工具 (Regsvcs.exe) 时,ServicedComponent 的事务选项默认为 Disabled

示例

下面的代码示例演示如何使用 TransactionOption 类型。

Imports System
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 'TransactionAttribute_TransactionDisabled

' 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 'TransactionAttribute_TransactionNotSupported

' 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 'TransactionAttribute_TransactionSupported

' 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 'TransactionAttribute_TransactionRequired

' A new transaction will always be created for an instance of this class.
<Transaction(TransactionOption.RequiresNew)>  _
Public Class TransactionAttribute_TransactionRequiresNew
    Inherits ServicedComponent
End Class 'TransactionAttribute_TransactionRequiresNew
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
{
}
#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
{
};
import System.*;
import System.EnterpriseServices.*;
import 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.
/** @attribute Transaction(TransactionOption.Disabled)
 */
public class TransactionAttribute_TransactionDisabled extends ServicedComponent
{
} //TransactionAttribute_TransactionDisabled

// 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.
/** @attribute Transaction(TransactionOption.NotSupported)
 */
public class TransactionAttribute_TransactionNotSupported extends 
    ServicedComponent
{
} //TransactionAttribute_TransactionNotSupported

// An instance of this class will participate in its caller's transaction
// if one exists.
/** @attribute Transaction(TransactionOption.Supported)
 */
public class TransactionAttribute_TransactionSupported extends ServicedComponent
{
} //TransactionAttribute_TransactionSupported

// 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.
/** @attribute Transaction(TransactionOption.Required)
 */
public class TransactionAttribute_TransactionRequired extends ServicedComponent
{
} //TransactionAttribute_TransactionRequired

// A new transaction will always be created for an instance of this class.
/** @attribute Transaction(TransactionOption.RequiresNew)
 */
public class TransactionAttribute_TransactionRequiresNew extends 
    ServicedComponent
{
} //TransactionAttribute_TransactionRequiresNew

平台

Windows 98、Windows 2000 SP4、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

System.EnterpriseServices 命名空间