private bool SaveConfigurationFile(string cfgPath)
{
var sb = new StringBuilder();
sb.Append("configurations {\r\n");
foreach (var pivot in Pivots.Values) {
if (pivot.UsedChoices.Any()) {
var used = pivot.Choices.Keys.First().SingleItemAsEnumerable().Union(pivot.UsedChoices).ToArray();
// yep, do this one.
sb.Append(" ").Append(pivot.Name).Append(" { \r\n"); // Platform {
if (pivot.IsBuiltIn) {
sb.Append(" key : \"").Append(pivot.Key).Append("\";\r\n"); // key : "Platform";
}
sb.Append(" choices : { ").Append(used.Aggregate((current, each) => current + ", " + each)).Append(" };\r\n"); // choices: { Win32, x64, ARM, AnyCPU };
foreach(var ch in used) {
if (pivot.Choices[ch].Count() > 1) {
sb.Append(" ").Append(ch).Append(".aliases : { ").Append(pivot.Choices[ch].Aggregate((current, each) => current + ", " + each)).Append(" };\r\n"); //Win32.aliases : { x86, win32, ia32, 386 };
}
}
sb.Append(" };\r\n");
}
}
sb.Append("};\r\n");
File.WriteAllText(cfgPath, sb.ToString());
return true;
}