SPPersistedObject class
Fornece os métodos de um objeto serializar seu estado, manter o estado em um armazenamento permanente, recuperá-la mais tarde e desserializá-la de volta em um objeto na memória.
Inheritance hierarchy
System.Object
Microsoft.SharePoint.Administration.SPAutoSerializingObject
Microsoft.SharePoint.Administration.SPPersistedObject
Namespace: Microsoft.SharePoint.Administration
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'Declaração
<GuidAttribute("3B60B328-F4D6-4902-BEC6-E904179FA246")> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public Class SPPersistedObject _
Inherits SPAutoSerializingObject _
Implements ICloneable
'Uso
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
Comentários
A classe SPPersistedObject fornece uma classe base para todos os objetos de administração. Ele serializa todos os campos marcados com o atributo Persisted para XML e grava o blob XML para o banco de dados de configuração. A classe SPPersistedObject contém código para serializar todos os seus membros são tipos base, outros objetos persistentes e coleções de objetos persistentes. Dados de configuração são armazenados em objetos persistentes seja automaticamente disponibilizados para todos os processos em todos os servidores no farm.
Quando você cria um objeto persistente personalizado, você deve especificar o construtor padrão para serialização.
Para retornar um objeto persistente existente, use o método GetObject da classe SPFarm ou o método GetChild da classe SPPersistedObject .
Examples
O exemplo a seguir ilustra uma classe personalizada que herda da classe SPPersistedObject , onde o atributo Peristed é usado para especificar campos para serialização.
<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; }
}
}
Depois de criar um objeto persistente MyObject do exemplo, você poderá retornar usando SPFarm.Local.GetObject(GUID).
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.
Ver também
Referência
Microsoft.SharePoint.Administration namespace
Inheritance hierarchy
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