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
。
範例
下列程式代碼範例會取得並設定 ObjectPoolingAttribute
的 Enabled 屬性值。
[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