CodeClass2.Access Özellik

Tanım

Bu kod sınıfının erişim özniteliklerini ayarlar veya alır.

public:
 property EnvDTE::vsCMAccess Access { EnvDTE::vsCMAccess get(); void set(EnvDTE::vsCMAccess value); };
public:
 property EnvDTE::vsCMAccess Access { EnvDTE::vsCMAccess get(); void set(EnvDTE::vsCMAccess value); };
[System.Runtime.InteropServices.DispId(35)]
public EnvDTE.vsCMAccess Access { [System.Runtime.InteropServices.DispId(35)] get; [System.Runtime.InteropServices.DispId(35)] set; }
[<System.Runtime.InteropServices.DispId(35)>]
[<get: System.Runtime.InteropServices.DispId(35)>]
[<set: System.Runtime.InteropServices.DispId(35)>]
member this.Access : EnvDTE.vsCMAccess with get, set
Public Property Access As vsCMAccess

Özellik Değeri

vsCMAccess

Bir vsCMAccess değer.

Uygulamalar

Öznitelikler

Örnekler

[Visual Basic]

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);  
    }  
}  

Açıklamalar

AccessÖzelliği, gerçek erişimi ve diğer kodun bu kod sınıfına nasıl erişebileceğini gösteren bir sabit döndürür.

Not

Sınıfların, yapıların, işlevlerin, özniteliklerin, temsilcilerin ve bu gibi kod modeli öğelerinin değerleri, belirli tür düzenlemeler yapıldıktan sonra belirleyici olmayan bir değer olabilir, yani değerlerinin her zaman aynı kalır. Daha fazla bilgi için bkz. kod modeli öğe değerleri, kod modeli kullanılarak kod bulma bölümünde değişebilir (Visual Basic).

Şunlara uygulanır