カスタムの仮想パス プロバイダーとビルド プロバイダーを作成しましたが、asp.net に名前を付けさせるのではなく、生成されたアセンブリの名前を何らかの方法で指定できるかどうか疑問に思っていました。
1 に答える
0
私自身の質問に答えるために、少しの体操で可能です. AssemblyBuilder から CodeDomProvider への参照を取得でき、そこから何をしたいかはあなた次第です。このようなもの
public override void GenerateCode(AssemblyBuilder assemblyBuilder)
{
string outputName = VirtualPath.Substring(VirtualPath.LastIndexOf('/') + 1);
outputName = outputName.Substring(0, outputName.LastIndexOf('.'));
_compilationContext = (CompilationContext)HttpContext.Current.Items[outputName];
// var tw = assemblyBuilder.CreateCodeFile(this);
// tw.Write(_compilationContext.Content);
// tw.Flush();
// tw.Close();
//TODO: inject this
var factory = new DirectCompilerServiceFactory();
var compilerService = factory.CreateCompilerService(assemblyBuilder.CodeDomProvider);
compilerService.CompileAssembly(_compilationContext);
}
于 2011-03-01T19:15:48.490 に答える