本文整理汇总了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;
}
示例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;
}
示例4: TemplateCompilationException
internal TemplateCompilationException(CompilerErrorCollection errorCollection)
: base(GetMessage(errorCollection))
{
_errors = new ReadOnlyCollection<CompilerError>(errorCollection.Cast<CompilerError>().ToArray());
}
示例5: ConfigurationCompilationException
public ConfigurationCompilationException(ConfigurationFileInfo configuration, CompilerErrorCollection compilationErrors)
: this(configuration, compilationErrors.Cast<CompilerError>())
{
}
示例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);
}
}
示例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);
}
示例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;
}