internal static T CurrentItem <T>(this RequestContext context, string key) where T : ContentItem { if (context == null) { throw new ArgumentNullException("context"); } return(context.RouteData.DataTokens[key] as T ?? context.RouteData.Values.CurrentItem <T>(key, RouteExtensions.GetEngine(context.RouteData).Persister)); }
protected virtual void SetPathOverride(ActionExecutingContext filterContext) { if (content == null && ControllerContext != null && ControllerContext.IsChildAction && ControllerContext.ParentActionViewContext != null && ControllerContext.ParentActionViewContext.RouteData.DataTokens.ContainsKey(PathOverrideKey)) { // bypass normal retrieval to handle rendering of auto-generated parts wihtout ID var path = ControllerContext.ParentActionViewContext.RouteData.DataTokens[PathOverrideKey] as PathData; if (path != null) { content = new ControllerContentHelper(() => RouteExtensions.GetEngine(RouteData), () => path); } } }
public static ContentItem StartPage(this RequestContext context) { return(Find.ClosestOf <IStartPage>(context.RouteData.CurrentPath().CurrentItem) ?? RouteExtensions.GetEngine(context.RouteData).Content.Traverse.StartPage); }