BuildProvider.CodeCompilerType プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > BuildProvider.CodeCompilerType プロパティの意味・解説 

BuildProvider.CodeCompilerType プロパティ

メモ : このプロパティは、.NET Framework version 2.0新しく追加されたものです。

ビルド プロバイダ独自のファイル種類ソース コード生成するために使用されるコンパイラ種類表します

名前空間: System.Web.Compilation
アセンブリ: System.Web (system.web.dll 内)
構文構文

Public Overridable ReadOnly
 Property CodeCompilerType As CompilerType
Dim instance As BuildProvider
Dim value As CompilerType

value = instance.CodeCompilerType
public virtual CompilerType CodeCompilerType { get;
 }
public:
virtual property CompilerType^ CodeCompilerType {
    CompilerType^ get ();
}
/** @property */
public CompilerType get_CodeCompilerType ()
public function get CodeCompilerType
 () : CompilerType

プロパティ
読み取り専用の System.Web.Compilation.CompilerType。仮想パスソース コードビルドするためのコード ジェネレータコード コンパイラ、およびコンパイラ設定値表します基本クラスでは、null 参照 (Visual Basic では Nothing) が返されます。

解説解説

特定の BuildProvider 実装対すソース コードコンパイル設定値指定するには、CodeCompilerType プロパティ使用しますビルド プロバイダソース コード生成コンパイルに独自のコード言語を必要としない場合CodeCompilerType プロパティnull 参照 (Visual Basic では Nothing) です。

ビルド プロバイダ実装内で 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 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.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()
    {
        _compilerType = GetDefaultCompilerTypeForLanguage("C#");
    }

    // Return the internal CompilerType member 
    // defined in this implementation.
    public override CompilerType CodeCompilerType
    {
        get { return _compilerType; }
    }


    // 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.GenerateCodeFromCompileUnit(compileUnit, tw, null);
            }
            finally
            {
                tw.Close();
            }
        }
    }

    public override System.Type GetGeneratedType(CompilerResults
 results)
    {
        string typeName = SampleClassGenerator.TypeName;

        return results.CompiledAssembly.GetType(typeName);
    }
}
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
BuildProvider クラス
BuildProvider メンバ
System.Web.Compilation 名前空間
CompilerType



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「BuildProvider.CodeCompilerType プロパティ」の関連用語

BuildProvider.CodeCompilerType プロパティのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



BuildProvider.CodeCompilerType プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2025 Microsoft.All rights reserved.

©2025 GRAS Group, Inc.RSS