SPEventReceiverBase 类

提供Microsoft SharePoint Foundation对象模型中的事件接收器的方法,并作为创建列表项,列表、 访问过的站点和站点的基类。

继承层次结构

System.Object
  Microsoft.SharePoint.SPEventReceiverBase
    Microsoft.SharePoint.SPItemEventReceiver
    Microsoft.SharePoint.SPListEventReceiver
    Microsoft.SharePoint.SPSecurityEventReceiver
    Microsoft.SharePoint.SPWebEventReceiver

命名空间:  Microsoft.SharePoint
程序集:  Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)

语法

声明
Public Class SPEventReceiverBase
用法
Dim instance As SPEventReceiverBase
public class SPEventReceiverBase

备注

SPEventReceiverBase类不应该被启动,但提供的接收器类从其派生的类的继承层次结构部分中列出的方法。重写派生类下面创建自定义事件处理程序,并使用SPEventReceiverDefinition类注册处理程序之一。

示例

下面的代码示例演示如何注册一个自定义事件接收器,捕获 Web 站点上的删除事件。

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

线程安全性

该类型的任何公共 静态 (已共享 在 Visual Basic 中) 成员都是线程安全的。不保证任何实例成员都是线程安全的。

另请参阅

引用

SPEventReceiverBase 成员

Microsoft.SharePoint 命名空间