Example #1
0
		private StateDisplayInfo GetStateDisplayInfo(HttpContextBase context)
		{
			StateDisplayInfo stateDisplayInfo = new StateDisplayInfo();
			stateDisplayInfo.IsPostBack = false;
			DisplayInfo displayInfo = GetDisplayInfoForPage(State.Page, context);
			stateDisplayInfo.DisplayMode = displayInfo.DisplayMode;
			stateDisplayInfo.Page = displayInfo.FilePath;
			stateDisplayInfo.DisplayModes = displayInfo.DisplayMode.DisplayModeId;
			stateDisplayInfo.Route = State.Route;
			stateDisplayInfo.RouteName = State.GetRouteName(false);
			stateDisplayInfo.Masters = State.Masters;
			stateDisplayInfo.Theme = State.Theme;
			if (StringComparer.OrdinalIgnoreCase.Compare(State.Page, stateDisplayInfo.Page) != 0)
			{
				stateDisplayInfo.Masters = new ReadOnlyCollection<string>(new string[0]);
				stateDisplayInfo.Theme = string.Empty;
			}
			return stateDisplayInfo;
		}
Example #2
0
		private bool IsConsistent(StateDisplayInfo stateDisplayInfo)
		{
#if NET40Plus
			Route route = Page.RouteData.Route as Route;
			if ((route == null && (stateDisplayInfo.Route.Length != 0 && RouteTable.Routes[stateDisplayInfo.RouteName] != null))
				|| (route != null && StringComparer.OrdinalIgnoreCase.Compare(stateDisplayInfo.Route, route.Url) != 0)
				|| StringComparer.OrdinalIgnoreCase.Compare(stateDisplayInfo.Page, Page.AppRelativeVirtualPath) != 0)
				return false;
#else
			if (StringComparer.OrdinalIgnoreCase.Compare(stateDisplayInfo.Page, Page.AppRelativeVirtualPath) != 0)
				return false;
#endif
			return true;
		}
Example #3
0
		private StateDisplayInfo GetStateDisplayInfo(string displayModes, HttpContextBase context)
		{
			StateDisplayInfo stateDisplayInfo = new StateDisplayInfo();
			stateDisplayInfo.IsPostBack = true;
			stateDisplayInfo.Page = State.Page;
			stateDisplayInfo.DisplayModes = displayModes;
			stateDisplayInfo.Route = State.Route;
			stateDisplayInfo.RouteName = State.GetRouteName(false);
			stateDisplayInfo.Masters = State.Masters;
			stateDisplayInfo.Theme = State.Theme;
			string[] displayModeIds = Regex.Split(displayModes, "\\|");
			DisplayInfo displayInfo = new DisplayInfo(State.Page, DisplayModeProvider.Instance.Modes.Where(m => m.DisplayModeId == displayModeIds[0]).First());
			stateDisplayInfo.Page = GetPageForDisplayInfo(displayInfo, context);
			if (StringComparer.OrdinalIgnoreCase.Compare(State.Page, stateDisplayInfo.Page) != 0)
			{
				stateDisplayInfo.Masters = new ReadOnlyCollection<string>(new string[0]);
				stateDisplayInfo.Theme = string.Empty;
			}
			return stateDisplayInfo;
		}
Example #4
0
		private static void UpdateStateDisplayInfo(StateDisplayInfo stateDisplayInfo, Page page)
		{
			string[] displayModeIds = Regex.Split(stateDisplayInfo.DisplayModes, "\\|");
			int i = 1;
			MasterPage master = null;
			if (stateDisplayInfo.Masters.Count != 0 && displayModeIds.Length > i)
			{
				page.MasterPageFile = stateDisplayInfo.Masters[0];
				page.Master.ID = "m";
				master = page.Master;
				if (stateDisplayInfo.Masters.Count > 1 && displayModeIds[i].Length == 0)
					master.MasterPageFile = stateDisplayInfo.Masters[1];
				i++;
			}
			while (master != null && !string.IsNullOrEmpty(master.MasterPageFile) && displayModeIds.Length > i)
			{
				master.MasterPageFile = master.MasterPageFile;
				master.Master.ID = "m";
				master = master.Master;
				if (stateDisplayInfo.Masters.Count > i && displayModeIds[i].Length == 0)
					master.MasterPageFile = stateDisplayInfo.Masters[i];
				i++;
			}
			if (stateDisplayInfo.Theme.Length != 0 && displayModeIds.Length > i)
			{
				page.Theme = stateDisplayInfo.Theme;
			}
		}
