ArcGISWindowsPhoneSDK.ArcGISWebClientSimple.webclient_DownloadStringCompleted C# (CSharp) Method

webclient_DownloadStringCompleted() private method

private webclient_DownloadStringCompleted ( object sender, ArcGISWebClient e ) : void
sender object
e ArcGISWebClient
return void
        void webclient_DownloadStringCompleted(object sender, ArcGISWebClient.DownloadStringCompletedEventArgs e)
        {
            try
            {
                if (e.Error != null)
                    throw new Exception(e.Error.Message);

                // Get the service url from the user object
                string svcUrl = e.UserState as string;

                //only available in Silverlight or .Net 4.5
                // Abstract JsonValue holds json response
                // JsonValue serviceInfo = JsonObject.Parse(e.Result);

                string[] jsonPairs = e.Result.Split(',');
                string mapCachePair = jsonPairs.Where(json => json.Contains("singleFusedMapCache")).FirstOrDefault();
                string[] mapCacheKeyAndValue = mapCachePair.Split(':');
                bool isTiledMapService = Boolean.Parse(mapCacheKeyAndValue[1]);

                // Use "singleFusedMapCache" to determine if a tiled or dynamic layer should be added to the map
                //bool isTiledMapService = Boolean.Parse(serviceInfo["singleFusedMapCache"].ToString());

                Layer lyr = null;

                if (isTiledMapService)
                    lyr = new ArcGISTiledMapServiceLayer() { Url = svcUrl };
                else
                    lyr = new ArcGISDynamicMapServiceLayer() { Url = svcUrl };

                if (lyr != null)
                {
                    lyr.InitializationFailed += (a, b) =>
                    {
                        throw new Exception(lyr.InitializationFailure.Message);
                    };
                    MyMap.Layers.Add(lyr);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }