Exemplo n.º 1
0
        public static SIPEventPresenceTuple Parse(XElement tupleElement)
        {
            XNamespace ns = m_pidfXMLNS;

            SIPEventPresenceTuple tuple = new SIPEventPresenceTuple();
            tuple.ID = tupleElement.Attribute("id").Value;
            tuple.Status = (SIPEventPresenceStateEnum)Enum.Parse(typeof(SIPEventPresenceStateEnum), tupleElement.Element(ns + "status").Element(ns + "basic").Value, true);
            tuple.ContactURI = (tupleElement.Element(ns + "contact") != null) ? SIPURI.ParseSIPURI(tupleElement.Element(ns + "contact").Value) : null;
            tuple.ContactPriority = (tuple.ContactURI != null && tupleElement.Element(ns + "contact").Attribute("priority") != null) ? Decimal.Parse(tupleElement.Element(ns + "contact").Attribute("priority").Value) : Decimal.Zero;
            tuple.AvatarURL = (tuple.ContactURI != null && tupleElement.Element(ns + "contact").Attribute("avatarurl") != null) ? tupleElement.Element(ns + "contact").Attribute("avatarurl").Value : null;

            return tuple;
        }
        public override void Load(string presenceXMLStr)
        {
            try
            {
                XNamespace ns          = m_pidfXMLNS;
                XDocument  presenceDoc = XDocument.Parse(presenceXMLStr);

                Entity = SIPURI.ParseSIPURI(((XElement)presenceDoc.FirstNode).Attribute("entity").Value);

                var tupleElements = presenceDoc.Root.Elements(ns + "tuple");
                foreach (XElement tupleElement in tupleElements)
                {
                    Tuples.Add(SIPEventPresenceTuple.Parse(tupleElement));
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception SIPEventPresence Load. " + excp.Message);
                throw;
            }
        }