CodeClass2.DataTypeKind 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
设置或获取此类与其他类之间的关系。
public:
property EnvDTE80::vsCMDataTypeKind DataTypeKind { EnvDTE80::vsCMDataTypeKind get(); void set(EnvDTE80::vsCMDataTypeKind value); };
public:
property EnvDTE80::vsCMDataTypeKind DataTypeKind { EnvDTE80::vsCMDataTypeKind get(); void set(EnvDTE80::vsCMDataTypeKind value); };
[System.Runtime.InteropServices.DispId(205)]
public EnvDTE80.vsCMDataTypeKind DataTypeKind { [System.Runtime.InteropServices.DispId(205)] get; [System.Runtime.InteropServices.DispId(205)] set; }
[<System.Runtime.InteropServices.DispId(205)>]
[<get: System.Runtime.InteropServices.DispId(205)>]
[<set: System.Runtime.InteropServices.DispId(205)>]
member this.DataTypeKind : EnvDTE80.vsCMDataTypeKind with get, set
Public Property DataTypeKind As vsCMDataTypeKind
属性值
返回枚举中的值 vsCMDataTypeKind 。
- 属性
示例
[Visual Basic]
Sub DataTypeKindExample(ByVal dte As DTE2)
' Before running this example, open a code document from a project
' and place the insertion point inside a class definition.
Try
' Retrieve the CodeClass at the insertion point.
Dim sel As TextSelection = _
CType(dte.ActiveDocument.Selection, TextSelection)
Dim cls As CodeClass2 = _
CType(sel.ActivePoint.CodeElement( _
vsCMElement.vsCMElementClass), CodeClass2)
' Displays the data type kind of the class.
Select Case cls.DataTypeKind
Case vsCMDataTypeKind.vsCMDataTypeKindBlueprint
MsgBox("Class data type: Blueprint")
Case vsCMDataTypeKind.vsCMDataTypeKindMain
MsgBox("Class data type: Main")
Case vsCMDataTypeKind.vsCMDataTypeKindModule
MsgBox("Class data type: Module")
Case vsCMDataTypeKind.vsCMDataTypeKindPartial
MsgBox("Class data type: Partial")
End Select
Catch ex As System.Exception
MsgBox(ex.ToString)
End Try
End Sub
[C#]
public void DataTypeKindExample(DTE2 dte)
{
// Before running this example, open a code document from a project
// and place the insertion point inside a class definition.
try
{
// Retrieve the CodeClass at the insertion point.
TextSelection sel =
(TextSelection)dte.ActiveDocument.Selection;
CodeClass2 cls =
(CodeClass2)sel.ActivePoint.get_CodeElement
(vsCMElement.vsCMElementClass);
// Display the data type kind of the class.
MessageBox.Show("Class data type kind: " + cls.DataTypeKind);
}
catch (System.Exception ex)
{
MessageBox.Show(ex.Message);
}
}
注解
例如,如果这是分部的主类,则此调用将返回 vsCMDataTypeKindMain 。 如果它是分部类,则返回 vsCMDataTypeKindPartial 。
备注
在进行了某些类型的编辑之后,代码模型元素(例如类、结构、函数、特性、委托等)的值可能变为非确定性的,这意味着不能确定它们的值始终保持不变。 有关详细信息,请参阅 "代码模型元素值在 使用代码模型查找代码时 可能发生变化" (Visual Basic) "。