void GenerateListLoop (string container, ListMap map, string item, string index, TypeData itemTypeData, string targetString)
{
bool multichoice = (map.ItemInfo.Count > 1);
if (map.ChoiceMember != null && container != null && index != null) {
WriteLineInd ("if ((" + container + ".@" + map.ChoiceMember + " == null) || (" + index + " >= " + container + ".@" + map.ChoiceMember + ".Length))");
WriteLine ("throw CreateInvalidChoiceIdentifierValueException (" + container + ".GetType().ToString(), \"" + map.ChoiceMember + "\");");
Unindent ();
}
if (multichoice)
WriteLine ("if (((object)" + item + ") == null) { }");
foreach (XmlTypeMapElementInfo info in map.ItemInfo)
{
if (map.ChoiceMember != null && multichoice)
WriteLineInd ("else if (" + container + ".@" + map.ChoiceMember + "[" + index + "] == " + GetLiteral (info.ChoiceValue) + ") {");
else if (multichoice)
WriteLineInd ("else if (" + item + ".GetType() == typeof(" + info.TypeData.CSharpFullName + ")) {");
if (targetString == null)
GenerateWriteMemberElement (info, GetCast (info.TypeData, itemTypeData, item));
else
{
string strVal = GenerateGetStringValue (info.MappedType, info.TypeData, GetCast (info.TypeData, itemTypeData, item), false);
WriteLine (targetString + ".Append (" + strVal + ").Append (\" \");");
}
if (multichoice)
WriteLineUni ("}");
}
if (multichoice)
WriteLine ("else throw CreateUnknownTypeException (" + item + ");");
}