共用方式為


IBackupRestore.Name property

取得或設定的名稱,以用於 SharePoint 伺服器陣列備份與還原 UI 之內容的元件。

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

Syntax

'宣告
Property Name As String
    Get
    Set
'用途
Dim instance As IBackupRestore
Dim value As String

value = instance.Name

instance.Name = value
string Name { get; set; }

Property value

Type: System.String
IBackupRestore 物件所表示的命名內容元件String

備註

如果您的類別衍生自SPPersistedObject項目,不會實作此成員。

Name屬性做為stsadm.exeUI、管理中心應用程式的使用者介面、 SharePoint Management Shell指令程式 UI 及使用者介面的任何自訂的備份及還原應用程式中的內容元件的名稱。在大多數情況下,您可以實作該屬性所建立之 name 值的私用欄位,並為欄位周圍的包裝函式實作公用屬性。

如果已設定之前,可能會閱讀Name屬性,請考慮設計get accessor 傳回類型為取代者的名稱。請參閱下面的的第二個範例。

如果您的元件會取得名稱,當它已安裝,且應該永遠不會重新命名,請考慮將它的名稱的當地語系化的版本儲存的一組資源檔案。設計get存取子屬性從目前的文化特性設為基礎的適當檔案讀取元件名稱。set存取子,在這類的實作中,會有無程式碼,就是沒有私人功能變數。請參閱下面的的第三個範例。

Examples

下列程式碼會顯示三種方法可以實作Name屬性。

// First example:

private String name;
public String Name
{
    get {return name;}
    set {name = value;}
}

// Second example:

private String name;
public String Name
{
    get 
    {
        if (name == null)
        { 
              name = this.GetType();
         }
         return name;
    }
    set {name = value;}
}

// Third example: 
// ComponentLookupKey is a constant assigned to the content component.
// LocalizedString uses the current culture to identify which file 
// to open andlookup ComponentLookupKey. It returns the string 
// assigned in that file to ComponentLookupKey.

public String Name
{
    get 
    {
         return LocalizedString(ComponentLookupKey, CultureInfo.CurrentCulture);
    }
    set {}
}
' First example:

Private _name As String
Public Property Name() As String
    Get
        Return name
    End Get
    Set(ByVal value As String)
        name = value
    End Set
End Property

' Second example:

Private _name As String
Public Property Name() As String
    Get
        If name Is Nothing Then
              name = Me.GetType()
        End If
         Return name
    End Get
    Set(ByVal value As String)
        name = value
    End Set
End Property

' Third example: 
' ComponentLookupKey is a constant assigned to the content component.
' LocalizedString uses the current culture to identify which file 
' to open andlookup ComponentLookupKey. It returns the string 
' assigned in that file to ComponentLookupKey.

Public Property Name() As String
    Get
         Return LocalizedString(ComponentLookupKey, CultureInfo.CurrentCulture)
    End Get
    Set(ByVal value As String)
    End Set
End Property

請參閱

參照

IBackupRestore interface

IBackupRestore members

Microsoft.SharePoint.Administration.Backup namespace