Example #5
0
		private static void UpdateStateDisplayInfo(StateDisplayInfo stateDisplayInfo, HttpRequest request, Page page)
		{
			StringBuilder keyBuilder = new StringBuilder();
			keyBuilder.Append(stateDisplayInfo.DisplayModes);
			MasterPage master = null;
			if (stateDisplayInfo.Masters.Count != 0)
			{
				keyBuilder.Append("|");
				page.MasterPageFile = stateDisplayInfo.Masters[0];
				page.Master.ID = "m";
				master = page.Master;
				if (stateDisplayInfo.Masters.Count > 1)
					master.MasterPageFile = stateDisplayInfo.Masters[1];
			}
			int i = 2;
			while (master != null && !string.IsNullOrEmpty(master.MasterPageFile))
			{
				keyBuilder.Append("|");
				master.MasterPageFile = master.MasterPageFile;
				master.Master.ID = "m";
				master = master.Master;
				if (stateDisplayInfo.Masters.Count > i)
					master.MasterPageFile = stateDisplayInfo.Masters[i];
				i++;
			}
			if (stateDisplayInfo.Theme.Length != 0)
			{
				keyBuilder.Append("|");
				page.Theme = stateDisplayInfo.Theme;
			}
			stateDisplayInfo.DisplayModes = keyBuilder.ToString();
		}
Example #6
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;
		}
Example #7
0
		private void UpdateStateDisplayInfo(StateDisplayInfo stateDisplayInfo, Page page, HttpContextBase context)
		{
			string[] displayModeIds = Regex.Split(stateDisplayInfo.DisplayModes, "\\|");
			int i = 1;
			MasterPage master = null;
			bool masterSwitch = false;
			DisplayInfo displayInfo;
			if (stateDisplayInfo.Masters.Count != 0 && displayModeIds.Length > i)
			{
				displayInfo = new DisplayInfo(stateDisplayInfo.Masters[0], DisplayModeProvider.Instance.Modes.Where(m => m.DisplayModeId == displayModeIds[i]).First());
				page.MasterPageFile = GetMasterForDisplayInfo(displayInfo, context);
				page.Master.ID = "m";
				master = page.Master;
				if (stateDisplayInfo.Masters.Count > 1 && displayModeIds[i].Length == 0)
					master.MasterPageFile = stateDisplayInfo.Masters[1];
				else
					masterSwitch = true;
				i++;
			}
			while (master != null && !string.IsNullOrEmpty(master.MasterPageFile) && displayModeIds.Length > i)
			{
				displayInfo = new DisplayInfo(master.MasterPageFile, DisplayModeProvider.Instance.Modes.Where(m => m.DisplayModeId == displayModeIds[i]).First());
				master.MasterPageFile = GetMasterForDisplayInfo(displayInfo, context);
				master.Master.ID = "m";
				master = master.Master;
				if (!masterSwitch && stateDisplayInfo.Masters.Count > i && displayModeIds[i].Length == 0)
					master.MasterPageFile = stateDisplayInfo.Masters[i];
				else
					masterSwitch = true;
				i++;
			}
			if (stateDisplayInfo.Theme.Length != 0 && displayModeIds.Length > i)
			{
				displayInfo = new DisplayInfo(stateDisplayInfo.Theme, DisplayModeProvider.Instance.Modes.Where(m => m.DisplayModeId == displayModeIds[i]).First());
				page.Theme = GetThemeForDisplayInfo(displayInfo, context);
			}
		}
Example #8
0
		private void UpdateStateDisplayInfo(StateDisplayInfo stateDisplayInfo, HttpContextBase context, Page page)
		{
			DisplayInfo displayInfo;
			StringBuilder keyBuilder = new StringBuilder();
			keyBuilder.Append(stateDisplayInfo.DisplayModes);
			MasterPage master = null;
			bool masterSwitch = false;
			if (stateDisplayInfo.Masters.Count != 0)
			{
				displayInfo = GetDisplayInfoForMaster(stateDisplayInfo.Masters[0], stateDisplayInfo.DisplayMode, context);
				keyBuilder.Append("|");
				keyBuilder.Append(displayInfo.DisplayMode.DisplayModeId);
				page.MasterPageFile = displayInfo.FilePath;
				page.Master.ID = "m";
				master = page.Master;
				if (stateDisplayInfo.Masters.Count > 1 && string.IsNullOrEmpty(displayInfo.DisplayMode.DisplayModeId))
					master.MasterPageFile = stateDisplayInfo.Masters[1];
				else
					masterSwitch = true;
			}
			int i = 2;
			while (master != null && !string.IsNullOrEmpty(master.MasterPageFile))
			{
				displayInfo = GetDisplayInfoForMaster(master.MasterPageFile, stateDisplayInfo.DisplayMode, context);
				keyBuilder.Append("|");
				keyBuilder.Append(displayInfo.DisplayMode.DisplayModeId);
				master.MasterPageFile = displayInfo.FilePath;
				master.Master.ID = "m";
				master = master.Master;
				if (!masterSwitch && stateDisplayInfo.Masters.Count > i && string.IsNullOrEmpty(displayInfo.DisplayMode.DisplayModeId))
					master.MasterPageFile = stateDisplayInfo.Masters[i];
				else
					masterSwitch = true;
				i++;
			}
			if (stateDisplayInfo.Theme.Length != 0)
			{
				displayInfo = GetDisplayInfoForTheme(stateDisplayInfo.Theme, stateDisplayInfo.DisplayMode, context);
				keyBuilder.Append("|");
				keyBuilder.Append(displayInfo.DisplayMode.DisplayModeId);
				page.Theme = displayInfo.FilePath;
			}
			stateDisplayInfo.DisplayModes = keyBuilder.ToString();
		}
Example #9
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;
		}