CodeClass2.Access 屬性
設定或取得這個程式碼類別的存取屬性。
命名空間: EnvDTE80
組件: EnvDTE80 (在 EnvDTE80.dll 中)
語法
'宣告
Property Access As vsCMAccess
Get
Set
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)
屬性值
型別:EnvDTE.vsCMAccess
vsCMAccess 值。
實作
備註
Access 屬性會傳回常數,指出實際的存取以及其他程式碼存取這個程式碼類別的方式。
注意事項 |
---|
在特定類型的編輯之後,程式碼模型項目 (例如類別、結構、函式、屬性、委派等) 的值可能不具決定性,表示其值不一定維持相同。 如需詳細資訊,請參閱使用程式碼模型探索程式碼 (Visual Basic) 的<程式碼模型項目值可以變更>一節。 |
範例
[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
[C#]
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 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。