CompilerInfo.CreateProvider Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Returns a CodeDomProvider instance for the current language provider settings.
Overloads
CreateProvider() |
Returns a CodeDomProvider instance for the current language provider settings. |
CreateProvider(IDictionary<String,String>) |
Returns a CodeDomProvider instance for the current language provider settings and specified options. |
CreateProvider()
- Source:
- CompilerInfo.cs
- Source:
- CompilerInfo.cs
Returns a CodeDomProvider instance for the current language provider settings.
public:
System::CodeDom::Compiler::CodeDomProvider ^ CreateProvider();
public System.CodeDom.Compiler.CodeDomProvider CreateProvider ();
member this.CreateProvider : unit -> System.CodeDom.Compiler.CodeDomProvider
Public Function CreateProvider () As CodeDomProvider
Returns
A CodeDOM provider associated with the language provider configuration.
Examples
The following code example enumerates the language providers on the computer and displays the configuration and compiler settings for each language provider. 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
Remarks
The CreateProvider method returns a CodeDomProvider instance for the current language provider settings.
Use the CreateProvider method to get a CodeDomProvider implementation for a CompilerInfo instance returned by the CodeDomProvider.GetAllCompilerInfo or CodeDomProvider.GetCompilerInfo method.
See also
Applies to
CreateProvider(IDictionary<String,String>)
- Source:
- CompilerInfo.cs
- Source:
- CompilerInfo.cs
Returns a CodeDomProvider instance for the current language provider settings and specified options.
public:
System::CodeDom::Compiler::CodeDomProvider ^ CreateProvider(System::Collections::Generic::IDictionary<System::String ^, System::String ^> ^ providerOptions);
public System.CodeDom.Compiler.CodeDomProvider CreateProvider (System.Collections.Generic.IDictionary<string,string> providerOptions);
member this.CreateProvider : System.Collections.Generic.IDictionary<string, string> -> System.CodeDom.Compiler.CodeDomProvider
Public Function CreateProvider (providerOptions As IDictionary(Of String, String)) As CodeDomProvider
Parameters
- providerOptions
- IDictionary<String,String>
A collection of provider options from the configuration file.
Returns
A CodeDOM provider associated with the language provider configuration and specified options.
Exceptions
providerOptions
is null
.
The provider does not support options.
Remarks
The CreateProvider(IDictionary<String,String>) method returns a CodeDomProvider instance for the current language provider settings and the specified provider options. For information about supported provider options, see the specific CodeDOM provider documentation.
Use the CreateProvider(IDictionary<String,String>) method to get a CodeDomProvider implementation for a CompilerInfo instance returned by the CodeDomProvider.GetAllCompilerInfo or CodeDomProvider.GetCompilerInfo method.