Compiler.Type プロパティ
アセンブリ: System.Web (system.web.dll 内)



Windows 98, Windows 2000 SP4, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


CompilerType クラス
アセンブリ: System.Web (system.web.dll 内)


ビルド プロバイダの仮想パスからのソース コードの生成とコンパイルに使用する設定値を調べるには、BuildProvider 実装の CodeCompilerType プロパティを使用します。
BuildProvider オブジェクトは、ASP.NET ビルド環境でオブジェクトから独自のファイルの種類でソース コードを生成するために使用されます。BuildProvider の派生クラスでは、ソース ファイル、Web ページ、リソース、およびその他のカスタム アイテムに関するビルドの詳細を提供します。ビルド プロバイダで独自のプログラミング言語が必要な場合は、CodeCompilerType プロパティをオーバーライドし、GetDefaultCompilerType メソッドを呼び出して、そのプログラミング言語をサポートする CompilerType オブジェクトを返すようにします。
ビルド プロバイダの実装内で CompilerType オブジェクトを設定するには、GetDefaultCompilerType メソッドまたは GetDefaultCompilerTypeForLanguage メソッドを使用します。
CodeDomProviderType プロパティは、特定のビルド プロバイダに対するソース コードの生成とコンパイルに使用される CodeDomProvider の実装を指定します。CompilerParameters プロパティは、ソース コードをアセンブリにコンパイルするために使用する設定値を定義します。

