in Source/Tx.Windows.TypeGeneration/ManifestParser.cs [720:762]
private void EmitMapValue(XElement maps, StringBuilder sb)
{
foreach (XElement map in maps.Elements())
{
string className = map.Attribute(AttributeNames.Name).Value;
bool isInt = map.Elements()
.Select(e => e.Attribute(AttributeNames.Value).Value)
.All(s =>
{
int val;
return Int32.TryParse(s, out val);
});
string mapType = isInt ? "int" : "uint";
sb.AppendFormat(" public enum {0} : {1}", NameUtils.CreateIdentifier(className), mapType);
sb.AppendLine(" {");
var mapCollection = new Dictionary<string, string>();
foreach (var mapValue in map.Elements())
{
var mapEnumIdentifier = NameUtils.CreateIdentifier(LookupResourceString(mapValue.Attribute(AttributeNames.Message).Value));
var mapEnumValue = mapValue.Attribute(AttributeNames.Value).Value;
if (mapCollection.ContainsKey(mapEnumIdentifier))
{
mapCollection[mapEnumIdentifier] += " | " + mapEnumValue;
}
else
{
mapCollection[mapEnumIdentifier] = mapEnumValue;
}
}
foreach (var mapValue in mapCollection)
{
sb.AppendFormat(" {0} = {1},", mapValue.Key, mapValue.Value);
sb.AppendLine();
}
sb.AppendLine(" }");
sb.AppendLine();
}
}