CodeDomProvider.GetAllCompilerInfo 方法

定義

傳回這部電腦的語言提供者和編譯器組態設定。Returns the language provider and compiler configuration settings for this computer.

public:
 static cli::array <System::CodeDom::Compiler::CompilerInfo ^> ^ GetAllCompilerInfo();
[System.Runtime.InteropServices.ComVisible(false)]
public static System.CodeDom.Compiler.CompilerInfo[] GetAllCompilerInfo ();
static member GetAllCompilerInfo : unit -> System.CodeDom.Compiler.CompilerInfo[]
Public Shared Function GetAllCompilerInfo () As CompilerInfo()

傳回

CompilerInfo 型別的陣列,表示所有已設定 CodeDomProvider 實作的設定。An array of type CompilerInfo representing the settings of all configured CodeDomProvider implementations.

屬性

例外狀況

呼叫端沒有必要的使用權限。The caller does not have the required permission.

範例

下列程式碼範例會列舉電腦上的語言提供者, 並顯示每個語言提供者的設定和編譯器設定。The following code example enumerates the language providers on the computer and displays the configuration and compiler settings for each language provider. 這個程式碼範例是針對CompilerInfo類別提供之較大範例的一部分。This code example is part of a larger example provided for the CompilerInfo class.

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

備註

GetAllCompilerInfo使用方法來列舉電腦上的語言提供者設定。Use the GetAllCompilerInfo method to enumerate the language provider settings on a computer.

注意

在中 < > ,.NET Framework 提供的預設語言提供者不會在 system.string 元素編譯器設定區段中指定,因此這個方法會傳回.NET Framework 2.0.NET Framework 2.0設定檔中的預設提供者和任何指定的相關資訊。In the .NET Framework 2.0.NET Framework 2.0, the default language providers supplied by the .NET Framework are not specified in the <system.codedom> Element compiler configuration section and cannot be removed, so this method returns information about the default providers and any specified in the configuration file.

安全性

LinkDemand
針對立即呼叫者的完全信任的。for full trust for the immediate caller. 這個成員無法供部分信任的程式碼使用。This member cannot be used by partially trusted code.

適用於

另請參閱