CodeDelegate2.Parent 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取 CodeDelegate2 对象的直接父对象。
public:
property System::Object ^ Parent { System::Object ^ get(); };
public:
property Platform::Object ^ Parent { Platform::Object ^ get(); };
[System.Runtime.InteropServices.DispId(31)]
public object Parent { [System.Runtime.InteropServices.DispId(31)] [System.Runtime.InteropServices.TypeLibFunc(1024)] get; }
[<System.Runtime.InteropServices.DispId(31)>]
[<get: System.Runtime.InteropServices.DispId(31)>]
[<get: System.Runtime.InteropServices.TypeLibFunc(1024)>]
member this.Parent : obj
Public ReadOnly Property Parent As Object
属性值
Parent属性将直接父级返回给 CodeDelegate2 对象。 若要获取包含集合,请使用 Collection 属性。
在进行了某些类型的编辑之后,代码模型元素(例如类、结构、函数、特性、委托等)的值可能变为非确定性的,这意味着不能确定它们的值始终保持不变。 有关详细信息,请参阅 "代码模型元素值在 使用代码模型查找代码时 可能发生变化" (Visual Basic) "。
实现
- 属性
示例
[C#]
public void Example(DTE2 dte)
{
// Before running this example, open a code document from a
// project and place the insertion point inside a delegate
// declaration.
try
{
TextSelection objTextSel;
CodeDelegate objCodeDel;
CodeElement objCodeElem;
objTextSel = (TextSelection)dte.ActiveDocument.Selection;
objCodeDel = (CodeDelegate)objTextSel.ActivePoint.get_CodeElement(vsCMElement.vsCMElementDelegate);
// Display the fullname of the CodeDelegate object.
MessageBox.Show(objCodeDel.FullName);
// Prove that the parent object of a CodeClass is a CodeElement.
objCodeElem = (CodeElement)objCodeDel.Parent;
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}