次の方法で共有


SPBackupRestoreObjectCollection Class

Represents a collection of SPBackupRestoreObjectCollection objects.

Inheritance Hierarchy

System.Object
  Microsoft.SharePoint.Administration.Backup.SPBackupRestoreObjectCollection

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

Syntax

<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public NotInheritable Class SPBackupRestoreObjectCollection _
    Implements IEnumerable

Dim instance As SPBackupRestoreObjectCollection
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public sealed class SPBackupRestoreObjectCollection : IEnumerable

Examples

The following shows the SPBackupRestoreObjectCollection class being used in a method that will ensure that the component name submitted by a user uniquely identifies a single component to be the top of the tree of components that will be processed by a backup or restore operation. For the full example and a detailed discussion of it, see How to: Programmatically Back Up Content.

private static SPBackupRestoreObject EnsureUniqueValidComponentName(SPBackupRestoreSettings settings, ref Guid operationGUID)
{
    SPBackupRestoreObjectCollection list = SPBackupRestoreConsole.FindItems(operationGUID, settings.IndividualItem);
    SPBackupRestoreObject component = null;

    if (list.Count <= 0)
    {
        Console.WriteLine("There is no component with that name. Run again with a new name.");
        Console.WriteLine("Press Enter to continue.");
        Console.ReadLine();
    }
    else if (list.Count > 1)  // The component name specified is ambiguous. Prompt user to be more specific.
    {
        Console.WriteLine("More than one component matches the name you entered.");
        Console.WriteLine("Run again with one of the following:");
        for (int i = 0; i < list.Count; i++)
        {
            Console.WriteLine("\t{0}", list[i].ToString());
        }
        Console.WriteLine("Press Enter to continue.");
        Console.ReadLine();
    }
    else
    {
        component = list[0];
    }

    return component;

}// end EnsureUniqueValidComponentName

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.

See Also

Reference

SPBackupRestoreObjectCollection Members

Microsoft.SharePoint.Administration.Backup Namespace