这个是SharePoint里的一个类,我就是要继承他,目的是要实现按部门设置权限. [SharePointPermission(SecurityAction.LinkDemand, ObjectModel=true), SharePointPermission(SecurityAction.InheritanceDemand, ObjectModel=true)] public abstract class SPPrincipal : SPMember { // Fields protected object[,] m_arrMembersData; protected bool m_bDataInitialized; protected uint m_index; internal ISecurableObject m_SecurableObject; protected SPWeb m_web; // Methods internal SPPrincipal(SPWeb web, ISecurableObject scope, object[,] arrMembersData, uint index) { if (web == null) { throw new ArgumentException(); } this.m_web = web; this.m_SecurableObject = scope; this.m_index = index; this.m_arrMembersData = arrMembersData; this.m_bDataInitialized = arrMembersData != null; } protected object GetField(uint fieldIndex) { if (!this.m_bDataInitialized) { this.InitMember(); } if (this.m_arrMembersData == null) { throw new ArgumentException(); } return this.m_arrMembersData[fieldIndex, this.m_index]; } protected abstract void InitMember(); protected void SetField(uint fieldIndex, object value) { if (!this.m_bDataInitialized) { this.InitMember(); } if (this.m_arrMembersData == null) { throw new ArgumentException(); } this.m_arrMembersData[fieldIndex, this.m_index] = value; } // Properties public abstract string Name { get; set; } public SPWeb ParentWeb { get { return this.m_web; } } private SPRoleDefinitionBindingCollection RoleBindings { get { try { return this.m_web.RoleAssignments.GetAssignmentByPrincipal(this).RoleDefinitionBindings; } catch (ArgumentException) { return new SPRoleDefinitionBindingCollection(); } } } [Obsolete("Use the SPRoleAssignment class instead")] public SPRoleCollection Roles { get { return new SPRoleCollection(this.m_web, this.RoleBindings); } } }
子类继承父类,首先要确保父类可以被创造,不管父类有没有internal 构造函数,只要他能在程序集外被创造,它就可以继承类似 namespace one { public abstract class baseclass { internal baseclass( ) { } public baseclass( int a ) {} } } namespace two { public class childclass:One.baseclass { public childclass( int a):base(a) {} } }
没测试,楼主自己试一下
internal肯定是不行的
[SharePointPermission(SecurityAction.LinkDemand, ObjectModel=true), SharePointPermission(SecurityAction.InheritanceDemand, ObjectModel=true)]
public abstract class SPPrincipal : SPMember
{
// Fields
protected object[,] m_arrMembersData;
protected bool m_bDataInitialized;
protected uint m_index;
internal ISecurableObject m_SecurableObject;
protected SPWeb m_web; // Methods
internal SPPrincipal(SPWeb web, ISecurableObject scope, object[,] arrMembersData, uint index)
{
if (web == null)
{
throw new ArgumentException();
}
this.m_web = web;
this.m_SecurableObject = scope;
this.m_index = index;
this.m_arrMembersData = arrMembersData;
this.m_bDataInitialized = arrMembersData != null;
} protected object GetField(uint fieldIndex)
{
if (!this.m_bDataInitialized)
{
this.InitMember();
}
if (this.m_arrMembersData == null)
{
throw new ArgumentException();
}
return this.m_arrMembersData[fieldIndex, this.m_index];
} protected abstract void InitMember();
protected void SetField(uint fieldIndex, object value)
{
if (!this.m_bDataInitialized)
{
this.InitMember();
}
if (this.m_arrMembersData == null)
{
throw new ArgumentException();
}
this.m_arrMembersData[fieldIndex, this.m_index] = value;
} // Properties
public abstract string Name { get; set; } public SPWeb ParentWeb
{
get
{
return this.m_web;
}
} private SPRoleDefinitionBindingCollection RoleBindings
{
get
{
try
{
return this.m_web.RoleAssignments.GetAssignmentByPrincipal(this).RoleDefinitionBindings;
}
catch (ArgumentException)
{
return new SPRoleDefinitionBindingCollection();
}
}
} [Obsolete("Use the SPRoleAssignment class instead")]
public SPRoleCollection Roles
{
get
{
return new SPRoleCollection(this.m_web, this.RoleBindings);
}
}
}
namespace one
{
public abstract class baseclass
{
internal baseclass( )
{
}
public baseclass( int a )
{}
}
}
namespace two
{
public class childclass:One.baseclass
{
public childclass( int a):base(a)
{}
}
}