Freigeben über


CompilerInfo.GetLanguages Methode

Definition

Ruft die vom Sprachanbieter unterstützten Sprachnamen ab.

public:
 cli::array <System::String ^> ^ GetLanguages();
public string[] GetLanguages ();
member this.GetLanguages : unit -> string[]
Public Function GetLanguages () As String()

Gibt zurück

String[]

Ein Array von vom Sprachanbieter unterstützten Sprachnamen.

Beispiele

Im folgenden Codebeispiel werden die Sprachanbieter auf dem Computer aufgelistet und die Konfigurations- und Compilereinstellungen für jeden Sprachanbieter angezeigt. Dieses Codebeispiel ist Teil eines größeren Beispiels, das für die CompilerInfo-Klasse bereitgestellt wird.

array<CompilerInfo^>^allCompilerInfo = CodeDomProvider::GetAllCompilerInfo();
for ( int i = 0; i < allCompilerInfo->Length; i++ )
{
   String^ defaultLanguage;
   String^ defaultExtension;
   CompilerInfo^ info = allCompilerInfo[ i ];
   CodeDomProvider^ provider = nullptr;
   if ( info )
      provider = info->CreateProvider();

   if ( provider )
   {
      // Display information about this configured provider.
      Console::WriteLine( "Language provider:  {0}", provider->ToString() );
      Console::WriteLine();
      Console::WriteLine( "  Supported file extension(s):" );
      array<String^>^extensions = info->GetExtensions();
      for ( int i = 0; i < extensions->Length; i++ )
          Console::WriteLine( "    {0}", extensions[ i ] );

      defaultExtension = provider->FileExtension;
      if (  !defaultExtension->StartsWith( "." ) )
          defaultExtension = String::Concat( ".", defaultExtension );

      Console::WriteLine( "  Default file extension:  {0}\n", defaultExtension );
      Console::WriteLine( "  Supported language(s):" );
      array<String^>^languages = info->GetLanguages();
      for ( int i = 0; i < languages->Length; i++ )
          Console::WriteLine( "    {0}", languages[ i ] );

      defaultLanguage = CodeDomProvider::GetLanguageFromExtension( defaultExtension );
      Console::WriteLine(  "  Default language:        {0}", defaultLanguage );
      Console::WriteLine();
      
      // Get the compiler settings for this provider.
      CompilerParameters^ langCompilerConfig = info->CreateDefaultCompilerParameters();
      if ( langCompilerConfig )
      {
         Console::WriteLine( "  Compiler options:        {0}", langCompilerConfig->CompilerOptions );
         Console::WriteLine( "  Compiler warning level:  {0}", langCompilerConfig->WarningLevel.ToString() );
      }
   }

}
CompilerInfo [] allCompilerInfo = CodeDomProvider.GetAllCompilerInfo();
foreach (CompilerInfo info in allCompilerInfo)
{
    String defaultLanguage;
    String defaultExtension;

    CodeDomProvider provider = info.CreateProvider();

    // Display information about this configured provider.

    Console.WriteLine("Language provider:  {0}",
        provider.ToString());
    Console.WriteLine();

    Console.WriteLine("  Supported file extension(s):");
    foreach(String extension in info.GetExtensions())
    {
        Console.WriteLine("    {0}", extension);
    }

    defaultExtension = provider.FileExtension;
    if (defaultExtension[0] != '.')
    {
        defaultExtension = "." + defaultExtension;
    }
    Console.WriteLine("  Default file extension:  {0}",
        defaultExtension);
    Console.WriteLine();

    Console.WriteLine("  Supported language(s):");
    foreach(String language in info.GetLanguages())
    {
        Console.WriteLine("    {0}", language);
    }

    defaultLanguage = CodeDomProvider.GetLanguageFromExtension(defaultExtension);
    Console.WriteLine("  Default language:        {0}",
        defaultLanguage);
    Console.WriteLine();

    // Get the compiler settings for this provider.
    CompilerParameters langCompilerConfig = info.CreateDefaultCompilerParameters();

    Console.WriteLine("  Compiler options:        {0}",
        langCompilerConfig.CompilerOptions);
    Console.WriteLine("  Compiler warning level:  {0}",
        langCompilerConfig.WarningLevel);
    Console.WriteLine();
}
        Dim allCompilerInfo As CompilerInfo() = CodeDomProvider.GetAllCompilerInfo()
        Dim info As CompilerInfo
        For Each info In  allCompilerInfo

           Dim defaultLanguage As String
           Dim defaultExtension As String

           Dim provider As CodeDomProvider = info.CreateProvider()
           
           ' Display information about this configured provider.
           Console.WriteLine("Language provider:  {0}", _
               provider.ToString())
           Console.WriteLine()
           
           Console.WriteLine("  Supported file extension(s):")
           Dim extension As String
           For Each extension In info.GetExtensions()
              Console.WriteLine("    {0}", extension)
           Next extension
           
           defaultExtension = provider.FileExtension
           If Not defaultExtension.StartsWith(".") Then
              defaultExtension = "." + defaultExtension
           End If

           Console.WriteLine("  Default file extension:  {0}", _
             defaultExtension)
           Console.WriteLine()
           
           Console.WriteLine("  Supported language(s):")
           Dim language As String
           For Each language In  info.GetLanguages()
              Console.WriteLine("    {0}", language)
           Next language
           defaultLanguage = CodeDomProvider.GetLanguageFromExtension(defaultExtension)
           Console.WriteLine("  Default language:        {0}", _
              defaultLanguage)
           Console.WriteLine()
           
           ' Get the compiler settings for this provider.
           Dim langCompilerConfig As CompilerParameters = info.CreateDefaultCompilerParameters()
           
           Console.WriteLine("  Compiler options:        {0}", _
               langCompilerConfig.CompilerOptions)
           Console.WriteLine("  Compiler warning level:  {0}", _
               langCompilerConfig.WarningLevel)
           Console.WriteLine()
        Next info

Hinweise

Das <system.codedom-Element> in der Computerkonfigurationsdatei enthält die Konfigurationseinstellungen des Sprachanbieters und des Compilers für jede CodeDomProvider Implementierung auf dem Computer. Jeder konfigurierte Sprachanbieter unterstützt mindestens einen Sprachnamen. Beispielsweise kann das CompilerInfo Objekt für ein Microsoft.CSharp.CSharpCodeProvider ein Array mit den Sprachnamen "c#", "cs" und "csharp" zurückgeben.

Gilt für:

Weitere Informationen