簡単なビルド プロバイダを、抽象基本クラス BuildProvider から継承して実装するコード例を次に示します。ビルド プロバイダは、基本クラスのメンバである CodeCompilerType、GetGeneratedType、および GenerateCode をオーバーライドします。
Imports Microsoft.VisualBasic Imports System Imports System.Collections Imports System.IO Imports System.Text Imports System.Web Imports System.Web.Compilation Imports System.CodeDom.Compiler Imports System.CodeDom Imports System.Security Imports System.Security.Permissions <PermissionSet(SecurityAction.Demand, Unrestricted := true)> _ Public Class SampleBuildProvider Inherits BuildProvider Protected _compilerType As CompilerType = Nothing Public Sub New() _compilerType = GetDefaultCompilerType() End Sub ' Return the internal CompilerType member ' defined in this implementation. Public Overrides ReadOnly Property CodeCompilerType() As CompilerType Get CodeCompilerType = _compilerType End Get End Property ' Define a method that returns details for the ' code compiler for this build provider. Public Function GetCompilerTypeDetails() As String Dim details As StringBuilder = New StringBuilder("") If Not _compilerType Is Nothing Then ' Format a string that contains the code compiler ' implementation, and various compiler details. details.AppendFormat("CodeDomProvider type: {0}; ", _ _compilerType.CodeDomProviderType.ToString()) details.AppendFormat("Compiler debug build = {0}; ", _ _compilerType.CompilerParameters.IncludeDebugInformation.ToString()) details.AppendFormat("Compiler warning level = {0}; ", _ _compilerType.CompilerParameters.WarningLevel.ToString()) If Not _compilerType.CompilerParameters.CompilerOptions Is Nothing Then details.AppendFormat("Compiler options: {0}; ", _ _compilerType.CompilerParameters.CompilerOptions.ToString()) End If End If Return details.ToString() End Function ' Define the build provider implementation of the GenerateCode method. Public Overrides Sub GenerateCode(ByVal assemBuilder As AssemblyBuilder) ' Generate a code compile unit, and add it to ' the assembly builder. Dim tw As TextWriter = assemBuilder.CreateCodeFile(Me) If Not tw Is Nothing Then Try ' Generate the code compile unit from the virtual path. Dim compileUnit As CodeCompileUnit = _ SampleClassGenerator.BuildCompileUnitFromPath(VirtualPath) ' Generate the source for the code compile unit, ' and write it to a file specified by the assembly builder. Dim provider As CodeDomProvider = assemBuilder.CodeDomProvider provider.CreateGenerator().GenerateCodeFromCompileUnit(compileUnit, tw, Nothing) Finally tw.Close() End Try End If End Sub Public Overrides Function GetGeneratedType(ByVal results As CompilerResults) As System.Type Dim typeName As String = SampleClassGenerator.TypeName Return results.CompiledAssembly.GetType(typeName) End Function End Class
using System; using System.Collections; using System.IO; using System.Text; using System.Web; using System.Web.Compilation; using System.CodeDom.Compiler; using System.CodeDom; using System.Security; using System.Security.Permissions; // Define a simple build provider implementation. [PermissionSet(SecurityAction.Demand, Unrestricted = true)] public class SampleBuildProvider : BuildProvider { // Define an internal member for the compiler type. protected CompilerType _compilerType = null; public SampleBuildProvider() { // Set the compiler to use Visual Basic. _compilerType = GetDefaultCompilerTypeForLanguage("C#"); } // Return the internal CompilerType member // defined in this implementation. public override CompilerType CodeCompilerType { get { return _compilerType; } } // Define a method that returns details for the // code compiler for this build provider. public string GetCompilerTypeDetails() { StringBuilder details = new StringBuilder(""); if (_compilerType != null) { // Format a string that contains the code compiler // implementation, and various compiler details. details.AppendFormat("CodeDomProvider type: {0}; \n", _compilerType.CodeDomProviderType.ToString()); details.AppendFormat("Compiler debug build = {0}; \n", _compilerType.CompilerParameters.IncludeDebugInformation.ToString()); details.AppendFormat("Compiler warning level = {0}; \n", _compilerType.CompilerParameters.WarningLevel.ToString()); if (_compilerType.CompilerParameters.CompilerOptions != null) { details.AppendFormat("Compiler options: {0}; \n", _compilerType.CompilerParameters.CompilerOptions.ToString()); } } return details.ToString(); } // Define the build provider implementation of the GenerateCode method. public override void GenerateCode(AssemblyBuilder assemBuilder) { // Generate a code compile unit, and add it to // the assembly builder. TextWriter tw = assemBuilder.CreateCodeFile(this); if (tw != null) { try { // Generate the code compile unit from the virtual path. CodeCompileUnit compileUnit = SampleClassGenerator.BuildCompileUnitFromPath(VirtualPath); // Generate the source for the code compile unit, // and write it to a file specified by the assembly builder. CodeDomProvider provider = assemBuilder.CodeDomProvider; provider.CreateGenerator().GenerateCodeFromCompileUnit(compileUnit, tw, null); } finally { tw.Close(); } } } public override System.Type GetGeneratedType(CompilerResults results) { string typeName = SampleClassGenerator.TypeName; return results.CompiledAssembly.GetType(typeName); } }

System.Web.Compilation.CompilerType


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


CompilerType プロパティ

名前 | 説明 | |
---|---|---|
![]() | CodeDomProviderType | 構成済みの CodeDomProvider 実装に対する Type を取得します。 |
![]() | CompilerParameters | ソース コードをアセンブリにコンパイルするために使用する設定とオプションを取得します。 |

CompilerType メソッド

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 オーバーライドされます。 |
![]() | GetHashCode | オーバーライドされます。 このインスタンスのハッシュ コードを返します。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |

CompilerType メンバ
仮想パスからソース コードの生成とコンパイルを行うために ASP.NET ビルド環境で使用するコンパイラ設定を表します。このクラスは継承できません。
CompilerType データ型で公開されるメンバを以下の表に示します。

名前 | 説明 | |
---|---|---|
![]() | CodeDomProviderType | 構成済みの CodeDomProvider 実装に対する Type を取得します。 |
![]() | CompilerParameters | ソース コードをアセンブリにコンパイルするために使用する設定とオプションを取得します。 |

名前 | 説明 | |
---|---|---|
![]() | Equals | オーバーロードされます。 オーバーライドされます。 |
![]() | GetHashCode | オーバーライドされます。 このインスタンスのハッシュ コードを返します。 |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |

- Compiler.Typeのページへのリンク