public static object LoadPreference(XmlNode node) { try { Object obj = null; string value = node.InnerText; // XmlDecode(node.InnerText); (already decoded by parser) if (node.Attributes != null && node.Attributes["type"] != null) { switch (node.Attributes["type"].InnerText) { case "null": return(null); case "int": int v = 0; int.TryParse(value, out v); return(v); case "bool": return(node.InnerText == "True"); case "string": return(value); //case "MyPreference": // return new MyPreference().FromXmlNode(node); case "TimeSpan": TimeSpan ts = TimeSpan.Zero; TimeSpan.TryParse(value, out ts); return(ts); default: //if (PreferenceTypeMap.ContainsKey(node.Attributes["type"].InnerText)) //{ Type type = null; try { type = Type.GetType(node.Attributes["type"].InnerText); } catch { type = null; } //Type type = PreferenceTypeMap[node.Attributes["type"].InnerText]; if (type != null) { try { obj = GetNewObject(type); IPreference p = (IPreference)obj; return(p.FromXmlNode(node)); } catch { } } //} // unknown object type return(null); } } // no type, so assume string return(value); } catch { } return(null); }