Proprietà IVSSUser.Name

Ottiene o imposta una stringa che rappresenta il nome dell'utente corrente del database di Visual SourceSafe.

Spazio dei nomi: Microsoft.VisualStudio.SourceSafe.Interop
Assembly: Microsoft.VisualStudio.SourceSafe.Interop (in microsoft.visualstudio.sourcesafe.interop.dll)

Sintassi

'Dichiarazione
Property Name As String
'Utilizzo
Dim instance As IVSSUser
Dim value As String

value = instance.Name

instance.Name = value
string Name { get; set; }
property String^ Name {
    String^ get ();
    void set ([InAttribute] String^ pName);
}
/** @property */
String get_Name ()

/** @property */
void set_Name (/** @attribute InAttribute() */ String pName)
function get Name () : String

function set Name (pName : String)

Valore proprietà

Una stringa che rappresenta il nome dell'utente corrente del database di Visual SourceSafe.

Note

[IDL]

HRESULT Name([out, retval] BSTR *pName);

HRESULT Name([in] BSTR Name);

Tutti gli utenti possono recuperare qualsiasi nome utente, ma solo l'utente Admin può impostare i nomi utente. Il nome Admin non può essere modificato. Se si tenta di modificarlo, verrà generato un errore di run-time. Se un utente diverso da Admin tenta di impostare il nome utente, verrà generato un errore di run-time.

Esempio

Nell'esempio riportato di seguito viene illustrato come utilizzare la proprietà Name per visualizzare il nome dell'utente corrente del database di Visual SourceSafe.

using System;
using Microsoft.VisualStudio.SourceSafe.Interop;

public class IVSSTest
{
    private static string GetUsername()
    {
        Console.Write("Enter Username: ");
        return Console.ReadLine();
    }

    private static string GetPassword()
    {
        Console.Write("Enter Password: ");
        return Console.ReadLine();
    }

    public static void Main()
    {
        // Create a VSSDatabase object.
        IVSSDatabase vssDatabase = new VSSDatabase();

        // Only SourceSafe Admin can access ProjectRights.
        Console.WriteLine("Admin login");
        vssDatabase.Open(@"C:\VSSTestDB\srcsafe.ini", 
                         GetUsername(), GetPassword());

        IVSSUser vssUser = vssDatabase.get_User("Guest");

        vssUser.set_ProjectRights("$/A", (int)VSSRights.VSSRIGHTS_READ);
        Console.WriteLine("Project Rights for user {0} for project $/A: {1}", 
                          vssUser.Name, 
                          (VSSRights)vssUser.get_ProjectRights("$/A"));

        vssUser.set_ProjectRights("$/A", (int)VSSRights.VSSRIGHTS_ALL);
        Console.WriteLine("Project Rights for user {0} for project $/A: {1}", 
                          vssUser.Name, 
                          (VSSRights)vssUser.get_ProjectRights("$/A"));
    }
}

Output:

Admin login

Enter Username:

Enter Password:

Project Rights for user Guest for project $/A: VSSRIGHTS_READ

Project Rights for user Guest for project $/A: VSSRIGHTS_ALL

Vedere anche

Riferimenti

Interfaccia IVSSUser
Membri IVSSUser
Spazio dei nomi Microsoft.VisualStudio.SourceSafe.Interop