編輯

共用方式為


CompilerInfo.CodeDomProviderType Property

Definition

Gets the type of the configured CodeDomProvider implementation.

public:
 property Type ^ CodeDomProviderType { Type ^ get(); };
public Type CodeDomProviderType { get; }
member this.CodeDomProviderType : Type
Public ReadOnly Property CodeDomProviderType As Type

Property Value

A read-only Type instance that represents the configured language provider type.

Exceptions

The language provider is not configured on this computer.

Cannot locate the type because it is a null or empty string.

-or-

Cannot locate the type because the name for the CodeDomProvider cannot be found in the configuration file.

Examples

The following code example determines whether the input language has a configured CodeDomProvider implementation on the computer. If there is a provider configured for the specified language, the example displays the language provider configuration settings. This code example is part of a larger example provided for the CompilerInfo class.

CodeDomProvider^ provider = nullptr;
CompilerInfo^ info = CodeDomProvider::GetCompilerInfo( configLanguage );

// Check whether there is a provider configured for this language.
if ( info->IsCodeDomProviderTypeValid )
{
   // Get a provider instance using the configured type information.
   provider = dynamic_cast<CodeDomProvider^>(Activator::CreateInstance( info->CodeDomProviderType ));
   if ( provider )
   {
      // Display information about this language provider.
      Console::WriteLine( "Language provider:  {0}", provider->ToString() );
      Console::WriteLine();
      Console::WriteLine( "  Default file extension:  {0}", provider->FileExtension );
      Console::WriteLine();
      
      // Get the compiler settings for this language.
      CompilerParameters^ langCompilerConfig = info->CreateDefaultCompilerParameters();
      if ( langCompilerConfig )
      {
         Console::WriteLine( "  Compiler options:        {0}", langCompilerConfig->CompilerOptions );
         Console::WriteLine( "  Compiler warning level:  {0}", langCompilerConfig->WarningLevel.ToString() );
      }
   }
}

if ( provider == nullptr ) // Tell the user that the language provider was not found.
   Console::WriteLine( "There is no provider configured for input language \"{0}\".", configLanguage );
CompilerInfo info = CodeDomProvider.GetCompilerInfo(configLanguage);

// Check whether there is a provider configured for this language.
if (info.IsCodeDomProviderTypeValid)
{
    // Get a provider instance using the configured type information.
    CodeDomProvider provider;
    provider = (CodeDomProvider)Activator.CreateInstance(info.CodeDomProviderType);

    // Display information about this language provider.
    Console.WriteLine("Language provider:  {0}",
        provider.ToString());
    Console.WriteLine();
    Console.WriteLine("  Default file extension:  {0}",
        provider.FileExtension);
    Console.WriteLine();

    // Get the compiler settings for this language.

    CompilerParameters langCompilerConfig = info.CreateDefaultCompilerParameters();

    Console.WriteLine("  Compiler options:        {0}",
        langCompilerConfig.CompilerOptions);
    Console.WriteLine("  Compiler warning level:  {0}",
        langCompilerConfig.WarningLevel);
}
else
{
    // Tell the user that the language provider was not found.
    Console.WriteLine("There is no provider configured for input language \"{0}\".",
        configLanguage);
}
Dim info As CompilerInfo = CodeDomProvider.GetCompilerInfo(configLanguage)

' Check whether there is a provider configured for this language.
If info.IsCodeDomProviderTypeValid Then
   ' Get a provider instance using the configured type information.
   Dim provider As CodeDomProvider
   provider = CType(Activator.CreateInstance(info.CodeDomProviderType), CodeDomProvider)
   
   ' Display information about this language provider.
   Console.WriteLine("Language provider:  {0}", _
       provider.ToString())
   Console.WriteLine()
   Console.WriteLine("  Default file extension:  {0}", _
       provider.FileExtension)
   Console.WriteLine()
   
   ' Get the compiler settings for this language.
   Dim langCompilerConfig As CompilerParameters = info.CreateDefaultCompilerParameters()
   
   Console.WriteLine("  Compiler options:        {0}", _
       langCompilerConfig.CompilerOptions)
   Console.WriteLine("  Compiler warning level:  {0}", _
       langCompilerConfig.WarningLevel)
Else
   ' Tell the user that the language provider was not found.
   Console.WriteLine("There is no provider configured for input language ""{0}"".", configLanguage)
End If

Remarks

The machine configuration file contains the fully qualified type name for each CodeDomProvider implementation on the computer. The CodeDomProviderType property value is a Type instance that represents a configured language provider implementation.

Applies to

See also