当前位置: 首页>>代码示例>>C#>>正文


C# NavigationData.Add方法代码示例

本文整理汇总了C#中NavigationData.Add方法的典型用法代码示例。如果您正苦于以下问题:C# NavigationData.Add方法的具体用法?C# NavigationData.Add怎么用?C# NavigationData.Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NavigationData的用法示例。


在下文中一共展示了NavigationData.Add方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DeterminePostBackMode

		/// <summary>
		/// Validates the incoming Url and if no <see cref="Navigation.NavigationSettings.StateIdKey"/> 
		/// found will navigate to the <see cref="Navigation.Dialog"/> whose path property matches the Url
		/// </summary>
		/// <returns>A <see cref="System.Collections.Specialized.NameValueCollection"/> of the 
		/// postback variables, if any; otherwise null</returns>
		/// <exception cref="Navigation.UrlException">The <see cref="Navigation.NavigationSettings.StateIdKey"/>
		/// is not found and the Url does not match the path of any <see cref="Navigation.Dialog"/>; the page of 
		/// the <see cref="Navigation.State"/> does not match the Url path</exception>
		public override NameValueCollection DeterminePostBackMode()
		{
			if (IsLogin() || !HttpContext.Current.Handler.GetType().IsSubclassOf(typeof(Page))
				|| StateInfoConfig.Dialogs == null || StateInfoConfig.Dialogs.Count == 0)
				return base.DeterminePostBackMode();
#if NET40Plus
			StateContext.StateId = Page.Request.QueryString[NavigationSettings.Config.StateIdKey] ?? (string)Page.RouteData.DataTokens[NavigationSettings.Config.StateIdKey];
#else
			StateContext.StateId = Page.Request.QueryString[NavigationSettings.Config.StateIdKey];
#endif
			if (StateContext.StateId == null)
			{
				if (_DialogPaths.ContainsKey(Page.AppRelativeVirtualPath.ToUpperInvariant()))
				{
					NavigationData data = new NavigationData();
					foreach (string key in Page.Request.QueryString)
						data.Add(key, Page.Request.QueryString[key]);
					StateController.Navigate(_DialogPaths[Page.AppRelativeVirtualPath.ToUpperInvariant()].Key, data);
				}
#if NET40Plus
				if (Page.RouteData.Route != null)
					return base.DeterminePostBackMode();
#endif
				throw new UrlException(Resources.InvalidUrl);
			}
			if (StateContext.State == null)
			{
				StateContext.StateId = null;
				throw new UrlException(Resources.InvalidUrl);
			}
#if NET40Plus
			Route route = Page.RouteData.Route as Route;
			if (StringComparer.OrdinalIgnoreCase.Compare(StateContext.State.Page, Page.AppRelativeVirtualPath) != 0
				&& StringComparer.OrdinalIgnoreCase.Compare(StateContext.State.MobilePage, Page.AppRelativeVirtualPath) != 0
				&& (route == null || StringComparer.OrdinalIgnoreCase.Compare(StateContext.State.Route, route.Url) != 0))
#else
			if (StringComparer.OrdinalIgnoreCase.Compare(StateContext.State.Page, Page.AppRelativeVirtualPath) != 0
				&& StringComparer.OrdinalIgnoreCase.Compare(StateContext.State.MobilePage, Page.AppRelativeVirtualPath) != 0)
#endif
			{
				throw new UrlException(Resources.InvalidUrl);
			}
			Page.PreInit += Page_PreInit;
			return base.DeterminePostBackMode();
		}
开发者ID:ericziko,项目名称:navigation,代码行数:54,代码来源:StateAdapter.cs

