SPEventReceiverBase class
提供方法來Microsoft SharePoint Foundation物件模型中的事件接收器,並做為建立清單項目、 清單、 網站,以及站台的基底類別。
Inheritance hierarchy
System.Object
Microsoft.SharePoint.SPEventReceiverBase
Microsoft.SharePoint.SPItemEventReceiver
Microsoft.SharePoint.SPListEventReceiver
Microsoft.SharePoint.SPSecurityEventReceiver
Microsoft.SharePoint.SPWebEventReceiver
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'宣告
Public Class SPEventReceiverBase
'用途
Dim instance As SPEventReceiverBase
public class SPEventReceiverBase
備註
SPEventReceiverBase類別應該不要作初始化,但提供接收器類別衍生自它繼承階層架構章節中所列的方法。覆寫其中一個衍生類別下面建立自訂事件處理常式,並使用SPEventReceiverDefinition類別註冊處理常式。
Examples
下列程式碼範例示範如何註冊設陷在網站上的 delete 事件的自訂事件接收器。
Dim webSite As SPWeb = New SPSite("https://localhost").OpenWeb()
Dim newReceiver As SPEventReceiverDefinition = webSite.EventReceivers.Add()
newReceiver.Class = "Receiver.Class1"
newReceiver.Assembly = "Receiver, Version=1.0.0.0, Culture=neutral, PublicKeyToken =10b23036c9b36d6d"
newReceiver.SequenceNumber = 3000
newReceiver.Type = SPEventReceiverType.SiteDeleting
newReceiver.Update()
SPWeb oWebsite = new SPSite("https://localhost").OpenWeb();
SPEventReceiverDefinition newReceiver = oWebsite.EventReceivers.Add();
newReceiver.Class = "Receiver.Class1";
newReceiver.Assembly = "Receiver, Version=1.0.0.0, Culture=neutral, PublicKeyToken =10b23036c9b36d6d";
newReceiver.SequenceNumber = 3000;
newReceiver.Type = SPEventReceiverType.SiteDeleting;
newReceiver.Update();
oWebsite.Dispose();
注意事項 |
---|
某些物件實作IDisposable介面,並且您必須避免之後不再需要保留這些物件在記憶體中。良好的程式碼撰寫方式的相關資訊,請參閱Disposing Objects。 |
Thread safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.