public static void GetSection(
     string version,
     string sectionName,
     string culture,
     string key,
     MapConfigurationCallback callback,
     bool reExecuteCallback) => GetSection(version, sectionName, culture, key, callback, reExecuteCallback, null);
Esempio n. 2
0
 public abstract void GetConfigurationSection(
     string version,
     string sectionName,
     string culture,
     MapConfigurationCallback callback,
     bool reExecuteCallback,
     object userState);
Esempio n. 3
0
 public MapConfigurationGetSectionRequest(string version, string sectionName, string culture, MapConfigurationCallback callback, object userState)
 {
     Version            = version;
     SectionName        = sectionName;
     Culture            = culture;
     Callback           = callback;
     UserState          = userState;
     CallbackDispatcher = Dispatcher.CurrentDispatcher;
 }
Esempio n. 4
0
 private void AddRequestToPendingQueue(
     string version,
     string sectionName,
     string culture,
     MapConfigurationCallback callback,
     object userState,
     string requestKey)
 {
     if (!requestQueue.ContainsKey(requestKey))
     {
         requestQueue.Add(requestKey, new Collection <MapConfigurationGetSectionRequest>());
     }
     requestQueue[requestKey].Add(new MapConfigurationGetSectionRequest(version, sectionName, culture, callback, userState));
 }
Esempio n. 5
0
        public override void GetConfigurationSection(
            string version,
            string sectionName,
            string culture,
            MapConfigurationCallback callback,
            bool reExecuteCallback,
            object userState)
        {
            _version = version;
            _culture = culture;
            var flag1      = ContainConfigurationSection(version, sectionName, culture);
            var requestKey = GetConfigurationKey(version, sectionName, culture);

            if (!flag1)
            {
                bool flag2;
                lock (configLock)
                {
                    flag1 = ContainConfigurationSection(version, sectionName, culture) || requestedSections.Contains(requestKey);
                    flag2 = !flag1 && !requestQueue.ContainsKey(requestKey);
                    AddRequestToPendingQueue(version, sectionName, culture, callback, userState, requestKey);
                    requestsPending = true;
                }
                if (flag2)
                {
                    var sectionReader = (XmlReader)null;
                    try
                    {
                        using var storageFileStream = GetIsolatedStorageFileStream(requestKey, FileMode.OpenOrCreate);
                        if (storageFileStream.Length > 0L)
                        {
                            sectionReader = XmlReader.Create(new StreamReader(storageFileStream));
                        }
                        else
                        {
                            var manifestResourceStream = typeof(MapConfiguration).Assembly.GetManifestResourceStream("Microsoft.Maps.MapControl.WPF.Data.DesignConfig.xml");
                            if (manifestResourceStream is object)
                            {
                                sectionReader = XmlReader.Create(manifestResourceStream);
                            }
                        }
                        if (sectionReader is object)
                        {
                            ConfigLoaded(requestKey, ParseConfiguration(sectionReader));
                        }
                    }
                    catch (XmlException)
                    {
                    }
                    finally
                    {
                        sectionReader?.Dispose();
                    }
                    requestTimer = new System.Timers.Timer(Map.LoggingDelay > 0 ? Map.LoggingDelay : 1.0)
                    {
                        AutoReset = false
                    };
                    requestTimer.Elapsed += (sender, e) =>
                    {
                        requestTimer.Dispose();
                        requestTimer                 = null;
                        using var webClient          = new WebClient();
                        webClient.OpenReadCompleted += new OpenReadCompletedEventHandler(LoadFromServer_OpenReadCompleted);
                        webClient.OpenReadAsync(configurationUri, requestKey);
                    };
                    requestTimer.Start();
                }
            }
            else
            {
                lock (configLock)
                {
                    if (requestsPending)
                    {
                        if (reExecuteCallback)
                        {
                            AddRequestToPendingQueue(version, sectionName, culture, callback, userState, requestKey);
                        }
                    }
                }
            }
            if (!flag1 || callback is null)
            {
                return;
            }
            callback(GetSection(version, sectionName, culture), userState);
        }
 public static void GetSection(string version, string sectionName, string culture, string key, MapConfigurationCallback callback, bool reExecuteCallback, object userState)
 {
     if (key is null)
     {
         key = "AnzLvLWGD8KU7wavNObJJdFVQcEGKMuBfBZ08b_Fo2cLb2HANvULeuewDmPDYExL";
     }
     if (configuration is null || configuration.Culture != culture)
     {
         if (!IsInDesignMode)
         {
             var uriString = defaultServiceUriFormat.Replace("{UriScheme}", Map.UriScheme).Replace("{UriKey}", key).Replace("{UriVersion}", version).Replace("{UriCulture}", culture).Replace("{UriRegion}", culture.Substring(culture.Length - 2)).Replace("{RegionLocation}", "");
             if (Map.UseHttps)
             {
                 uriString += "&uriScheme=https";
             }
             LoadConfiguration(new MapConfigurationFromWeb(new Uri(uriString, UriKind.Absolute)));
         }
         else
         {
             try
             {
                 typeof(MapConfiguration).Assembly.GetManifestResourceNames();
                 var manifestResourceStream = typeof(MapConfiguration).Assembly.GetManifestResourceStream("Microsoft.Maps.MapControl.WPF.Data.DesignConfig.xml");
                 if (manifestResourceStream is object)
                 {
                     LoadConfiguration(new MapConfigurationFromFile(XmlReader.Create(manifestResourceStream), culture, version));
                 }
             }
             catch (XmlException)
             {
             }
         }
     }
     if (string.IsNullOrEmpty(version))
     {
         throw new ArgumentException(ExceptionStrings.MapConfiguration_GetSection_NonNull, nameof(version));
     }
     if (string.IsNullOrEmpty(sectionName))
     {
         throw new ArgumentException(ExceptionStrings.MapConfiguration_GetSection_NonNull, nameof(sectionName));
     }
     configuration.GetConfigurationSection(version, sectionName, culture, callback, reExecuteCallback, userState);
 }
Esempio n. 7
0
 public override void GetConfigurationSection(string version, string sectionName, string culture, MapConfigurationCallback callback, bool reExecuteCallback, object userState)
 {
     _version = version;
     _culture = culture;
     if (callback is null)
     {
         return;
     }
     callback(GetSection(version, sectionName, culture), userState);
 }