public LinkedList<StandardInfoWindowInfo> loadInfoFromFile(string filePath)
{
Logger.Log("InfoWindowLoader::loadInfoFromFile("+filePath+")", Logger.Level.INFO);
LinkedList<StandardInfoWindowInfo> resultInfo = new LinkedList<StandardInfoWindowInfo>();
XmlDocument xmlDoc = Tools.getXmlDocument(filePath);
XmlNodeList infoList = xmlDoc.GetElementsByTagName(InfoWindowXMLTags.INFO);
foreach (XmlNode infoNode in infoList)
{
reinitVars();
//common info attributes
try {
_code = infoNode.Attributes[InfoWindowXMLTags.CODE].Value;
}
catch (NullReferenceException exc) {
Logger.Log("InfoWindowLoader::loadInfoFromFile bad xml, missing field\n"+exc, Logger.Level.WARN);
continue;
}
catch (Exception exc) {
Logger.Log("InfoWindowLoader::loadInfoFromFile failed, got exc="+exc, Logger.Level.WARN);
continue;
}
if (checkString(_code)) {
foreach (XmlNode attr in infoNode){
switch (attr.Name){
case InfoWindowXMLTags.TEXTURE:
_texture = attr.InnerText;
break;
case InfoWindowXMLTags.NEXT:
_next = attr.InnerText;
break;
case InfoWindowXMLTags.CANCEL:
_cancel = attr.InnerText;
break;
default:
Logger.Log("InfoWindowLoader::loadInfoFromFile unknown attr "+attr.Name+" for info node", Logger.Level.WARN);
break;
}
}
if(
checkString(_texture)
&& checkString(_next)
//_cancel is optional, therefore no need to check it
)
{
_info = new StandardInfoWindowInfo(_code, _texture, _next, _cancel);
}
if(null != _info)
{
resultInfo.AddLast(_info);
}
}
else
{
Logger.Log("InfoWindowLoader::loadInfoFromFile Error : missing attribute code in info node", Logger.Level.WARN);
}
}
return resultInfo;
}