Export (0) Print
Expand All

SPPersistedObject class

Provides the methods for an object to automatically serialize its state, persist that state in a permanent store, retrieve it at a later time, and deserialize it back into an in-memory object.

System.Object
  Microsoft.SharePoint.Administration.SPAutoSerializingObject
    Microsoft.SharePoint.Administration.SPPersistedObject
      

Namespace:  Microsoft.SharePoint.Administration
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

'Declaration
<GuidAttribute("3B60B328-F4D6-4902-BEC6-E904179FA246")> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
Public Class SPPersistedObject _
	Inherits SPAutoSerializingObject _
	Implements ICloneable
'Usage
Dim instance As SPPersistedObject

The SPPersistedObject class provides a base class for all administration objects. It serializes all fields marked with the Persisted attribute to XML and writes the XML blob to the configuration database. The SPPersistedObject class contains code to serialize all its members that are base types, other persisted objects, and collections of persisted objects. Configuration data that is stored in persisted objects is automatically made available to every process on every server in the farm.

When you create a custom persisted object you must specify the default constructor for serialization.

To return an existing persisted object, use the GetObject method of the SPFarm class, or the GetChild method of the SPPersistedObject class.

The following example illustrates a custom class that inherits from the SPPersistedObject class where the Peristed attribute is used to specify fields for serialization.

<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

After you create a MyObject persisted object as in the example, you can return it by using SPFarm.Local.GetObject(GUID).

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

System.Object
  Microsoft.SharePoint.Administration.SPAutoSerializingObject
    Microsoft.SharePoint.Administration.SPPersistedObject
      Microsoft.SharePoint.Administration.AppDeployment.DatabaseProviderTypePersistedObject
      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

Community Additions

ADD
Show:
© 2014 Microsoft