Parse() public static method

public static Parse ( System.Xml.Linq.XElement participantElement ) : SIPEventDialogParticipant
participantElement System.Xml.Linq.XElement
return SIPEventDialogParticipant
Example #1
0
        public static SIPEventDialog Parse(XElement dialogElement)
        {
            XNamespace ns = m_dialogXMLNS;
            XNamespace ss = m_sipsorceryXMLNS;

            SIPEventDialog eventDialog = new SIPEventDialog();

            eventDialog.ID     = dialogElement.Attribute("id").Value;
            eventDialog.CallID = (dialogElement.Attribute("call-id") != null)
                ? dialogElement.Attribute("call-id").Value
                : null;
            eventDialog.LocalTag = (dialogElement.Attribute("local-tag") != null)
                ? dialogElement.Attribute("local-tag").Value
                : null;
            eventDialog.RemoteTag = (dialogElement.Attribute("remote-tag") != null)
                ? dialogElement.Attribute("remote-tag").Value
                : null;
            eventDialog.Direction = (dialogElement.Attribute("direction") != null)
                ? (SIPEventDialogDirectionEnum)Enum.Parse(typeof(SIPEventDialogDirectionEnum),
                                                          dialogElement.Attribute("direction").Value, true)
                : SIPEventDialogDirectionEnum.none;

            XElement stateElement = dialogElement.Element(ns + "state");

            eventDialog.State     = stateElement.Value;
            eventDialog.StateCode = (stateElement.Attribute("code") != null)
                ? Convert.ToInt32(stateElement.Attribute("code").Value)
                : 0;
            eventDialog.StateEvent = (stateElement.Attribute("event") != null)
                ? SIPEventDialogStateEvent.Parse(stateElement.Attribute("event").Value)
                : SIPEventDialogStateEvent.None;

            eventDialog.Duration = (dialogElement.Element(ns + "duration") != null)
                ? Convert.ToInt32(dialogElement.Element(ns + "duration").Value)
                : 0;
            eventDialog.BridgeID = (dialogElement.Element(ss + "bridgeid") != null)
                ? dialogElement.Element(ss + "bridgeid").Value
                : null;

            eventDialog.LocalParticipant = (dialogElement.Element(ns + "local") != null)
                ? SIPEventDialogParticipant.Parse(dialogElement.Element(ns + "local"))
                : null;
            eventDialog.RemoteParticipant = (dialogElement.Element(ns + "remote") != null)
                ? SIPEventDialogParticipant.Parse(dialogElement.Element(ns + "remote"))
                : null;

            return(eventDialog);
        }