Has() public method

public Has ( string name ) : bool
name string
return bool
Exemplo n.º 1
0
        public override string ToString()
        {
            try
            {
                string uriStr = Scheme.ToString() + SCHEME_ADDR_SEPARATOR;

                uriStr = (User != null) ? uriStr + User + USER_HOST_SEPARATOR + Host : uriStr + Host;

                if (Parameters != null && Parameters.Count > 0)
                {
                    uriStr += Parameters.ToString();
                }

                // If the URI's protocol is not implied already set the transport parameter.
                if (Scheme != SIPSchemesEnum.sips && Protocol != SIPProtocolsEnum.udp &&
                    !Parameters.Has(m_uriParamTransportKey))
                {
                    uriStr += PARAM_TAG_DELIMITER + m_uriParamTransportKey + TAG_NAME_VALUE_SEPERATOR +
                              Protocol.ToString();
                }

                if (Headers != null && Headers.Count > 0)
                {
                    string headerStr = Headers.ToString();
                    uriStr += HEADER_START_DELIMITER + headerStr.Substring(1);
                }

                return(uriStr);
            }
            catch (Exception excp)
            {
                logger.LogError("Exception SIPURI ToString. " + excp.Message);
                throw excp;
            }
        }
Exemplo n.º 2
0
            public void EmptyValueParametersUnittest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                string        testParamStr1 = ";emptykey;Server=hippo;FTag=12345";
                SIPParameters testParam1    = new SIPParameters(testParamStr1, ';');

                Console.WriteLine("Parameter 1:" + testParam1.ToString());

                Assert.IsTrue(testParam1.Has("emptykey"), "The empty parameter \"emptykey\" was not correctly extracted from the paramter string.");
                Assert.IsTrue(Regex.Match(testParam1.ToString(), "emptykey").Success, "The emptykey name was not in the output parameter string.");
            }
Exemplo n.º 3
0
        /// <summary>
        /// Reverses The SIPEndPoint.ToString() method.
        /// </summary>
        /// <param name="serialisedSIPEndPoint">The serialised SIP end point MUST be in the form protocol:socket[;connid=abcd].
        /// Valid examples are udp:10.0.0.1:5060 and ws:10.0.0.1:5060;connid=abcd. An invalid example is 10.0.0.1:5060.</param>
        private static SIPEndPoint ParseSerialisedSIPEndPoint(string serialisedSIPEndPoint)
        {
            string channelID    = null;
            string connectionID = null;
            string endPointStr  = null;
            string protcolStr   = serialisedSIPEndPoint.Substring(0, serialisedSIPEndPoint.IndexOf(':'));

            if (serialisedSIPEndPoint.Contains(";"))
            {
                endPointStr = serialisedSIPEndPoint.Slice(':', ';');
                var paramsStr = serialisedSIPEndPoint.Substring(serialisedSIPEndPoint.IndexOf(';') + 1)?.Trim();

                var endPointParams = new SIPParameters(paramsStr, ';');

                if (endPointParams.Has(CHANNELID_ATTRIBUTE_NAME))
                {
                    channelID = endPointParams.Get(CHANNELID_ATTRIBUTE_NAME);
                }

                if (endPointParams.Has(CONNECTIONID_ATTRIBUTE_NAME))
                {
                    connectionID = endPointParams.Get(CONNECTIONID_ATTRIBUTE_NAME);
                }
            }
            else
            {
                endPointStr = serialisedSIPEndPoint.Substring(serialisedSIPEndPoint.IndexOf(':') + 1);
            }

            if (!IPSocket.TryParseIPEndPoint(endPointStr, out var endPoint))
            {
                throw new ApplicationException($"Could not parse SIPEndPoint host {endPointStr} as an IP end point.");
            }

            return(new SIPEndPoint(SIPProtocolsType.GetProtocolType(protcolStr), endPoint, channelID, connectionID));
        }
Exemplo n.º 4
0
            public void EmptyValueParametersUnittest()
            {
                Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);

                string testParamStr1 = ";emptykey;Server=hippo;FTag=12345";
                SIPParameters testParam1 = new SIPParameters(testParamStr1, ';');
                Console.WriteLine("Parameter 1:" + testParam1.ToString());

                Assert.IsTrue(testParam1.Has("emptykey"), "The empty parameter \"emptykey\" was not correctly extracted from the paramter string.");
                Assert.IsTrue(Regex.Match(testParam1.ToString(), "emptykey").Success, "The emptykey name was not in the output parameter string.");
            }