SIPSorcery.SIP.SIPEventDialogParticipant.ToXML C# (CSharp) Method

ToXML() public method

Puts the dialog participant information to an XML element.
public ToXML ( string nodeName ) : System.Xml.Linq.XElement
nodeName string A participant can represent a local or remote party, the node name needs to be set to either "local" or "remote".
return System.Xml.Linq.XElement
        public XElement ToXML(string nodeName)
        {
            XNamespace ns = m_dialogXMLNS;
            XNamespace ss = m_sipsorceryXMLNS;
            XElement participantElement = new XElement(ns + nodeName);

            if(URI != null)
            {
                XElement identityElement = new XElement(ns + "identity", URI.ToString());
                if(!DisplayName.IsNullOrBlank())
                {
                    identityElement.Add(new XAttribute("display-name", DisplayName));
                }
                participantElement.Add(identityElement);
            }

            if(TargetURI != null)
            {
                XElement targetElement = new XElement(ns + "target", new XAttribute("uri", TargetURI.ToString()));
                participantElement.Add(targetElement);
            }

            if(CSeq > 0)
            {
                XElement cseqElement = new XElement(ns + "cseq", CSeq);
                participantElement.Add(cseqElement);
            }

            if (!SwitchboardLineName.IsNullOrBlank())
            {
                XElement switchLineNameElement = new XElement(ss + "switchboardlinename", SwitchboardLineName);
                participantElement.Add(switchLineNameElement);
            }

            if (!CRMPersonName.IsNullOrBlank())
            {
                XElement crmPersonNameElement = new XElement(ss + "crmpersonname", CRMPersonName);
                participantElement.Add(crmPersonNameElement);
            }

            if (!CRMCompanyName.IsNullOrBlank())
            {
                XElement crmCompanyNameElement = new XElement(ss + "crmcompanyname", CRMCompanyName);
                participantElement.Add(crmCompanyNameElement);
            }

            if (!CRMPictureURL.IsNullOrBlank())
            {
                XElement crmPictureURLElement = new XElement(ss + "crmpictureurl", CRMPictureURL);
                participantElement.Add(crmPictureURLElement);
            }

            return participantElement;
        }

Usage Example

Beispiel #1
0
        public XElement ToXML()
        {
            XNamespace ns = m_dialogXMLNS;
            XNamespace ss = m_sipsorceryXMLNS;

            XElement eventDialogElement = new XElement(ns + "dialog",
                                                       new XAttribute("id", ID),
                                                       new XElement(ns + "state", State)
                                                       );

            // Add the optional information if available.
            if (!CallID.IsNullOrBlank())
            {
                eventDialogElement.Add(new XAttribute("call-id", CallID));
            }
            if (!LocalTag.IsNullOrBlank())
            {
                eventDialogElement.Add(new XAttribute("local-tag", LocalTag));
            }
            if (!RemoteTag.IsNullOrBlank())
            {
                eventDialogElement.Add(new XAttribute("remote-tag", RemoteTag));
            }
            if (Direction != SIPEventDialogDirectionEnum.none)
            {
                eventDialogElement.Add(new XAttribute("direction", Direction));
            }
            if (StateCode != 0)
            {
                eventDialogElement.Element(ns + "state").Add(new XAttribute("code", StateCode));
            }
            if (StateEvent != SIPEventDialogStateEvent.None)
            {
                eventDialogElement.Element(ns + "state").Add(new XAttribute("event", StateEvent.ToString()));
            }
            if (Duration != 0)
            {
                eventDialogElement.Add(new XElement(ns + "duration", Duration));
            }
            if (BridgeID != null)
            {
                eventDialogElement.Add(new XElement(ss + "bridgeid", BridgeID));
            }
            if (SwitchboardOwner != null)
            {
                eventDialogElement.Add(new XElement(ss + "switchboardowner", SwitchboardOwner));
            }
            //if (LocalParticipant != null) { eventDialogElement.Add(LocalParticipant.ToXML("local", filter)); }
            if (LocalParticipant != null)
            {
                eventDialogElement.Add(LocalParticipant.ToXML("local"));
            }
            //if (RemoteParticipant != null) { eventDialogElement.Add(RemoteParticipant.ToXML("remote", filter)); }
            if (RemoteParticipant != null)
            {
                eventDialogElement.Add(RemoteParticipant.ToXML("remote"));
            }

            return(eventDialogElement);
        }