- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
static MessageException()
{
kinds = new MessageKindsSet();
kinds.AddError("error", "error: <0>");
kinds.AddAttention("attention", "warning: <0>");
kinds.AddNormalMessage("message", "<0>");
kinds.AddError("out_of_bounds", "<0> out of <1>..<2>");
kinds.AddError("dont_be_here", "Should dont be here!");
kinds.AddError("not_found", "<0> not found!");
kinds.AddError("not_equal", "<0> not equals <1>");
kinds.AddError("equal", "<0> equals <1>, but they must be differrence!");
kinds.AddError("equals_null", "<0> is null!!");
kinds.AddError("excess_item", "Item '<0>' is excess");
kinds.AddError("expected_item", "Expected '<0>'");
kinds.AddError("unexpected_item", "Encountered unexpected item '<0>'");
kinds.AddError("wrong_item", "Wrong item '<0>'");
kinds.AddError("expected_other_item", "Expected '<0>' but encountered '<1>'");
kinds.AddError("unknown_item", "item '<0>' is unknown");
kinds.AddError("file_not_found", "File '<0>' not found");
kinds.AddError("wrong_file_extension", "File '<0>' has wrong extension");
kinds.AddError("expected_eol", "Expected end of line but encountered '<0>'");
kinds.AddError("expected_not_eol", "End of line unexpected!");
}
private void MakeTplParams()
{
Object[] obj = originalTplParams;
String[] str = new String[obj.Length];
int length = str.Length;
for (int i = 0; i < length; i++)
{
str[i] = !Object.ReferenceEquals(obj[i], null) ? obj[i].ToString() : "";
}
tplParams = str;
}
private String CreateText()
{
MakeTplParams();
Message kind = kinds.Get(kindName);
if (kind != null)
{
return MakeText(kind.TextTemplate);
}
else
{
return MakeDefaultText();
}
}
private String MakeText(String tpl)
{
MakeTplParams();
if (tpl == "")
{
return MakeDefaultText();
}
else
{
return MakeTextByTemplate(tpl);
}
}
private String MakeTextByTemplate(String tpl)
{
String builder = tpl;
int length = tplParams.Length;
for (int i = 0; i < length; i++)
{
builder = builder.Replace("<" + i + ">", (tplParams[i]));
}
return builder;
}
private String MakeDefaultText()
{
String builder = "";
builder += "[" + kindName + "] :";
int length = tplParams.Length;
for (int i = 0; i < length; i++)
{
builder += (tplParams[i]) + "; ";
}
return builder;
}
dm_fomenok 23.01.2017 13:42 # 0