示例2: BeginRefreshLink

		/// <summary>
		/// Returns an anchor element (a element) with its href attribute set from a call to
		/// <see cref="StateController.GetRefreshLink(NavigationData)"/>
		/// </summary>
		/// <param name="htmlHelper">The HTML helper instance that this method extends</param>
		/// <param name="toData">The <see cref="NavigationData"/> to be passed to the current
		/// <see cref="State"/> and stored in the <see cref="StateContext"/></param>
		/// <param name="currentDataKeys">A comma separated list of current data items to
		/// include together with the <paramref name="toData"/></param>
		/// <param name="writer">The text writer the HTML is written to</param>
		/// <param name="htmlAttributes">An object that contains the HTML attributes to set for the
		/// element</param>
		/// <returns>An anchor element (a element)</returns>
		public static RefreshLink BeginRefreshLink(this HtmlHelper htmlHelper, NavigationData toData, string currentDataKeys, TextWriter writer = null, object htmlAttributes = null)
		{
			var currentKeys = htmlHelper.GetCurrentKeys(currentDataKeys);
			var data = new NavigationData(currentKeys);
			if (toData != null)
				data.Add(toData);
			return GenerateRefreshLink(htmlHelper, StateController.GetRefreshLink(data), writer, htmlAttributes, false, string.Join(",", currentKeys), htmlHelper.GetToKeys(toData));
		}
开发者ID:ericziko,项目名称:navigation,代码行数:21,代码来源:LinkExtensions.cs

示例3: RefreshLink

		/// <summary>
		/// Returns an anchor element (a element) with its href attribute set from a call to
		/// <see cref="StateController.GetRefreshLink(NavigationData)"/>
		/// </summary>
		/// <param name="htmlHelper">The HTML helper instance that this method extends</param>
		/// <param name="linkText">The inner text of the anchor element</param>
		/// <param name="toData">The <see cref="NavigationData"/> to be passed to the current
		/// <see cref="State"/> and stored in the <see cref="StateContext"/></param>
		/// <param name="currentDataKeys">A comma separated list of current data items to
		/// include together with the <paramref name="toData"/></param>
		/// <param name="htmlAttributes">An object that contains the HTML attributes to set for the
		/// element</param>
		/// <returns>An anchor element (a element)</returns>
		/// <exception cref="System.ArgumentException"><paramref name="linkText"/> is null or empty; or
		/// there is <see cref="NavigationData"/> that cannot be converted to a <see cref="System.String"/></exception>
		public static MvcHtmlString RefreshLink(this HtmlHelper htmlHelper, string linkText, NavigationData toData, string currentDataKeys, object htmlAttributes = null)
		{
			var currentKeys = htmlHelper.GetCurrentKeys(currentDataKeys);
			var data = new NavigationData(currentKeys);
			if (toData != null)
				data.Add(toData);
			return GenerateLink(htmlHelper, linkText, StateController.GetRefreshLink(data), htmlAttributes, true, false, string.Join(",", currentKeys), htmlHelper.GetToKeys(toData));
		}
开发者ID:ericziko,项目名称:navigation,代码行数:23,代码来源:LinkExtensions.cs

示例4: ParseReturnData

		private static NavigationData ParseReturnData(string returnData, State state)
		{
			NavigationData navData = new NavigationData();
			string[] nameValuePair;
			string[] returnDataArray = Regex.Split(returnData, RET_3_SEP);
			for (int i = 0; i < returnDataArray.Length; i++)
			{
				nameValuePair = Regex.Split(returnDataArray[i], RET_1_SEP);
				navData.Add(DecodeURLValue(nameValuePair[0]), ParseURLString(DecodeURLValue(nameValuePair[0]), nameValuePair[1], state));
			}
			return navData;
		}
开发者ID:ericziko,项目名称:navigation,代码行数:12,代码来源:CrumbTrailManager.cs

示例5: NavigateOverrideDefaultsViewStateTest

		public void NavigateOverrideDefaultsViewStateTest()
		{
			StateController.Navigate("d3");
			StateController.Navigate("t0");
			NavigationData data = new NavigationData();
			data["DateTime"] = new DateTime(1990, 3, 1, 12, 35, 47);
			data.Add("double", "");
			data.Add("byte", '2');
			data.Add("char", (byte)0);
			StateController.Navigate("t0", data);
			data = new NavigationData();
			((IStateManager)data).LoadViewState(((IStateManager)StateContext.Data).SaveViewState());
			Assert.IsNull(data["decimal"]);
			Assert.IsNull(data["double"]);
			Assert.IsNull(data["DateTime"]);
			Assert.IsNull(data["emptyString"]);
			Assert.AreEqual('2', data["byte"]);
			Assert.AreEqual((byte)0, data["char"]);
		}
开发者ID:ericziko,项目名称:navigation,代码行数:19,代码来源:NavigationDataTest.cs


注:本文中的NavigationData.Add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。