コード例 #1
0
        /// <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);
        }
コード例 #2
0
ファイル: ShapeFigure.cs プロジェクト: heng222/MyRepository
        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);
        }
コード例 #3
0
        /// <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));
        }
コード例 #4
0
        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);
        }
コード例 #5
0
 public DataDirectory(VirtualLocation loc) : base(loc)
 {
 }