/// <summary> /// Для возможности задания стандартной начальной страницы(если есть токе, или если его нет) /// </summary> void SetupUriMapper() { // Get the UriMapper from the app.xaml resources, and assign it to the root frame UriMapper mapper = Resources["mapper"] as UriMapper; RootFrame.UriMapper = mapper; if (settings.Contains("access_token") && settings.Contains("user_id")) { MyUserData.user_id = (int)settings["user_id"]; MyUserData.access_token = (string)settings["access_token"]; if (MyUserData.user_id != 0 && MyUserData.access_token != null) { mapper.UriMappings[0].MappedUri = new Uri("/Pages/Conversation.xaml", UriKind.Relative); } else { mapper.UriMappings[0].MappedUri = new Uri("/Login.xaml", UriKind.Relative); } } else // выполняет при самом первом запуске приложения(создаем начальный словарь) { //MyUserData.user_id = 0; //if (!settings.Contains("access_token") && !settings.Contains("user_id")) //{ settings.Add("access_token", null); settings.Add("user_id", 0); //} mapper.UriMappings[0].MappedUri = new Uri("/Login.xaml", UriKind.Relative); } }
public void ShouldOmitQueryParametersInCssOrJsUrls() { var mapper = new UriMapper(new Configuration(MainUrl, _testDirectoryPath)); mapper.CreatePath("http://site1/min.css?v=12345678".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site1\min.css")); }
public void ShouldMapUrlWithParameters() { var mapper = new UriMapper(new Configuration(MainUrl, _testDirectoryPath)); mapper.CreatePath("http://site1/|".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site1\_ch_.html")); mapper.CreatePath("http://site1/".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site1\index.html")); mapper.CreatePath("http://site1/issues?q=is%3Aopen+is%3Aissue".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site1\issues_p_q=is_pr_3Aopen+is_pr_3Aissue.html")); mapper.CreatePath("http://site1/issues?q=is%3Aissue+is%3Aclosed".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site1\issues_p_q=is_pr_3Aissue+is_pr_3Aclosed.html")); mapper.CreatePath("http://site1/issues?q=is%3Aissue+is%3Aopen+sort%3Acreated-asc".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site1\issues_p_q=is_pr_3Aissue+is_pr_3Aopen+sort_pr_3Acreated-asc.html")); mapper.CreatePath("http://site1/issues?q=is%3Aissue+is%3Aopen+sort%3Acomments-desc".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site1\issues_p_q=is_pr_3Aissue+is_pr_3Aopen+sort_pr_3Acomments-desc.html")); mapper.CreatePath("http://site1/issues".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site1\issues.html")); mapper.CreatePath("http://site1/sharer.php?u=http%3A%2F%2Fhtml-agility-pack.net%2F".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site1\sharer.php_p_u=http_pr_3A_pr_2F_pr_2Fhtml-agility-pack.net_pr_2F.html")); mapper.CreatePath("http://site1.net/?ref=topbar_help".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site1.net\_p_ref=topbar_help.html")); mapper.CreatePath("http://site1.net/?&%25".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site1.net\_p__am__pr_25.html")); }
public void ShouldReplaceLongQueryPath() { var longUrl = $"http://url/?{string.Join("", Enumerable.Range(0, 200))}".AsUri(); var mapper = new UriMapper(new Configuration(MainUrl, _testDirectoryPath)); mapper.CreatePath(longUrl)?.Length .ShouldBe(_testDirectoryPath.Length + @"url\_p_".Length + (@"\" + Guid.Empty).Length + ".html".Length); }
public void ShouldMapFragmentedUri() { var mapper = new UriMapper(new Configuration(MainUrl, _testDirectoryPath)); mapper.CreatePath("http://site4/#".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site4\index.html")); mapper.CreatePath("http://site4/test/some.html/#part-2".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site4\test\some.html")); }
public void ShouldMapUriWithoutDirectNestedDirectory() { var mapper = new UriMapper(new Configuration(MainUrl, _testDirectoryPath)); mapper.CreatePath("http://site3/".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site3\index.html")); mapper.CreatePath("http://site3/test/some.html/".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site3\test\some.html")); }
public void MapUri(Uri from, Uri to) { UriMapper mapper = this.ContentFrame.UriMapper as UriMapper; mapper.UriMappings.Insert(0, new UriMapping() { Uri = from, MappedUri = to }); }
public void GetProperty_ValidStringValue_ReturnsSuccess(string stringValue, Uri expected) { var item = new UriMapper(); object value = null; PropertyMapperResultType result = item.GetProperty(new ReadCellValueResult(-1, stringValue), ref value); Assert.Equal(PropertyMapperResultType.Success, result); Assert.Equal(expected, value); }
public void GetProperty_InvalidStringValue_ReturnsInvalid(string stringValue) { var item = new UriMapper(); object value = 1; PropertyMapperResultType result = item.GetProperty(new ReadCellValueResult(-1, stringValue), ref value); Assert.Equal(PropertyMapperResultType.Invalid, result); Assert.Equal(1, value); }
public static async Task <ProcessingResult> ProcessAsync(Configuration configuration, CancellationToken token) { using var fileLoader = new FileLoader(token); var mapper = new UriMapper(configuration); var parser = new ItemParser(mapper, configuration.Mode); var writer = new ItemWriter(mapper); var processor = new ItemProcessor(fileLoader, parser, writer, configuration, token); await processor.RunAsync().ConfigureAwait(false); return(new ProcessingResult(fileLoader.FailedUris)); }
public void ShouldReplaceLongFileNamePath() { var longUrl = $"http://url/{string.Join("", Enumerable.Range(0, 200))}.jpeg".AsUri(); var item1 = new Item(longUrl); var mapper = new UriMapper(new Configuration(MainUrl, _testDirectoryPath)); mapper.CreatePath(item1.Uri); mapper.CreatePath(longUrl)?.Length .ShouldBe(_testDirectoryPath.Length + "url".Length + 2 * (@"\" + Guid.Empty).Length + ".jpeg".Length); }
public void ShouldAppendExtensionToFileName() { var mapper = new UriMapper(new Configuration(MainUrl, _testDirectoryPath)); mapper.CreatePath("http://site1/".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site1\index.html")); mapper.CreatePath("http://site1/test/some".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site1\test\some.html")); mapper.CreatePath("http://site1/css/style.css".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site1\css\style.css")); mapper.CreatePath("http://site1/test/1.5.5".AsUri(), NodeType.Html) .ShouldBe(Path.Combine(_testDirectoryPath, @"site1\test\1.5.5.html")); }
public void ShouldMapRelativeUri() { var mapper = new UriMapper(new Configuration(MainUrl, _testDirectoryPath)); mapper.CreatePath("http://site1/index.html".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site1\index.html")); mapper.CreatePath("http://site1/internal/internal.html".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site1\internal\internal.html")); mapper.CreatePath("http://site2/index2.html".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site2\index2.html")); mapper.CreatePath("http://site2/other_internal/some.html".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site2\other_internal\some.html")); }
public void ShouldRecognizeHostName() { var item1 = new Item("http://site1/test/some".AsUri()); var mapper = new UriMapper(new Configuration(MainUrl, _testDirectoryPath)); mapper.CreatePath(item1.Uri); mapper.CreatePath("http://site1/test/some".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site1\test\some.html")); mapper.CreatePath("http://site1/".AsUri()) .ShouldBe(Path.Combine(_testDirectoryPath, @"site1\index.html")); }
private void checkPassword() { UriMapper mapper = Resources["mapper"] as UriMapper; RootFrame.UriMapper = mapper; if (isoSetting.Contains("password")) { mapper.UriMappings[1].MappedUri = new Uri("/Login.xaml", UriKind.Relative); } else { mapper.UriMappings[1].MappedUri = new Uri("/MainPage.xaml", UriKind.Relative); } }
public void Map_Calls_Parse_And_Log_IsValidNever(string uriString) { // Arrange mockIParser.Setup(m => m.Parse(uriString)).Returns((Uri)null); var mapper = new UriMapper(mockIParser.Object, mockIValidator.Object, mockILogger.Object); // Act mapper.Map(uriString); // Assert mockIParser.Verify(p => p.Parse(uriString), Times.Once); mockIValidator.Verify(v => v.IsValid(null), Times.Never); mockILogger.Verify(l => l.Log($"The line {uriString} is not processed."), Times.Once); }
// Initializes UriMapper used to map to various pages based on application state private void InitializeUriMapper() { UriMapper mapper = Resources["mapper"] as UriMapper; RootFrame.UriMapper = mapper; if (!String.IsNullOrEmpty(GoodreadsClient.Current.AccessToken)) { mapper.UriMappings[0].MappedUri = new Uri("/Views/HomeView.xaml", UriKind.Relative); } else { mapper.UriMappings[0].MappedUri = new Uri("/Views/WelcomeView.xaml", UriKind.Relative); } }
public void Test() { var m = new UriMapper("http://example.com"); Assert.IsNull(m.MapLink(null), "MapLink(null) => null"); Assert.IsNull(m.MapLink("http://another-example.com/abc"), "MapLink(<another domain>) => null"); Assert.AreEqual("http://example.com/abc", m.MapLink("http://example.com/abc").ToString(), "MapLink(<absolute>) => absolute"); Assert.AreEqual("http://example.com/a/b/c", m.MapLink("/a/b/c").ToString(), "MapLink(<relative>) => absolute"); Assert.AreEqual("http://example.com/a/b/c", m.MapLink("a/b/c").ToString(), "MapLink(<relative>) => absolute"); Assert.AreEqual("http://example.com/abc", m.MapLink("/abc?query").ToString(), "MapLink(<with query>) => without query"); Assert.AreEqual("http://example.com/abc", m.MapLink("/abc#cool-stuff").ToString(), "MapLink(<with hash>) => without hash"); }
protected override UriMapper CreateUriMapper() { var mapper = new UriMapper(); //Mapps all examples to desired URIs foreach (var page in Module.ChartingPages) { mapper.UriMappings.Add(new UriMapping { Uri = new Uri(page.Value.Uri, UriKind.RelativeOrAbsolute), MappedUri = new Uri(page.Value.MappedUri, UriKind.RelativeOrAbsolute) }); } return(mapper); }
public void Map_Calls_Parse_And_IsValid_And_LogNever(string uriString) { // Arrange Uri uri = new Uri(uriString); mockIParser.Setup(m => m.Parse(uriString)).Returns(uri); var mapper = new UriMapper(mockIParser.Object, mockIValidator.Object, mockILogger.Object); // Act mapper.Map(uriString); // Assert mockIParser.Verify(p => p.Parse(uriString), Times.Once); mockIValidator.Verify(v => v.IsValid(uri), Times.Once); mockILogger.Verify(l => l.Log("never colled"), Times.Never); }
/// <summary> /// Constructor for the Application object. /// </summary> public App() { // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; // Standard XAML initialization InitializeComponent(); // Phone-specific initialization InitializePhoneApplication(); // Language display initialization InitializeLanguage(); // Show graphics profiling information while debugging. if (Debugger.IsAttached) { // Display the current frame rate counters. Application.Current.Host.Settings.EnableFrameRateCounter = true; // Show the areas of the app that are being redrawn in each frame. //Application.Current.Host.Settings.EnableRedrawRegions = true; // Enable non-production analysis visualization mode, // which shows areas of a page that are handed off to GPU with a colored overlay. //Application.Current.Host.Settings.EnableCacheVisualization = true; // Prevent the screen from turning off while under the debugger by disabling // the application's idle detection. // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run // and consume battery power when the user is not using the phone. PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; } var bingMapping = new UriMapping { Uri = new Uri("/SearchExtras", UriKind.Relative), MappedUri = new Uri("/MainPage.xaml", UriKind.Relative) }; var mapper = new UriMapper(); mapper.UriMappings.Add(bingMapping); RootFrame.UriMapper = mapper; }
private void InitializeUriMapper() { //DEV NOTE: application launching and application activated happen on two different //execution paths--if we want the UriMapper resource to contain the bindings below //we have to ensure that the method is called in both places. UriMapper mapper = Resources["UriMapper"] as UriMapper; RootFrame.UriMapper = mapper; if (null == DataService.Current.Blogs || 0 == DataService.Current.Blogs.Count) { mapper.UriMappings[0].MappedUri = new Uri("/LocateBlogPage.xaml", UriKind.Relative); } else { mapper.UriMappings[0].MappedUri = new Uri("/BlogsPage.xaml", UriKind.Relative); } }
public void Map_Calls_Parse_And_Log_Is(string uriString) { // Arrange Uri uri = new Uri(uriString); mockIParser.Setup(m => m.Parse(uriString)).Returns(uri); mockIValidator.Setup(v => v.Message).Returns($"The uri {uriString} must contain host of dns type."); var mapper = new UriMapper(mockIParser.Object, mockIValidator.Object, mockILogger.Object); // Act mapper.Map(uriString); // Assert mockIParser.Verify(p => p.Parse(uriString), Times.Once); mockIValidator.Verify(v => v.IsValid(uri), Times.Once); mockILogger.Verify(l => l.Log($"The line {uriString} is not processed - {mockIValidator.Object.Message}"), Times.Once); }
protected override UriMapper CreateUriMapper() { var mapper = new UriMapper(); //Mapps "" to HomeView mapper.UriMappings.Add(new UriMapping { Uri = new Uri("", UriKind.RelativeOrAbsolute), MappedUri = new Uri(Module.ChartingPages[AppPage.HomePageId].Uri, UriKind.RelativeOrAbsolute) }); //Mapps pages to desired URIs var applicationPages = Module.ChartingPages.Where(x => x.Value is ApplicationAppPage).Select(x => x.Value); foreach (var page in applicationPages) { mapper.UriMappings.Add(new UriMapping { Uri = new Uri(page.Uri, UriKind.RelativeOrAbsolute), MappedUri = new Uri(page.MappedUri, UriKind.RelativeOrAbsolute) }); //This is for browser navigation, so "/Url" and "/Url/" both works mapper.UriMappings.Add(new UriMapping { Uri = new Uri(string.Format("{0}/", page.Uri), UriKind.RelativeOrAbsolute), MappedUri = new Uri(page.MappedUri, UriKind.RelativeOrAbsolute) }); } //Mapps all examples to ExamplesView so main frame won't navigate to particular example, but to ExampleView, and stay on it. var examplePages = Module.ChartingPages.Where(x => x.Value is ExampleAppPage).Select(x => x.Value); foreach (var page in examplePages) { mapper.UriMappings.Add(new UriMapping { Uri = new Uri(page.Uri, UriKind.RelativeOrAbsolute), MappedUri = new Uri(Module.ChartingPages[AppPage.ExamplesPageId].MappedUri, UriKind.RelativeOrAbsolute) }); } return(mapper); }
/// <summary> /// Constructor for the Application object. /// </summary> public App() { // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; LoggerNamespace.Logger.SetLogLevel(Convert.ToInt32(LoggerNamespace.LogLevel.DEBUG | LoggerNamespace.LogLevel.INFORM | LoggerNamespace.LogLevel.ERROR | LoggerNamespace.LogLevel.WARN)); // Standard Silverlight initialization InitializeComponent(); // Phone-specific initialization InitializePhoneApplication(); // Show graphics profiling information while debugging. if (System.Diagnostics.Debugger.IsAttached) { // Display the current frame rate counters. //Application.Current.Host.Settings.EnableFrameRateCounter = true; // Show the areas of the app that are being redrawn in each frame. //Application.Current.Host.Settings.EnableRedrawRegions = true; // Enable non-production analysis visualization mode, // which shows areas of a page that are handed off to GPU with a colored overlay. //Application.Current.Host.Settings.EnableCacheVisualization = true; // Disable the application idle detection by setting the UserIdleDetectionMode property of the // application's PhoneApplicationService object to Disabled. // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run // and consume battery power when the user is not using the phone. PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; } var mapper = new UriMapper(); mapper.UriMappings.Add(new UriMapping { Uri = new Uri("/MainPage.xaml", UriKind.Relative), #if WP8 MappedUri = new Uri("/LuaScriptingEngine8;component/ScriptingEngine/LuaForm.xaml", UriKind.Relative) #else MappedUri = new Uri("/LuaScriptingEngine7;component/ScriptingEngine/LuaForm.xaml", UriKind.Relative) #endif });
private static UriMapper PaginaInicial() { var isolatedSettings = IsolatedStorageSettings.ApplicationSettings; var mapper = new UriMapper(); Thread.CurrentThread.CurrentCulture = Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-ES"); if (isolatedSettings.Contains("NombreUsuario")) { mapper.UriMappings.Add(new UriMapping { Uri = new Uri("/InitialPage.xaml", UriKind.RelativeOrAbsolute), MappedUri = new Uri("/MainPage.xaml", UriKind.RelativeOrAbsolute) }); return(mapper); } mapper.UriMappings.Add(new UriMapping { Uri = new Uri("/InitialPage.xaml", UriKind.RelativeOrAbsolute), MappedUri = new Uri("/Ventanas/LoginPage.xaml", UriKind.RelativeOrAbsolute) }); return(mapper); }
/// <summary> /// 获取下游请求信息 /// </summary> /// <param name="routeConfiguration"></param> /// <param name="upstreamQueryString">上游请求的查询字符串</param> /// <returns></returns> private DownstreamRoute GetDownstreamRoute(FileRouteConfiguration routeConfiguration, string upstreamQueryString) { DownstreamRoute downstreamRoute = new DownstreamRoute(); var downstreamHostInfo = GetDownstreamHostString(routeConfiguration.DownstreamHostInfo); downstreamRoute.Host = downstreamHostInfo.IP; downstreamRoute.Port = int.Parse(downstreamHostInfo.Port); downstreamRoute.Scheme = routeConfiguration.DownstreamScheme; downstreamRoute.PathTemplate = UriMapper.GetRestfullUri(routeConfiguration.DownstreamPathTemplate, upstreamQueryString); downstreamRoute.QueryString = upstreamQueryString; downstreamRoute.Authentication = routeConfiguration.Authentication; return(downstreamRoute); }
private static UriMapper CreateOldAppMapping() { var mapping = new UriMapping { Uri = new Uri(ExampleNavigationPattern, UriKind.RelativeOrAbsolute), MappedUri = new Uri(OldAppNavigationPattern, UriKind.RelativeOrAbsolute) }; var mapper = new UriMapper(); mapper.UriMappings.Add(mapping); var examples = Module.ChartingPages.Where(x => x.Value is ExampleAppPage).Select(x => x.Value); foreach (var example in examples) { mapper.UriMappings.Add(new UriMapping { Uri = mapping.MapUri(new Uri(example.MappedUri, UriKind.RelativeOrAbsolute)), MappedUri = new Uri(example.Uri, UriKind.RelativeOrAbsolute), }); } return(mapper); }
public void TestInitialize() { this.UriMapper = new UriMapper(); }
private static bool AutoMap(this Type memberType, FallbackStrategy emptyValueStrategy, out ICellValueMapper mapper, out IFallbackItem emptyFallback, out IFallbackItem invalidFallback) { Type type = memberType.GetNullableTypeOrThis(out bool isNullable); Type[] interfaces = type.GetTypeInfo().ImplementedInterfaces.ToArray(); IFallbackItem ReconcileFallback(FallbackStrategy strategyToPursue, bool empty) { // Empty nullable values should be set to null. if (empty && isNullable) { return(new FixedValueFallback(null)); } else if (strategyToPursue == FallbackStrategy.SetToDefaultValue || emptyValueStrategy == FallbackStrategy.SetToDefaultValue) { return(new FixedValueFallback(type.DefaultValue())); } else { Debug.Assert(emptyValueStrategy == FallbackStrategy.ThrowIfPrimitive); // The user specified that we should set to the default value if it was empty. return(new ThrowFallback()); } } if (type == typeof(DateTime)) { mapper = new DateTimeMapper(); emptyFallback = ReconcileFallback(FallbackStrategy.ThrowIfPrimitive, empty: true); invalidFallback = ReconcileFallback(FallbackStrategy.ThrowIfPrimitive, empty: false); } else if (type == typeof(bool)) { mapper = new BoolMapper(); emptyFallback = ReconcileFallback(FallbackStrategy.ThrowIfPrimitive, empty: true); invalidFallback = ReconcileFallback(FallbackStrategy.ThrowIfPrimitive, empty: false); } else if (type.GetTypeInfo().IsEnum) { mapper = new EnumMapper(type); emptyFallback = ReconcileFallback(FallbackStrategy.ThrowIfPrimitive, empty: true); invalidFallback = ReconcileFallback(FallbackStrategy.ThrowIfPrimitive, empty: false); } else if (type == typeof(string) || type == typeof(object) || type == typeof(IConvertible)) { mapper = new StringMapper(); emptyFallback = ReconcileFallback(FallbackStrategy.SetToDefaultValue, empty: true); invalidFallback = ReconcileFallback(FallbackStrategy.SetToDefaultValue, empty: false); } else if (type == typeof(Uri)) { mapper = new UriMapper(); emptyFallback = ReconcileFallback(FallbackStrategy.SetToDefaultValue, empty: true); invalidFallback = ReconcileFallback(FallbackStrategy.ThrowIfPrimitive, empty: false); } else if (interfaces.Any(t => t == typeof(IConvertible))) { mapper = new ChangeTypeMapper(type); emptyFallback = ReconcileFallback(FallbackStrategy.ThrowIfPrimitive, empty: true); invalidFallback = ReconcileFallback(FallbackStrategy.ThrowIfPrimitive, empty: false); } else { mapper = null; emptyFallback = null; invalidFallback = null; return(false); } return(true); }
/// <summary> /// Constructor for the Application object. /// </summary> public App() { // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; // Standard Silverlight initialization InitializeComponent(); // Phone-specific initialization InitializePhoneApplication(); // Show graphics profiling information while debugging. if (System.Diagnostics.Debugger.IsAttached) { // Display the current frame rate counters. Application.Current.Host.Settings.EnableFrameRateCounter = true; // Show the areas of the app that are being redrawn in each frame. //Application.Current.Host.Settings.EnableRedrawRegions = true; // Enable non-production analysis visualization mode, // which shows areas of a page that are handed off to GPU with a colored overlay. //Application.Current.Host.Settings.EnableCacheVisualization = true; // Disable the application idle detection by setting the UserIdleDetectionMode property of the // application's PhoneApplicationService object to Disabled. // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run // and consume battery power when the user is not using the phone. PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; } // Get the UriMapper from the app.xaml resources, and assign it to the root frame UriMapper mapper = Resources["mapper"] as UriMapper; RootFrame.UriMapper = mapper; mapper.UriMappings[0].MappedUri = new Uri("/MainPage.xaml", UriKind.Relative); try { settings = IsolatedStorageSettings.ApplicationSettings; // Load default values if they do not exist if (!settings.Contains("autologin")) { settings["autologin"] = true; } if (!settings.Contains("redirect")) { settings["redirect"] = true; } if (settings.Contains("username") && settings.Contains("password")) { var autologin = (bool)settings["autologin"]; if (autologin) { mapper.UriMappings[0].MappedUri = new Uri("/Siding.xaml", UriKind.Relative); } } } catch (Exception) { } }