void FileLoader_FileLoaded(object sender, GetFileAsTextCompletedEventArgs e) { string configFileXml = e.FileContents; if (string.IsNullOrEmpty(configFileXml)) { OnGetConfigurationStoreFailed(new ExceptionEventArgs(new Exception(Resources.Strings.ExceptionConfigurationXmlIsEmpty), e.UserState)); return; } try { ConfigurationStore store = null; using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(configFileXml))) { DataContractSerializer serializer = new DataContractSerializer(typeof(ConfigurationStore)); store = serializer.ReadObject(ms) as ConfigurationStore; } OnGetConfigurationStoreCompleted(new GetConfigurationStoreCompletedEventArgs() { ConfigurationStore = store, UserState = e.UserState }); } catch (Exception ex) { OnGetConfigurationStoreFailed(new ExceptionEventArgs(ex, e.UserState)); } }
public string GetGeometryServiceUrl(ConfigurationStore configStore) { if (configStore == null || configStore.GeometryServices == null || configStore.GeometryServices.Count < 1) return null; return configStore.GeometryServices[0].Url; }
protected virtual void OnGetConfigurationStoreCompleted(GetConfigurationStoreCompletedEventArgs args) { DefaultConfigurationStore = args.ConfigurationStore; if (GetConfigurationStoreCompleted != null) { GetConfigurationStoreCompleted(this, args); } }
public string GetGeometryServiceUrl(ConfigurationStore configStore) { if (configStore == null || configStore.GeometryServices == null || configStore.GeometryServices.Count < 1) { return(null); } return(configStore.GeometryServices[0].Url); }
protected override void OnGetConfigurationStoreCompleted(GetConfigurationStoreCompletedEventArgs args) { ConfigurationStore store = args.ConfigurationStore; if (store != null) { bool isHttps = "https".Equals(Application.Current.Host.Source.Scheme); if (store.BaseMaps != null) { foreach (BaseMapInfo baseMapInfo in store.BaseMaps) { if (isHttps && baseMapInfo.BaseMapType == BaseMapType.OpenStreetMap) { // Open street map doesn't have a secure end point, so don't show it in https mode store.BaseMaps.Remove(baseMapInfo); break; } if (string.IsNullOrWhiteSpace(baseMapInfo.Url)) { continue; } if (isHttps) { baseMapInfo.Url = baseMapInfo.Url.Replace("http://", "https://"); } else { baseMapInfo.Url = baseMapInfo.Url.Replace("https://", "http://"); } } } if (store.GeometryServices != null) { foreach (GeometryServiceInfo serviceInfo in store.GeometryServices) { if (isHttps) { serviceInfo.Url = serviceInfo.Url.Replace("http://", "https://"); } else { serviceInfo.Url = serviceInfo.Url.Replace("https://", "http://"); } } } } base.OnGetConfigurationStoreCompleted(args); }
public virtual void GetConfigurationStoreAsync(object userState) { ConfigurationStore store = ReadStoreFromEmbeddedFile(); if (store != null) { OnGetConfigurationStoreCompleted(new GetConfigurationStoreCompletedEventArgs() { ConfigurationStore = store, UserState = userState }); } else { OnGetConfigurationStoreFailed(new ExceptionEventArgs(new Exception(Strings.ExceptionUnableToLoadconfigurationStoreFromEmbeddedResource), userState)); } }
public static ConfigurationStore ParseConfigurationStoreXml(string configFileXml) { if (string.IsNullOrEmpty(configFileXml)) { return(null); } string xmlPrefix = @"<?xml version=""1.0"" encoding=""utf-8""?>"; if (configFileXml.StartsWith(xmlPrefix, StringComparison.Ordinal)) { configFileXml = configFileXml.Substring(xmlPrefix.Length); } ConfigurationStore store = null; using (System.IO.MemoryStream ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(configFileXml))) { DataContractSerializer serializer = new DataContractSerializer(typeof(ConfigurationStore)); store = serializer.ReadObject(ms) as ConfigurationStore; } return(store); }
public override void GetConfigurationStoreAsync(object userState) { ConfigurationStore store = new ConfigurationStore() { GeometryServices = new List<GeometryServiceInfo>(), BingMapsAppId = _bingMapsAppId, PortalAppId = _portalAppId }; if (!string.IsNullOrWhiteSpace(_geometryServiceUrl)) store.GeometryServices.Add(new GeometryServiceInfo() { Url = _geometryServiceUrl }); OnGetConfigurationStoreCompleted(new GetConfigurationStoreCompletedEventArgs() { ConfigurationStore = store, UserState = userState }); }
protected virtual void OnGetConfigurationStoreCompleted(GetConfigurationStoreCompletedEventArgs args) { DefaultConfigurationStore = args.ConfigurationStore; if(GetConfigurationStoreCompleted != null) GetConfigurationStoreCompleted(this, args); }