public static ButtonIndex Load() { string filename = string.Format(Path.Combine(Pandora.Profile.BaseFolder, "bdi.xml")); if (File.Exists(filename)) { XmlDocument dom = new XmlDocument(); dom.Load(filename); if (dom.ChildNodes.Count != 2) { Pandora.Log.WriteError(null, string.Format("Bad format for file {0}", filename)); return(null); } XmlElement main = (XmlElement)dom.ChildNodes[1]; if (main.Name != "table") { Pandora.Log.WriteError(null, string.Format("Bad format for file {0}", filename)); return(null); } ButtonIndex index = new ButtonIndex(); foreach (XmlElement data in main.ChildNodes) { try { int key = Convert.ToInt32(data.Attributes["id"].Value); int val = Convert.ToInt32(data.Attributes["index"].Value); index.m_Table[key] = val; } catch (Exception err) { Pandora.Log.WriteError(err, string.Format("An error occurred when reading entries from {0}", filename)); return(null); } } return(index); } else { return(null); } }
public static ButtonIndex Load() { string filename = string.Format( Path.Combine( Pandora.Profile.BaseFolder, "bdi.xml" ) ); if ( File.Exists( filename ) ) { XmlDocument dom = new XmlDocument(); dom.Load( filename ); if ( dom.ChildNodes.Count != 2 ) { Pandora.Log.WriteError( null, string.Format( "Bad format for file {0}", filename ) ); return null; } XmlElement main = (XmlElement) dom.ChildNodes[ 1 ]; if ( main.Name != "table" ) { Pandora.Log.WriteError( null, string.Format( "Bad format for file {0}", filename ) ); return null; } ButtonIndex index = new ButtonIndex(); foreach ( XmlElement data in main.ChildNodes ) { try { int key = Convert.ToInt32( data.Attributes[ "id" ].Value ); int val = Convert.ToInt32( data.Attributes[ "index" ].Value ); index.m_Table[ key ] = val; } catch ( Exception err ) { Pandora.Log.WriteError( err, string.Format( "An error occurred when reading entries from {0}", filename ) ); return null; } } return index; } else { return null; } }