public void param <T> (string param_name, ref T param_val, T default_val) { if (!hasParam(param_name)) { param_val = default_val; return; } try { XmlRpcValue v = Param.getParam(param_name); if (v == null || !v.Valid) { param_val = default_val; } else { param_val = v.Get <T> (); } } catch { param_val = default_val; } }
/// <summary> /// Checks if the paramter exists. /// </summary> /// <param name="key">Name of the paramerer</param> /// <returns></returns> public static bool has(string key) { XmlRpcValue parm = new XmlRpcValue(), result = new XmlRpcValue(), payload = new XmlRpcValue(); parm.Set(0, this_node.Name); parm.Set(1, names.resolve(key)); if (!master.execute("hasParam", parm, ref result, ref payload, false)) { return(false); } return(payload.Get <bool>()); }
public bool registerSubscriber(Subscription s, string datatype) { string uri = XmlRpcManager.Instance.uri; XmlRpcValue args = new XmlRpcValue(this_node.Name, s.name, datatype, uri); XmlRpcValue result = new XmlRpcValue(); XmlRpcValue payload = new XmlRpcValue(); if (!master.execute("registerSubscriber", args, result, payload, true)) { return(false); } List <string> pub_uris = new List <string>(); for (int i = 0; i < payload.Size; i++) { XmlRpcValue load = payload[i]; string pubed = load.Get <string>(); if (pubed != uri && !pub_uris.Contains(pubed)) { pub_uris.Add(pubed); } } bool self_subscribed = false; Publication pub = null; string sub_md5sum = s.md5sum; lock (advertised_topics_mutex) { foreach (Publication p in advertised_topics) { pub = p; string pub_md5sum = pub.Md5sum; if (pub.Name == s.name && md5sumsMatch(pub_md5sum, sub_md5sum) && !pub.Dropped) { self_subscribed = true; break; } } } s.pubUpdate(pub_uris); if (self_subscribed) { s.addLocalConnection(pub); } return(true); }
public static bool getCached <T> (string key, T dest) { try { XmlRpcValue v = getParam(key, true); if (v == null || !v.Valid) { return(false); } dest = v.Get <T> (); return(true); } catch { return(false); } }
private static bool safeGet <T>(string key, ref T dest, object def = null) { try { XmlRpcValue v = getParam(key); if (v == null) { if (def == null) { return(false); } dest = (T)def; return(true); } dest = v.Get <T>(); return(true); } catch { return(false); } }
public T param <T> (string param_name, T default_val) { if (!hasParam(param_name)) { return(default_val); } try { XmlRpcValue v = Param.getParam(param_name); if (v == null || !v.Valid) { return(default_val); } return(v.Get <T> ()); } catch { return(default_val); } return(default_val); }