internal static void AddRoutes(State state) { if (state.Page.Length != 0 && state.Attributes["route"] != null && state.Attributes["route"].Length != 0) { Route route = RouteTable.Routes.MapPageRoute(state.GetRouteName(false), state.GetRoute(false), state.GetPage(false), state.CheckPhysicalUrlAccess, StateInfoConfig.GetRouteDefaults(state, state.GetRoute(false)), null, new RouteValueDictionary() { { NavigationSettings.Config.StateIdKey, state.Id }, }); #if NET45Plus if (state.MobilePage.Length == 0 && state.MobileRoute.Length == 0 && state.MobileMasters.Count == 0 && state.MobileTheme.Length == 0) route.RouteHandler = (StateRouteHandler)Activator.CreateInstance(_StateRouteHandlerType, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, new object[] { state }, null); #endif } if (state.Page.Length != 0 && state.Attributes["mobileRoute"] != null && state.Attributes["mobileRoute"].Length != 0) RouteTable.Routes.MapPageRoute(state.GetRouteName(true), state.GetRoute(true), state.GetPage(true), state.CheckPhysicalUrlAccess, StateInfoConfig.GetRouteDefaults(state, state.GetRoute(true)), null, new RouteValueDictionary() { { NavigationSettings.Config.StateIdKey, state.Id }, }); }
private static StateDisplayInfo GetStateDisplayInfo(State state, HttpRequest request) { bool mobile; string displayModes = HttpUtility.HtmlDecode(request.Form[DISPLAY_MODES]); StateDisplayInfo stateDisplayInfo = new StateDisplayInfo(); if (displayModes == null) { mobile = request.Browser.IsMobileDevice; stateDisplayInfo.DisplayModes = mobile ? "Mobile" : string.Empty; stateDisplayInfo.IsPostBack = false; } else { mobile = StringComparer.OrdinalIgnoreCase.Compare(Regex.Split(displayModes, "\\|")[0], "Mobile") == 0; stateDisplayInfo.DisplayModes = displayModes; stateDisplayInfo.IsPostBack = true; } stateDisplayInfo.Page = state.GetPage(mobile); #if NET40Plus stateDisplayInfo.Route = state.GetRoute(mobile); stateDisplayInfo.RouteName = state.GetRouteName(mobile); #endif stateDisplayInfo.Masters = state.GetMasters(mobile); stateDisplayInfo.Theme = state.GetTheme(mobile); return stateDisplayInfo; }
private static StateDisplayInfo GetStateDisplayInfo(State state, HttpContextBase context) { bool mobile; string displayModes = HttpUtility.HtmlDecode(context.Request.Form[DISPLAY_MODES]); StateDisplayInfo stateDisplayInfo = new StateDisplayInfo(); if (displayModes == null) { mobile = new HttpContextWrapper(HttpContext.Current).GetOverriddenBrowser().IsMobileDevice; if (DisplayModeProvider.Instance.RequireConsistentDisplayMode && (!mobile || state.MobilePage.Length == 0)) stateDisplayInfo.DisplayMode = DisplayModeProvider.Instance.Modes.Last(); stateDisplayInfo.DisplayModes = mobile ? "Mobile" : string.Empty; stateDisplayInfo.IsPostBack = false; } else { mobile = StringComparer.OrdinalIgnoreCase.Compare(Regex.Split(displayModes, "\\|")[0], "Mobile") == 0; stateDisplayInfo.DisplayModes = displayModes; stateDisplayInfo.IsPostBack = true; } stateDisplayInfo.Page = state.GetPage(mobile); stateDisplayInfo.Route = state.GetRoute(mobile); stateDisplayInfo.RouteName = state.GetRouteName(mobile); stateDisplayInfo.Masters = state.GetMasters(mobile); stateDisplayInfo.Theme = state.GetTheme(mobile); return stateDisplayInfo; }
private string GetLink(State state, NameValueCollection data, bool mobile, string applicationPath) { StringBuilder link = new StringBuilder(); link.Append(VirtualPathUtility.ToAbsolute(state.GetPage(mobile), applicationPath)); link.Append("?"); link.Append(HttpUtility.UrlEncode(NavigationSettings.Config.StateIdKey)); link.Append("="); link.Append(HttpUtility.UrlEncode(state.Id)); foreach (string key in data) { if (key != NavigationSettings.Config.StateIdKey) { link.Append("&"); link.Append(HttpUtility.UrlEncode(key)); link.Append("="); link.Append(HttpUtility.UrlEncode(data[key])); } } return link.ToString(); }