private static ParseTitle ( string src ) : string>.Dictionary |
||
src | string | |
return | string>.Dictionary |
private static Dictionary<string, string> ParseTitle(string src)
{
Dictionary<string, string> result = new Dictionary<string, string>();
StringBuilder value = new StringBuilder();
int i = 0;
while (i < src.Length)
{
var c = src[i];
if (c == '\\')
{
i++;
Assert.IsTrue(i < src.Length);
c = src[i];
switch (c)
{
case '\\':
case '=':
case ',':
value.Append(c);
break;
default:
Assert.Fail($"Unknown escape sequence \\{c}");
break;
}
}
else if (c == ',')
{
var entry = ParseValue(value.ToString());
result.Add(entry.Key, entry.Value);
value.Clear();
}
else
{
value.Append(c);
}
i++;
}
// Add the very last value.
{
var entry = ParseValue(value.ToString());
result.Add(entry.Key, entry.Value);
}
return result;
}