1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System.Text;
using System.Web.Razor.Utils;
namespace System.Web.Razor.Test.Framework
{
public class ErrorCollector
{
private StringBuilder _message = new StringBuilder();
private int _indent = 0;
public bool Success { get; private set; }
public string Message
{
get { return _message.ToString(); }
}
public ErrorCollector()
{
Success = true;
}
public void AddError(string msg, params object[] args)
{
Append("F", msg, args);
Success = false;
}
public void AddMessage(string msg, params object[] args)
{
Append("P", msg, args);
}
public IDisposable Indent()
{
_indent++;
return new DisposableAction(Unindent);
}
public void Unindent()
{
_indent--;
}
private void Append(string prefix, string msg, object[] args)
{
_message.Append(prefix);
_message.Append(":");
_message.Append(new String('\t', _indent));
_message.AppendFormat(msg, args);
_message.AppendLine();
}
}
}
|