Aracılığıyla paylaş


CodeVariable.Access Özellik

Bu öğe için erişim değiştiricisi tanımlar.

Ad alanı:  EnvDTE
Derleme:  EnvDTE (EnvDTE.dll içinde)

Sözdizimi

'Bildirim
Property Access As vsCMAccess
vsCMAccess Access { get; set; }
property vsCMAccess Access {
    vsCMAccess get ();
    void set (vsCMAccess value);
}
abstract Access : vsCMAccess with get, set
function get Access () : vsCMAccess 
function set Access (value : vsCMAccess)

Özellik Değeri

Tür: EnvDTE.vsCMAccess
A vsCMAccess value.

Notlar

Accessgerçek erişim ve diğer kod bu kod öğenin nasıl erişebilir döndürür.

[!NOT]

Bu özellik, salt okunur için Visual Basic kaynak kodu kodu öğelerden.

Ayrıca, sınıflar, yapılar, İşlevler, öznitelikleri, Temsilciler ve diğerleri gibi kod modeli öğelerinin değerleri düzenlemeleri değerlerine bağlı her zaman aynı kalacak şekilde dayanıyordu olamaz, diğer bir deyişle, belirli türde yaptıktan sonra non-deterministik olabilir.Daha fazla bilgi için kod modeli öğe değerlerini de değiştirebilirsiniz bölümüne bakın Kod Modeli Kullanarak Kodu Keşfetme (Visual Basic).

Örnekler

Sub AccessExample(ByVal dte As DTE2)

    ' Before running this example, open a code document from a project
    ' and place the insertion point inside a variable definition.
    Try
        ' Retrieve the CodeVariable at the insertion point.
        Dim sel As TextSelection = _
            CType(dte.ActiveDocument.Selection, TextSelection)
        Dim var As CodeVariable = _
            CType(sel.ActivePoint.CodeElement( _
            vsCMElement.vsCMElementVariable), CodeVariable)

        ' Display the CodeVariable's accessibility.
        Dim access As String
        Dim varAccess As vsCMAccess = var.Access
        Dim val As vsCMAccess
        For Each val In [Enum].GetValues(varAccess.GetType())
            If (val And varAccess) <> 0 Then
                access &= val.ToString() & vbCrLf
            End If
        Next

        MsgBox(var.Name & " has the following accessibility:" & _
            vbCrLf & vbCrLf & access)
    Catch ex As Exception
        MsgBox(ex.Message)
    End Try

End Sub
public void AccessExample(DTE2 dte)
{
    // Before running this example, open a code document from a project
    // and place the insertion point inside a variable definition.
    try
    {
        // Retrieve the CodeVariable at the insertion point.
        TextSelection sel = 
            (TextSelection)dte.ActiveDocument.Selection;
        CodeVariable var = 
            (CodeVariable)sel.ActivePoint.get_CodeElement(
            vsCMElement.vsCMElementVariable);

        // Display the CodeVariable's accessibility.
        string access = "";
        vsCMAccess varAccess = var.Access;

        foreach (vsCMAccess val in Enum.GetValues(varAccess.GetType()))
        {
            if ((val & varAccess) != 0)
                access += val.ToString() + "\r\n";
        }

        MessageBox.Show(var.Name + 
            " has the following accessibility:\r\n\r\n" + access);
    }
    catch (Exception ex)
    {
        MessageBox.Show(ex.Message);
    }
}

.NET Framework Güvenliği

Ayrıca bkz.

Başvuru

CodeVariable Arabirim

EnvDTE Ad Alanı

Diğer Kaynaklar

Nasıl yapılır: Otomasyon Nesne Modeli Kod Örnekleri Derleme ve Çalıştırma

Kod Modeli Kullanarak Kodu Keşfetme (Visual Basic)

Kod Modeli Kullanarak Kodu Keşfetme (Visual C#)