SPBackupRestoreObjectCollection.Item 属性

返回集合中指定索引处的对象。

命名空间:  Microsoft.SharePoint.Administration.Backup
程序集:  Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)

语法

声明
Public ReadOnly Default Property Item ( _
    index As Integer _
) As SPBackupRestoreObject
    Get
用法
Dim instance As SPBackupRestoreObjectCollection
Dim index As Integer
Dim value As SPBackupRestoreObject

value = instance(index)
public SPBackupRestoreObject this[
    int index
] { get; }

参数

属性值

类型:Microsoft.SharePoint.Administration.Backup.SPBackupRestoreObject
指定索引处的SPBackupRestoreObject对象。

示例

下图显示Item索引正在使用中的方法,将确保该组件名称由用户提交唯一标识单个组件进行备份或还原操作的组件的树的顶部。有关完整的示例和详细的讨论,请参阅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
Private Shared Function EnsureUniqueValidComponentName(ByVal settings As SPBackupRestoreSettings, ByRef operationGUID As Guid) As SPBackupRestoreObject
Dim list As SPBackupRestoreObjectCollection = SPBackupRestoreConsole.FindItems(operationGUID, settings.IndividualItem)
Dim component As SPBackupRestoreObject = Nothing

If list.Count <= 0 Then
Console.WriteLine("There is no component with that name. Run again with a new name.")
Console.WriteLine("Press Enter to continue.")
Console.ReadLine()
ElseIf list.Count > 1 Then ' 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 i As Integer = 0 To list.Count - 1
Console.WriteLine(vbTab & "{0}", list(i).ToString())
Next i
Console.WriteLine("Press Enter to continue.")
Console.ReadLine()
Else
component = list(0)
End If

Return component

End Function ' end EnsureUniqueValidComponentName

另请参阅

引用

SPBackupRestoreObjectCollection 类

SPBackupRestoreObjectCollection 成员

Microsoft.SharePoint.Administration.Backup 命名空间