本文整理汇总了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();
}
示例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));
}
示例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));
}
示例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;
}
示例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"]);
}