private static bool SafeGetDefault <T>(string key, out T dest, T def = default(T), bool useCache = false) { try { XmlRpcValue v = GetParam(key, useCache); if (v == null || !v.IsEmpty) { if (def == null) { dest = default(T); return(false); } dest = def; return(true); } if (typeof(T) == typeof(int)) { dest = (T)(object)v.GetInt(); } else if (typeof(T) == typeof(string)) { dest = (T)(object)v.GetString(); } else if (typeof(T) == typeof(bool)) { dest = (T)(object)v.GetBool(); } else if (typeof(T) == typeof(int)) { dest = (T)(object)v.GetInt(); } else if (typeof(T) == typeof(XmlRpcValue)) { dest = (T)(object)v; } else { // unsupported type dest = default(T); return(false); } return(true); } catch { dest = default(T); return(false); } }