当前位置: 首页>>代码示例>>C#>>正文


C# AssemblyBuilder.GetBuildProviderFromLinePragma方法代码示例

本文整理汇总了C#中System.Web.Compilation.AssemblyBuilder.GetBuildProviderFromLinePragma方法的典型用法代码示例。如果您正苦于以下问题:C# AssemblyBuilder.GetBuildProviderFromLinePragma方法的具体用法?C# AssemblyBuilder.GetBuildProviderFromLinePragma怎么用?C# AssemblyBuilder.GetBuildProviderFromLinePragma使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Web.Compilation.AssemblyBuilder的用法示例。


在下文中一共展示了AssemblyBuilder.GetBuildProviderFromLinePragma方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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);
             }
         }
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:WebDirectoryBatchCompiler.cs

示例2: 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);
        }

    }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:57,代码来源:BuildProvidersCompiler.cs


注:本文中的System.Web.Compilation.AssemblyBuilder.GetBuildProviderFromLinePragma方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。