public static bool TryParse(byte[] datagram, out N1mmXmlContactInfo contactInfo) { string str; try { str = Encoding.UTF8.GetString(datagram); } catch (Exception ex) { Program.Log("Exception: {0}", ex); contactInfo = null; return(false); } try { var serialiser = new XmlSerializer(typeof(N1mmXmlContactInfo)); using (var reader = new StringReader(str)) { contactInfo = (N1mmXmlContactInfo)serialiser.Deserialize(reader); } } catch (Exception ex) { //Program.Log("Exception: {0}", ex); contactInfo = null; return(false); } return(true); }
static void ProcessContactAdd(N1mmXmlContactInfo ci) { if (Debugger.IsAttached) { if (ci.Call == "VO1CAL") { Debugger.Break(); } } ProcessContactAdd1(ci.Rcv, ci.Snt, ci.Call, ci.Timestamp, ci.Mode, ci.Txfreq, ci.Radionr); }
static void ProcessDatagram(byte[] msg) { if (N1mmRadioInfo.TryParse(msg, out N1mmRadioInfo ri)) { ProcessRadioInfo(ri); return; } string dg = Encoding.UTF8.GetString(msg); if (N1mmXmlContactInfo.TryParse(msg, out N1mmXmlContactInfo ci)) { ProcessContactAdd(ci); writedg(msg); } else if (N1mmXmlContactReplace.TryParse(msg, out N1mmXmlContactReplace cr)) { ProcessContactReplace(cr); } else if (ContactDelete.TryParse(msg, out ContactDelete cd)) { ProcessContactDelete(cd); } }