首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >是否可以从SPWeb继承?

是否可以从SPWeb继承?
EN

Stack Overflow用户
提问于 2010-10-14 12:53:03
回答 5查看 1.2K关注 0票数 1

是否可以从SharePoint类继承,如: SPWeb、SPList等,或者这个类是密封的?我找不到正确的答案。

克里斯

谢谢你的回复。里奇,你说得对--构造器是内部的。所以这意味着我不能以任何优雅的方式扩展这些类的功能?

EN

回答 5

Stack Overflow用户

发布于 2010-10-14 15:34:57

根据Reflector的说法,SPWeb在2007年或2010年都没有密封。

2007年:

代码语言:javascript
复制
[SharePointPermission(SecurityAction.LinkDemand, ObjectModel=true), 
SharePointPermission(SecurityAction.LinkDemand, ObjectModel=true), 
SharePointPermission(SecurityAction.LinkDemand, ObjectModel=true), 
SharePointPermission(SecurityAction.InheritanceDemand, ObjectModel=true)]
public class SPWeb : IDisposable, ISecurableObject

2010年:

代码语言:javascript
复制
[SubsetCallableType, 
ClientCallableType(Name="Web", ServerTypeId="{A489ADD2-5D3A-4de8-9445-49259462DCEB}", FactoryType=typeof(SPObjectFactory), ObjectIdentityPropertyName="CanonicalId"), 
SharePointPermission(SecurityAction.InheritanceDemand, ObjectModel=true), 
SharePointPermission(SecurityAction.LinkDemand, ObjectModel=true), 
SharePointPermission(SecurityAction.LinkDemand, ObjectModel=true), 
SharePointPermission(SecurityAction.LinkDemand, ObjectModel=true)]
public class SPWeb : SPSecurableObject, IDisposable

但是,在这两个版本中,类都只有内部构造函数,因此虽然Visual将允许您尝试从类继承,但它不会编译:

类型'Microsoft.SharePoint.SPWeb‘没有定义构造函数

票数 2
EN

Stack Overflow用户

发布于 2010-10-14 12:55:39

根据它们的MSDN页面,类不被密封:

SPWeb类

SPList类

尽管您可能能够继承这些类,但我不明白这一点,因为您不能强迫SharePoint在内部使用它们。

通过扩展方法而不是实际从基类继承来提供添加的功能可能更有意义。

票数 0
EN

Stack Overflow用户

发布于 2010-10-14 12:56:35

SPWeb和SPList被密封在SharePoint 2007中,参见:http://blogs.msdn.com/b/francischeung/archive/2008/08/22/unit-testing-sharepoint-2007-applications.aspx

但它们在SharePoint 2010中没有密封,参见:http://my.safaribooksonline.com/9781435456457/365

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/3933270

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档