QuoteString() public static method

Quotes specified string. Note: Quotes inside text will be escaped to \".
public static QuoteString ( string text ) : string
text string String to quote.
return string
Beispiel #1
0
        /// <summary>
        /// Converts SIP_Uri to valid SIP-URI string.
        /// </summary>
        /// <returns>Returns SIP-URI string.</returns>
        public override string ToString()
        {
            // Syntax: sip:/sips: username@host *[;parameter] [?header *[&header]]

            StringBuilder retVal = new StringBuilder();

            if (this.IsSecure)
            {
                retVal.Append("sips:");
            }
            else
            {
                retVal.Append("sip:");
            }
            if (this.User != null)
            {
                retVal.Append(this.User + "@");
            }

            retVal.Append(this.Host);
            if (this.Port > -1)
            {
                retVal.Append(":" + this.Port.ToString());
            }

            // Add URI parameters.
            foreach (SIP_Parameter parameter in m_pParameters)
            {
                /*
                 * If value is token value is not quoted(quoted-string).
                 * If value contains `tspecials', value should be represented as quoted-string.
                 * If value is empty string, only parameter name is added.
                 */
                if (parameter.Value != null)
                {
                    if (MIME.MIME_Reader.IsToken(parameter.Value))
                    {
                        retVal.Append(";" + parameter.Name + "=" + parameter.Value);
                    }
                    else
                    {
                        retVal.Append(";" + parameter.Name + "=" + TextUtils.QuoteString(parameter.Value));
                    }
                }
                else
                {
                    retVal.Append(";" + parameter.Name);
                }
            }

            if (this.Header != null)
            {
                retVal.Append("?" + this.Header);
            }

            return(retVal.ToString());
        }