Example #1
0
        /// <summary>Parses a string that represents one or more endpoints.</summary>
        /// <param name="endpointString">The string to parse.</param>
        /// <param name="communicator">The communicator.</param>
        /// <param name="oaEndpoints">When true (the default), endpointString corresponds to the Endpoints property of
        /// an object adapter. Otherwise, false.</param>
        /// <returns>The list of endpoints.</returns>
        internal static IReadOnlyList <Endpoint> ParseEndpoints(
            string endpointString,
            Communicator communicator,
            bool oaEndpoints = true)
        {
            int beg;
            int end = 0;

            string delim = " \t\n\r";

            var endpoints = new List <Endpoint>();

            while (end < endpointString.Length)
            {
                beg = StringUtil.FindFirstNotOf(endpointString, delim, end);
                if (beg == -1)
                {
                    if (endpoints.Count != 0)
                    {
                        throw new FormatException("invalid empty object adapter endpoint");
                    }
                    break;
                }

                end = beg;
                while (true)
                {
                    end = endpointString.IndexOf(':', end);
                    if (end == -1)
                    {
                        end = endpointString.Length;
                        break;
                    }
                    else
                    {
                        bool quoted = false;
                        int  quote  = beg;
                        while (true)
                        {
                            quote = endpointString.IndexOf('\"', quote);
                            if (quote == -1 || end < quote)
                            {
                                break;
                            }
                            else
                            {
                                quote = endpointString.IndexOf('\"', ++quote);
                                if (quote == -1)
                                {
                                    break;
                                }
                                else if (end < quote)
                                {
                                    quoted = true;
                                    break;
                                }
                                ++quote;
                            }
                        }
                        if (!quoted)
                        {
                            break;
                        }
                        ++end;
                    }
                }

                if (end == beg)
                {
                    throw new FormatException("invalid empty object adapter endpoint");
                }

                string s = endpointString[beg..end];