Exemplo n.º 1
0
		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 }, 
				});
		}
Exemplo n.º 2
0
		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;
		}
Exemplo n.º 3
0
		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;
		}