CodeProperty.Getter 屬性
設定或取得用來定義程式碼以傳回某一屬性的物件。
命名空間: EnvDTE
組件: EnvDTE (在 EnvDTE.dll 中)
語法
'宣告
Property Getter As CodeFunction
CodeFunction Getter { get; set; }
property CodeFunction^ Getter {
CodeFunction^ get ();
void set (CodeFunction^ value);
}
abstract Getter : CodeFunction with get, set
function get Getter () : CodeFunction
function set Getter (value : CodeFunction)
屬性值
型別:EnvDTE.CodeFunction
CodeFunction 物件。
備註
如果有程式碼函式的話,Getter 會傳回它,也就是這項屬性的 getter。
注意事項 |
---|
這個屬性對於 Visual Basic 原始程式碼的程式碼項目而言是唯讀性質。 另外像是類別、建構、函式、屬性 (Attribute)、委派 (Delegate) 等這些程式碼模型元素的值,在經過特定方式的編輯之後也可以為非決定性,即表示這些值將不再固定。如需詳細資訊,請參閱使用程式碼模型探索程式碼 (Visual Basic) 的<程式碼模型項目值可以變更>一節。 |
範例
Sub GetterExample(ByVal dte As DTE2)
' Before running this example, open a code document from a project
' and place the insertion point inside a property definition.
Try
' Retrieve the CodeProperty at the insertion point.
Dim sel As TextSelection = _
CType(dte.ActiveDocument.Selection, TextSelection)
Dim prop As CodeProperty = _
CType(sel.ActivePoint.CodeElement( _
vsCMElement.vsCMElementProperty), CodeProperty)
' Display the source code for the property getter.
Dim gttr As CodeFunction = prop.Getter
Dim start As TextPoint = gttr.GetStartPoint()
Dim finish As TextPoint = gttr.GetEndPoint()
Dim src As String = start.CreateEditPoint().GetText(finish)
MsgBox(prop.Name & "'s getter source code:" & vbCrLf & _
vbCrLf & src)
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
public void GetterExample(DTE2 dte)
{
// Before running this example, open a code document from a project
// and place the insertion point inside a property definition.
try
{
// Retrieve the CodeProperty at the insertion point.
TextSelection sel =
(TextSelection)dte.ActiveDocument.Selection;
CodeProperty prop =
(CodeProperty)sel.ActivePoint.get_CodeElement(
vsCMElement.vsCMElementProperty);
// Display the source code for the property getter.
CodeFunction getter = prop.Getter;
TextPoint start = getter.GetStartPoint(vsCMPart.vsCMPartWhole);
TextPoint finish = getter.GetEndPoint(vsCMPart.vsCMPartWhole);
string src = start.CreateEditPoint().GetText(finish);
MessageBox.Show(prop.Name + "'s getter source code:\n\n" +
src);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
.NET Framework 安全性
- 完全信任立即呼叫者。這個成員無法供部分信任的程式碼使用。如需詳細資訊,請參閱從部分受信任程式碼使用程式庫。