/// <summary>
        /// Get the instance-level metadata for the server
        /// </summary>
        private async Task<ServerInfo> getServerInfo(string connectionString, string proxyUrl)
        {
            // Based on the input URL, get the different possible URLs that could point to the server
            Queue<string> candidateUrls = getCandidateUrls(connectionString);
            if (server == null || !candidateUrls.Contains(server.Uri))
            {
                // Try the different URLs
                int count = candidateUrls.Count;
                for (int i = 0; i < count; i++)
                {
                    server = new Server(candidateUrls.Dequeue(), proxyUrl);

                    try
                    {
                        ServerInfo info = await server.GetServerInfo();
                        if (info != null)
                        {
                            m_cachedServerInfos.Add(info);
                            return info;
                        }
                    }
                    catch { } // swallow exception because we're intentionally trying different URL permutations
                }

                return null;
            }
            else
            {
                // Since the server was already assigned one of the candidate URLs, assume it is the correct
                // one and retrieve server metadata directly
                return await server.GetServerInfo();
            }
        }
 private void tryGetResourceForAgsCandidateUrl(Queue<string> candidateUrls, string proxyUrl, Filter filter, object userState)
 {
     if (candidateUrls == null || candidateUrls.Count < 1)
     {
         OnGetCatalogFailed(new ExceptionEventArgs(new Exception(Strings.ExceptionDoneTryingallCandidateURLs), userState));
         return;
     }
     string agsRestUrl = candidateUrls.Dequeue();
     server = new Server(agsRestUrl, proxyUrl) { Filter = filter };
     server.GetCatalogCompleted += (o, e) =>
     {
         OnGetCatalogCompleted(new GetCatalogCompletedEventArgs() { ChildResources = e.ChildResources, UserState = e.UserState });
     };
     server.GetCatalogFailed += (o, e) =>
     {
         tryGetResourceForAgsCandidateUrl(candidateUrls, proxyUrl, filter, userState);
     };
     server.GetCatalog(userState);
 }
 private void getChildResourcesForServer(Resource parentResource, Filter filter, object userState)
 {
     server = new Server(parentResource.Url, parentResource.ProxyUrl) { Filter = filter };
     server.GetCatalogCompleted += (o, e) =>
     {
         OnGetChildResourcesCompleted(new GetChildResourcesCompletedEventArgs() { ChildResources = e.ChildResources, UserState = e.UserState });
     };
     server.GetCatalogFailed += (o, e) =>
     {
         OnGetChildResourcesFailed(e);
     };
     server.GetCatalog(userState);
 }