次の方法で共有


IBackupRestore.Name property

Gets or sets a name, for use in the SharePoint farm backup and restore UI, for the content component.

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

Syntax

'Declaration
Property Name As String
    Get
    Set
'Usage
Dim instance As IBackupRestore
Dim value As String

value = instance.Name

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

Property value

Type: System.String
A String that names the content component that is represented by the IBackupRestore object.

Remarks

If your class derives from SPPersistedObject, do not implement this member.

The Name property serves as the name of the content component in the UI of stsadm.exe, the UI of Central Administration application, the UI of a SharePoint Management Shell cmdlet, and the UI of any custom backup and restore application. In most cases, you implement the property by creating a private field for the name value and implement the public property as a wrapper around the field.

If the Name property might be read before it has been set, consider designing the get accessor to return the name of the type as a substitute. See the second example below.

If your component gets a name when it is installed and should never be renamed, consider storing localized versions of its name in a set of resource files. Design the get accessor for the property to read the component name from the appropriate file based on the current culture. The set accessor, in such an implementation, would have no code and there would be no private field. See the third example below.

Examples

The following code shows three ways to implement the Name property.

// 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

See also

Reference

IBackupRestore interface

IBackupRestore members

Microsoft.SharePoint.Administration.Backup namespace