SPBackupRestoreInformation.SetParameter 方法

将指定的键 / 值对添加到一个内部存储的参数。

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

语法

声明
Public Sub SetParameter ( _
    key As String, _
    value As Object _
)
用法
Dim instance As SPBackupRestoreInformation
Dim key As String
Dim value As Object

instance.SetParameter(key, value)
public void SetParameter(
    string key,
    Object value
)

参数

  • key
    类型:System.String

    参数名称,该名称用作查找关键字。

  • value
    类型:System.Object

    分配给作为其值返回的参数的对象。如果此对象是类型SPBackupRestoreParameter,这是什么将被保存。如果没有,然后它将被转换为一个字符串,通过该对象的ToString()方法,该字符串将被保存。

异常

异常 条件
SPException

SPBackupRestoreInformation对象是只读的。(请参阅备注详细信息)。

备注

是"SPDescription"、"SPTypeName"或"SPObjectGroup"的参数键时,即使SPBackupRestoreInformation对象是只读的也不是引发异常。

示例

下面的示例演示如何在AddBackupObjects方法的实现中使用的SetParameter方法。

public void AddBackupObjects(SPBackupRestoreObject parent)
{
    if (parent == null)
    {
        throw new ArgumentNullException("parent");
    }

    SPBackupRestoreObject self = parent.AddChild(this);
    self.Information.SetParameter(SPBackupRestoreObject.SPTypeName, this.GetType());
    self.Information.SetParameter(SPBackupRestoreObject.SPDescription, "Description of custom content component");

    foreach (ChildContent child in ChildContentCollection)
    {
        IBackupRestore childIBR = child as IBackupRestore;
        childIBR.AddBackupObjects(self);
    }
}
Public Sub AddBackupObjects(ByVal parent As SPBackupRestoreObject)
    If parent Is Nothing Then
        Throw New ArgumentNullException("parent")
    End If

    Dim self As SPBackupRestoreObject = parent.AddChild(Me)
    self.Information.SetParameter(SPBackupRestoreObject.SPTypeName, Me.GetType())
    self.Information.SetParameter(SPBackupRestoreObject.SPDescription, "Description of custom content component")

     For Each child As ChildContent In ChildContentCollection
        Dim childIBR As IBackupRestore = TryCast(child, IBackupRestore)
        childIBR.AddBackupObjects(self)
    Next child
End Sub

另请参阅

引用

SPBackupRestoreInformation 类

SPBackupRestoreInformation 成员

Microsoft.SharePoint.Administration.Backup 命名空间