private static bool parseOptions(string format, out string newline, out string elementFormat)
{
// "{0,g}" -> multiline with system new line character and number format g
// "{0:Mn,g}" -> multiline with \n new line character and number format g
// "{0:Mnr,g}" -> multiline with \n\r new line character and number format g
// "{0:Ms,g}" -> single line and number format g
if (String.IsNullOrEmpty(format))
{
newline = Environment.NewLine;
elementFormat = String.Empty;
return true;
}
string[] options = format.Split(',');
if (options.Length == 1)
{
elementFormat = String.Empty;
switch (options[0])
{
case "Mn":
newline = "\n";
return true;
case "Mnr":
newline = "\n\r";
return true;
case "Ms":
newline = String.Empty;
return true;
default:
newline = Environment.NewLine;
elementFormat = format;
return false;
}
}
if (options.Length == 2)
{
elementFormat = options[1];
switch (options[0])
{
case "Mn":
newline = "\n";
break;
case "Mnr":
newline = "\n\r";
break;
case "Ms":
newline = String.Empty;
break;
default:
newline = String.Empty;
return false;
}
return true;
}
newline = String.Empty;
elementFormat = format;
return false;
}