CodeClass2.DataTypeKind 属性
获取或设置此类与其他类的关系。
命名空间: EnvDTE80
程序集: EnvDTE80(在 EnvDTE80.dll 中)
语法
声明
Property DataTypeKind As vsCMDataTypeKind
vsCMDataTypeKind DataTypeKind { get; set; }
property vsCMDataTypeKind DataTypeKind {
vsCMDataTypeKind get ();
void set (vsCMDataTypeKind value);
}
abstract DataTypeKind : vsCMDataTypeKind with get, set
function get DataTypeKind () : vsCMDataTypeKind
function set DataTypeKind (value : vsCMDataTypeKind)
属性值
类型:EnvDTE80.vsCMDataTypeKind
从 vsCMDataTypeKind 枚举返回值。
备注
例如,如果它是分部类的主类,则此调用返回 vsCMDataTypeKindMain。 如果它是分部类,则此调用返回 vsCMDataTypeKindPartial。
备注
在进行某些类型的编辑之后,代码模型元素(如类、结构、函数、特性、委托等)的值可能是非确定性的,这意味着不能指望它们的值总是保持不变。有关更多信息,请参见 使用代码模型查找代码 (Visual Basic) 中的“代码模型元素的值可能会更改”一节。
示例
[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);
}
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关详细信息,请参阅通过部分受信任的代码使用库。