共用方式為


IBackupRestore Interface

Enables the content that a class represents to be backed up and restored.

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

Syntax

<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public Interface IBackupRestore

Dim instance As IBackupRestore
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public interface IBackupRestore

Remarks

By implementing this interface an object representing some content in a Windows SharePoint Services 3.0 deployment becomes something that can be backed up and restored.

Your code does not call the members of IBackupRestore directly. After you have implemented it, your code will construct objects of your custom IBackupRestore classes and add them to the configuration database with the Update() method. Backup and restore applications, such as the Windows SharePoint Services Central Administration application and the stsadm.exe console application, will make internal calls to the members of your IBackupRestore objects when they are backed up and restored. For more information about how IBackupRestore objects are used, see How to: Create a Content Class That Can Be Backed Up and Restored.

You can create as many types of IBackupRestore classes you want and, if you want, they can be nested as a tree of component classes. But the highest class in any such tree must derive (directly or indirectly) from SPPersistedObject object and must be a child of SPFarm. If your content class is not a child of any other custom content class, it must derive (directly or indirectly) from SPPersistedObject object and must be a child of SPFarm.

If your class derives from a class that already implements IBackupRestore object, and you want to replace an inherited implementation of an IBackupRestore member, your class declaration should explicitly reference IBackupRestore like this:

public class MyClass : SPPersistedObject, IBackupRestore

Your override of any IBackupRestore member should explicitly include "IBackupRestore" in the member name and it should not include the public keyword. The following is an example:

String IBackupRestore.Name { ... }

Alternatively, if the implementation of the member in the parent class used the virtual or override keywords, you can use the override keyword in your implementation like this:

public override String Name { ... }

Do not hide the inherited member implementation by redeclaring the member either with or without the new keyword ([new] public String Name { ... }).

If your class derives from SPPersistedObject, then the declaration of fields that you want to persist in the configuration database must be preceded with the [Persisted] attribute. However, you can only mark the following types of fields in this way: primitive types such as strings, integers, and GUIDs; other SPPersistedObject objects or SPAutoserializingObject objects; or collections of any of the above. For example, the class cannot have a FileInfo field marked with the [Persisted] attribute. If the data you would like to persist is not of a persistable class, use a persistable substitute. The sample implementation in the reference topic for the DiskSizeRequired property envisions a class that persists a collection of file names and uses them to create a temporary collection of FileInfo objects at runtime.

If your class can have multiple children of the same type, create a property or field of a collection type or other enumerable type to hold a collection of all children of a given type. This is particularly important if the child type itself implements IBackupRestore, because your implementation of the AddBackupObjects() method should iterate through such children and call the AddBackupObjects() method of each child.

There is basically a one-to-one mapping between objects of type SPBackupRestoreInformation and objects of type IBackupRestore. Each provides a part of the information needed to process a backup or restore of a particular type of content component. Objects of these two types are referenced, respectively, in the Information and IBackupRestore properties of a SPBackupRestoreObject object. The latter class, in addition to acting as a container for the correlated SPBackupRestoreInformation and IBackupRestore objects, provides helper functions for SPBackupRestoreConsoleObject objects.

See Also

Reference

IBackupRestore Members

Microsoft.SharePoint.Administration.Backup Namespace