Пример #1
0
        public static bool TryParse(byte[] datagram, out ContactDelete contactDelete)
        {
            string str;

            try
            {
                str = Encoding.UTF8.GetString(datagram);
            }
            catch (Exception ex)
            {
                Program.Log("Exception: {0}", ex);
                contactDelete = null;
                return(false);
            }

            try
            {
                var serialiser = new XmlSerializer(typeof(ContactDelete));
                using (var reader = new StringReader(str))
                {
                    contactDelete = (ContactDelete)serialiser.Deserialize(reader);
                }
            }
            catch (Exception ex)
            {
                //Program.Log("Exception: {0}", ex);
                contactDelete = null;
                return(false);
            }

            return(true);
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
 static void ProcessContactDelete(ContactDelete cd)
 {
     //throw new NotImplementedException();
 }