本文整理汇总了C#中System.Web.Compilation.AssemblyBuilder.GetGeneratedSourceFromBuildProvider方法的典型用法代码示例。如果您正苦于以下问题:C# AssemblyBuilder.GetGeneratedSourceFromBuildProvider方法的具体用法?C# AssemblyBuilder.GetGeneratedSourceFromBuildProvider怎么用?C# AssemblyBuilder.GetGeneratedSourceFromBuildProvider使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.Compilation.AssemblyBuilder
的用法示例。
在下文中一共展示了AssemblyBuilder.GetGeneratedSourceFromBuildProvider方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CacheCompileErrors
// Cache the various compile errors found during batching
private void CacheCompileErrors(AssemblyBuilder assemblyBuilder, CompilerResults results) {
BuildProvider previous = null;
// Go through all the compile errors
foreach (CompilerError error in results.Errors) {
// Skip warnings
if (error.IsWarning)
continue;
// Try to map the error back to a BuildProvider. If we can't, skip the error.
BuildProvider buildProvider = assemblyBuilder.GetBuildProviderFromLinePragma(error.FileName);
if (buildProvider == null)
continue;
// Only cache the error for template controls. Otherwise, for file types like
// asmx/ashx, it's too likely that two of them define the same class.
if (!(buildProvider is BaseTemplateBuildProvider))
continue;
// If the error is for the same page as the previous one, ignore it
if (buildProvider == previous)
continue;
previous = buildProvider;
// Create a new CompilerResults for this error
CompilerResults newResults = new CompilerResults(null /*tempFiles*/);
// Copy all the output to the new result. Note that this will include all the
// error lines, not just the ones for this BuildProvider. But that's not a big deal,
// and we can't easily filter the output here.
foreach (string s in results.Output)
newResults.Output.Add(s);
// Copy various other fields to the new CompilerResults object
newResults.PathToAssembly = results.PathToAssembly;
newResults.NativeCompilerReturnValue = results.NativeCompilerReturnValue;
// Add this error. It will be the only one in the CompilerResults object.
newResults.Errors.Add(error);
// Create a new HttpCompileException & BuildResultCompileError to wrap this error
HttpCompileException e = new HttpCompileException(newResults,
assemblyBuilder.GetGeneratedSourceFromBuildProvider(buildProvider));
BuildResult result = new BuildResultCompileError(buildProvider.VirtualPathObject, e);
// Add the dependencies to the compile error build provider, so that
// we will retry compilation when a dependency changes
buildProvider.SetBuildResultDependencies(result);
// Cache it
BuildManager.CacheVPathBuildResult(buildProvider.VirtualPathObject, result, _utcStart);
}
}
示例2: CacheCompileErrors
private void CacheCompileErrors(AssemblyBuilder assemblyBuilder, CompilerResults results)
{
System.Web.Compilation.BuildProvider provider = null;
foreach (CompilerError error in results.Errors)
{
if (!error.IsWarning)
{
System.Web.Compilation.BuildProvider buildProviderFromLinePragma = assemblyBuilder.GetBuildProviderFromLinePragma(error.FileName);
if (((buildProviderFromLinePragma != null) && (buildProviderFromLinePragma is BaseTemplateBuildProvider)) && (buildProviderFromLinePragma != provider))
{
provider = buildProviderFromLinePragma;
CompilerResults results2 = new CompilerResults(null);
foreach (string str in results.Output)
{
results2.Output.Add(str);
}
results2.PathToAssembly = results.PathToAssembly;
results2.NativeCompilerReturnValue = results.NativeCompilerReturnValue;
results2.Errors.Add(error);
HttpCompileException compileException = new HttpCompileException(results2, assemblyBuilder.GetGeneratedSourceFromBuildProvider(buildProviderFromLinePragma));
BuildResult result = new BuildResultCompileError(buildProviderFromLinePragma.VirtualPathObject, compileException);
buildProviderFromLinePragma.SetBuildResultDependencies(result);
BuildManager.CacheVPathBuildResult(buildProviderFromLinePragma.VirtualPathObject, result, this._utcStart);
}
}
}
}