/// <summary> /// Resolves the URL. /// </summary> /// <param name="path">The path.</param> /// <param name="normalize">if set to <c>true</c> normalize the url, i.e., replace the root operator with the application root and resolve relative path jumps (like '..').</param> /// <returns></returns> public virtual string ResolveUrl(string path, bool normalize = true) { if (path.NullOrEmpty() || path[0] == '/' || path.Contains(":")) { return(path); } var args = string.Empty; var argIndex = path.IndexOf('?'); if (argIndex >= 0) { args = path.Substring(argIndex, path.Length - argIndex); path = path.Substring(0, argIndex); } else { argIndex = path.IndexOf('#'); if (argIndex >= 0) { args = path.Substring(argIndex, path.Length - argIndex); path = path.Substring(0, argIndex); } } var builder = VirtualLocation.CombineWith(path); if (normalize) { builder.Normalize(); } return(builder + args); }
public override void PaintFigure(Graphics g, Rectangle bounds) { Point offset = VirtualLocation.PointSubPoint(bounds.Location); Rectangle rect = new Rectangle(offset, _virtualBounds.Size); ComputePlayerBound(rect, SignSize); PaintFigure(g, rect, DrawingColor, DrawingFilledColor, Type, _borderWidth * Zoom); }
/// <summary> /// Renders the requested page. Optionally you may pass a specific model. By default the current model is used by the rendered page /// </summary> /// <param name="virtualPath">The virtual path of the page that must be rendered.</param> /// <param name="model">The model.</param> /// <param name="skipLayout">if set to <c>true</c> the any layout setting is ignored</param> /// <returns></returns> public virtual LiteralString RenderPage(string virtualPath, object model = null, bool skipLayout = false) { ITemplateController @this = this; var page = @this.RazorContext.TemplateFactory.CreateTemplateInstance(VirtualLocation.CombineWith(virtualPath)).CastTo <ITemplateController>(); page.SetModel(model ?? Model); page.SetParent(@this); page.Execute(); if (!skipLayout) { page.TryApplyLayout(); } return(new LiteralString(page.Result)); }
ITemplateController ITemplateController.TryApplyLayout() { if (Layout.NullOrEmpty()) { return(this); } var layoutPath = VirtualLocation.CombineWith(Layout).Normalize(); var layoutTemplate = RazorContext .TemplateFactory .CreateTemplateInstance(layoutPath) .CastTo <ITemplateController>(); this.CastTo <ITemplateController>().ApplyLayout(layoutTemplate); return(this); }
public DataDirectory(VirtualLocation loc) : base(loc) { }