SPPersistedObject 类
提供了用于自动序列化其状态、 保持永久存储区中的状态,以后,检索和反序列化的对象的方法回内存中对象。
继承层次结构
System.Object
Microsoft.SharePoint.Administration.SPAutoSerializingObject
Microsoft.SharePoint.Administration.SPPersistedObject
命名空间: Microsoft.SharePoint.Administration
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
<GuidAttribute("3B60B328-F4D6-4902-BEC6-E904179FA246")> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public Class SPPersistedObject _
Inherits SPAutoSerializingObject _
Implements ICloneable
用法
Dim instance As SPPersistedObject
[GuidAttribute("3B60B328-F4D6-4902-BEC6-E904179FA246")]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
public class SPPersistedObject : SPAutoSerializingObject,
ICloneable
备注
SPPersistedObject类的所有管理对象提供基类。它序列化使用Persisted属性设置为 XML 标记的所有字段,并将该 XML blob 写入到配置数据库。SPPersistedObject类包含代码序列化其基类型、 其他持久的对象,和持久化对象的集合的所有成员。每个进程可用的服务器场中每台服务器自动进行配置数据存储在持久对象。
当您创建一个自定义的持久性的对象时必须指定默认的构造函数进行序列化。
若要返回现有的持久化的对象,使用GetObject方法的SPFarm类或SPPersistedObject类的GetChild方法。
示例
下面的示例阐释了其中的Peristed属性用于指定用于序列化的字段的SPPersistedObject类从继承的自定义类。
<GuidAttribute("3B60B328-F4D6-4902-BEC6-E904179FA246")>
Public Class MyObject
Inherits SPPersistedObject
<Persisted()> _
Private location As String
<Persisted()> _
Private url As String
'The default constructor must be specified for serialization.
Public Sub New()
End Sub 'New
Public Sub New(name As String, parent As SPPersistedObject)
MyBase.New(name, parent)
End Sub 'New
Public Overrides ReadOnly Property DisplayName() As String
Get
Return Me.url
End Get
End Property
Public Property Url() As String
Get
Return Me.url
End Get
Set
If Me.url = value Then
Return
End If
Me.url = value
End Set
End Property
Public Property Location() As String
Get
Return Me.location
End Get
Set
Me.location = value
End Set
End Property
End Class 'MyObject
[GuidAttribute("3B60B328-F4D6-4902-BEC6-E904179FA246")]
public class MyObject : SPPersistedObject
{
[Persisted]
private string location;
[Persisted]
private string url;
/*The default constructor must be specified for serialization.*/
public MyObject()
{
}
public MyObject(string name, SPPersistedObject parent)
: base(name, parent)
{
;
}
public override string DisplayName
{
get
{
return this.url;
}
}
public string Url
{
get { return this.url; }
set
{
if (this.url == value)
{
return;
}
this.url = value;
}
}
public string Location
{
get { return this.location; }
set { this.location = value; }
}
}
创建与示例 MyObject 持久的对象后,可以通过使用SPFarm.Local.GetObject(GUID)返回它。
线程安全性
该类型的任何公共 静态 (已共享 在 Visual Basic 中) 成员都是线程安全的。不保证任何实例成员都是线程安全的。
另请参阅
引用
Microsoft.SharePoint.Administration 命名空间
继承层次结构
System.Object
Microsoft.SharePoint.Administration.SPAutoSerializingObject
Microsoft.SharePoint.Administration.SPPersistedObject
Microsoft.SharePoint.Administration.AppDeployment.DatabaseProviderTypePersistedObject
Microsoft.SharePoint.Administration.AppDeployment.WorkflowAppPartTypePersistedObject
Microsoft.SharePoint.Administration.AppDeployment.WorkflowDeploymentGroupTypePersistedObject
Microsoft.SharePoint.Administration.Backup.SPBackupRestoreConfigurationSettings
Microsoft.SharePoint.Administration.Backup.SPVssDiscoveryHelper
Microsoft.SharePoint.Administration.Claims.SPClaimProviderManager
Microsoft.SharePoint.Administration.Claims.SPIdentityClaimMapperManager
Microsoft.SharePoint.Administration.Claims.SPSecurityTokenServiceManager
Microsoft.SharePoint.Administration.Claims.SPTrustedProviderBase
Microsoft.SharePoint.Administration.SPAlternateUrlCollection
Microsoft.SharePoint.Administration.SPDeveloperDashboardSettings
Microsoft.SharePoint.Administration.SPDocumentConverter
Microsoft.SharePoint.Administration.SPEncryptedString
Microsoft.SharePoint.Administration.SPFarmConfigurationWizardSettings
Microsoft.SharePoint.Administration.SPFeatureDefinition
Microsoft.SharePoint.Administration.SPHealthReportStore
Microsoft.SharePoint.Administration.SPIisWebServiceApplicationPool
Microsoft.SharePoint.Administration.SPIisWebServiceEndpoint
Microsoft.SharePoint.Administration.SPJobDefinition
Microsoft.SharePoint.Administration.SPManagedAccount
Microsoft.SharePoint.Administration.SPMigratableSiteCollection
Microsoft.SharePoint.Administration.SPPersistedCustomWebTemplate
Microsoft.SharePoint.Administration.SPPersistedFile
Microsoft.SharePoint.Administration.SPPersistedUpgradableObject
Microsoft.SharePoint.Administration.SPProcessIdentity
Microsoft.SharePoint.Administration.SPRequestManagementRuleCollection<T>
Microsoft.SharePoint.Administration.SPRequestManagementSettings
Microsoft.SharePoint.Administration.SPResourceMeasure
Microsoft.SharePoint.Administration.SPRoutingMachineInfo
Microsoft.SharePoint.Administration.SPRoutingMachinePool
Microsoft.SharePoint.Administration.SPSiteUpgradeThrottleSettings
Microsoft.SharePoint.Administration.SPSolution
Microsoft.SharePoint.Administration.SPSolutionLanguagePack
Microsoft.SharePoint.Administration.SPUsageDefinition
Microsoft.SharePoint.Administration.SPUsageIdentityTable
Microsoft.SharePoint.Administration.SPUsageManager
Microsoft.SharePoint.Administration.SPUsageReceiverDefinition
Microsoft.SharePoint.Administration.SPUsageSettings
Microsoft.SharePoint.Administration.SPUserCodeProvider
Microsoft.SharePoint.Administration.SPUserSettingsProviderManager
Microsoft.SharePoint.ApplicationServices.SPAuthenticationPipelineClaimMapping
Microsoft.SharePoint.DistributedCaching.Utilities.SPDistributedCacheClusterInfo
Microsoft.SharePoint.DistributedCaching.Utilities.SPDistributedCacheClusterInfoManager
Microsoft.SharePoint.DistributedCaching.Utilities.SPDistributedCacheHostInfo
Microsoft.SharePoint.Upgrade.SPUpgradeSession