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


C# CompilerErrorCollection.Cast方法代码示例

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


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

示例1: TemplateCompilationException

 /// <summary>
 /// Initialises a new instance of <see cref="TemplateCompilationException"/>.
 /// </summary>
 /// <param name="errors">The set of compiler errors.</param>
 /// <param name="sourceCode">The source code that wasn't compiled.</param>
 /// <param name="template">The source template that wasn't compiled.</param>
 internal TemplateCompilationException(CompilerErrorCollection errors, string sourceCode, string template)
     : base("Unable to compile template. " + errors[0].ErrorText + "\n\nOther compilation errors may have occurred. Check the Errors property for more information.")
 {
     var list = errors.Cast<CompilerError>().ToList();
     Errors = new ReadOnlyCollection<CompilerError>(list);
     SourceCode = sourceCode;
     Template = template;
 }
开发者ID:JodenSoft,项目名称:JodenSoft,代码行数:14,代码来源:TemplateCompilationException.cs

示例2: TemplateCompilationException

 /// <summary>
 /// Initialises a new instance of <see cref="TemplateCompilationException"/>
 /// </summary>
 /// <param name="errors">The collection of compilation errors.</param>
 public TemplateCompilationException(CompilerErrorCollection errors)
     : base("Unable to compile template. Check the Errors list for details.")
 {
     var list = errors.Cast<CompilerError>().ToList();
     Errors = new ReadOnlyCollection<CompilerError>(list);
 }
开发者ID:grammarware,项目名称:fodder,代码行数:10,代码来源:src_ServiceStack_Razor_Templating_TemplateCompilationException.cs

示例3: CreateBindingExpressionCompilationErrors

        /// <summary>
        /// Converts a <see cref="CompilerErrorCollection"/> to a collection of <see cref="BindingExpressionCompilationError"/> objects.
        /// </summary>
        /// <param name="state">The expression compiler's current state.</param>
        /// <param name="models">The list of models which were compiled.</param>
        /// <param name="errors">The collection of errors produced during compilation.</param>
        /// <returns>A list containing the converted errors.</returns>
        private static List<BindingExpressionCompilationError> CreateBindingExpressionCompilationErrors(ExpressionCompilerState state,
            IEnumerable<DataSourceWrapperInfo> models, CompilerErrorCollection errors)
        {
            var result = new List<BindingExpressionCompilationError>();

            var workingDirectory = GetWorkingDirectory(state);

            var errorsByFile = errors.Cast<CompilerError>()
                .Where(x => !x.IsWarning).GroupBy(x => Path.GetFileName(x.FileName)).ToDictionary(x => x.Key, x => x.ToList());

            foreach (var model in models)
            {
                var dataSourceWrapperFilename = Path.GetFileName(GetWorkingFileForDataSourceWrapper(model));
                var dataSourceErrors = default(List<CompilerError>);
                if (errorsByFile.TryGetValue(dataSourceWrapperFilename, out dataSourceErrors))
                {
                    foreach (var dataSourceError in dataSourceErrors)
                    {
                        var fullPathToFile = model.DataSourceWrapperName;
                        if (state.WriteErrorsToFile)
                        {
                            fullPathToFile = Path.GetFullPath(Path.Combine(workingDirectory, 
                                Path.ChangeExtension(model.DataSourceWrapperName, "cs")));
                        }

                        result.Add(new BindingExpressionCompilationError(fullPathToFile,
                            dataSourceError.Line, dataSourceError.Column, dataSourceError.ErrorNumber, dataSourceError.ErrorText));
                    }
                }
            }

            return result;
        }
开发者ID:prshreshtha,项目名称:ultraviolet,代码行数:40,代码来源:ExpressionCompiler.cs

示例4: TemplateCompilationException

 internal TemplateCompilationException(CompilerErrorCollection errorCollection)
     : base(GetMessage(errorCollection))
 {
     _errors = new ReadOnlyCollection<CompilerError>(errorCollection.Cast<CompilerError>().ToArray());
 }
开发者ID:nathan-alden,项目名称:junior-route,代码行数:5,代码来源:TemplateCompilationException.cs

示例5: ConfigurationCompilationException

 public ConfigurationCompilationException(ConfigurationFileInfo configuration, CompilerErrorCollection compilationErrors)
     : this(configuration, compilationErrors.Cast<CompilerError>())
 {
 }
开发者ID:naraga,项目名称:Configizer,代码行数:4,代码来源:ConfigurationCompilationException.cs

示例6: AssertSingleError

 private static void AssertSingleError(CompilerErrorCollection errors, params string[] keywords)
 {
     var error = errors.Cast<CompilerError>().Single();
     foreach (string keyword in keywords)
     {
         StringAssert.Contains(error.ErrorText, keyword);
     }
 }
开发者ID:icool123,项目名称:T4Toolbox,代码行数:8,代码来源:TemplateTest.cs

示例7: TemplateException

 /// <summary>
 /// Initialises a new instance of <see cref="TemplateException"/>
 /// </summary>
 /// <param name="errors">The collection of compilation errors.</param>
 internal TemplateException(CompilerErrorCollection errors)
     : base("Unable to compile template.")
 {
     var list = errors.Cast<CompilerError>().ToList();
     Errors = new ReadOnlyCollection<CompilerError>(list);
 }
开发者ID:tqc,项目名称:RazorEngine,代码行数:10,代码来源:TemplateException.cs

示例8: FormatMessage

 private static string FormatMessage(CompilerErrorCollection errors)
 {
     var message = "One or more template processing errors occurred: " + Environment.NewLine;
     message += string.Join(Environment.NewLine, errors.Cast<CompilerError>().Select(x => x.ToString()));
     return message;
 }
开发者ID:tikrimi,项目名称:MvcScaffolding4TwitterBootstrapMvc,代码行数:6,代码来源:TemplatingTest.cs


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