ObjectPoolingAttribute.Enabled 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取或设置一个值,该值指示是否启用对象池。
public:
property bool Enabled { bool get(); void set(bool value); };
public bool Enabled { get; set; }
member this.Enabled : bool with get, set
Public Property Enabled As Boolean
属性值
如果启用对象池,则为 true
;否则为 false
。 默认值为 true
。
示例
下面的代码示例获取并设置 的 Enabled 属性的值ObjectPoolingAttribute
。
[ObjectPooling(false)]
public ref class ObjectPoolingAttributeEnabled : public ServicedComponent
{
public:
void EnabledExample()
{
// Get the ObjectPoolingAttribute applied to the class.
ObjectPoolingAttribute^ attribute =
(ObjectPoolingAttribute^)Attribute::GetCustomAttribute(
this->GetType(),
ObjectPoolingAttribute::typeid,
false);
// Display the current value of the attribute's Enabled property.
Console::WriteLine("ObjectPoolingAttribute.Enabled: {0}",
attribute->Enabled);
// Set the Enabled property value of the attribute.
attribute->Enabled = true;
// Display the new value of the attribute's Enabled property.
Console::WriteLine("ObjectPoolingAttribute.Enabled: {0}",
attribute->Enabled);
}
};
[ObjectPooling(false)]
public class ObjectPoolingAttribute_Enabled : ServicedComponent
{
public void EnabledExample()
{
// Get the ObjectPoolingAttribute applied to the class.
ObjectPoolingAttribute attribute =
(ObjectPoolingAttribute)Attribute.GetCustomAttribute(
this.GetType(),
typeof(ObjectPoolingAttribute),
false);
// Display the current value of the attribute's Enabled property.
Console.WriteLine("ObjectPoolingAttribute.Enabled: {0}",
attribute.Enabled);
// Set the Enabled property value of the attribute.
attribute.Enabled = true;
// Display the new value of the attribute's Enabled property.
Console.WriteLine("ObjectPoolingAttribute.Enabled: {0}",
attribute.Enabled);
}
}
<ObjectPooling(False)> _
Public Class ObjectPoolingAttribute_Enabled
Inherits ServicedComponent
Public Sub EnabledExample()
' Get the ObjectPoolingAttribute applied to the class.
Dim attribute As ObjectPoolingAttribute = CType(Attribute.GetCustomAttribute(Me.GetType(), GetType(ObjectPoolingAttribute), False), ObjectPoolingAttribute)
' Display the current value of the attribute's Enabled property.
MsgBox("ObjectPoolingAttribute.Enabled: " & attribute.Enabled)
' Set the Enabled property value of the attribute.
attribute.Enabled = True
' Display the new value of the attribute's Enabled property.
MsgBox("ObjectPoolingAttribute.Enabled: " & attribute.Enabled)
End Sub
End Class