CodeModel2.Language 属性
获取用于创作代码的编程语言。
命名空间: EnvDTE80
程序集: EnvDTE80(在 EnvDTE80.dll 中)
语法
声明
ReadOnly Property Language As String
string Language { get; }
property String^ Language {
String^ get ();
}
abstract Language : string with get
function get Language () : String
属性值
类型:String
一个 CodeModelLanguageConstants 常数。
示例
Sub LanguageExample(ByVal dte As DTE2)
' Before running this example, open a solution that contains
' one or more projects.
Dim langs As String
Dim proj As Project
For Each proj In dte.Solution
Try
Dim cm As CodeModel = proj.CodeModel
langs &= proj.Name & "'s language is "
Select Case cm.Language
Case CodeModelLanguageConstants.vsCMLanguageMC, _
CodeModelLanguageConstants.vsCMLanguageVC
langs &= "C++" & vbCrLf
Case CodeModelLanguageConstants.vsCMLanguageCSharp
langs &= "C#" & vbCrLf
Case CodeModelLanguageConstants.vsCMLanguageVB
langs &= "Visual Basic" & vbCrLf
Case "{E6FDF8BF-F3D1-11D4-8576-0002A516ECE8}"
langs &= "J#" & vbCrLf
End Select
Catch
End Try
Next
MsgBox(langs)
End Sub
public void LanguageExample(DTE2 dte)
{
// Before running this example, open a solution that contains one
// or more projects.
string langs = "";
foreach (Project proj in dte.Solution)
{
try
{
CodeModel cm = proj.CodeModel;
langs += proj.Name + "'s language is ";
switch (cm.Language)
{
case CodeModelLanguageConstants.vsCMLanguageMC:
case CodeModelLanguageConstants.vsCMLanguageVC:
langs += "C++" + Environment.NewLine;
break;
case CodeModelLanguageConstants.vsCMLanguageCSharp:
langs += "C#" + Environment.NewLine;
break;
case CodeModelLanguageConstants.vsCMLanguageVB:
langs += "Visual Basic" + Environment.NewLine;
break;
case "{E6FDF8BF-F3D1-11D4-8576-0002A516ECE8}":
langs += "J#" + Environment.NewLine;
break;
}
}
catch
{
}
}
MessageBox.Show(langs);
}
.NET Framework 安全性
- 对直接调用方的完全信任。此成员不能由部分信任的代码使用。有关详细信息,请参阅通过部分受信任的代码使用库。