Inheritance: System.Web.WebPages.WebPageRenderingBase
 public ResourceCapture(WebPageBase page, Action<ResourceCollection, string> callBack, ResourceCollection source, string key)
 {
     _page = page;
     _callBack = callBack;
     _resource = source;
     _key = key;
 }
Beispiel #2
0
        /// <summary>
        /// Renders the section contents.
        /// </summary>
        /// <param name="htmlHelper">The HTML helper.</param>
        /// <param name="webPage">The web page.</param>
        /// <param name="model">The model.</param>
        public static void RenderSectionContents(this HtmlHelper htmlHelper, WebPageBase webPage, RenderPageViewModel model)
        {
            foreach (var region in model.Regions)
            {
                var contentsBuilder = new StringBuilder();
                var projections = model.Contents.Where(c => c.RegionId == region.RegionId).OrderBy(c => c.Order).ToList();

                using (new LayoutRegionWrapper(contentsBuilder, region, model.CanManageContent))
                {
                    foreach (var projection in projections)
                    {
                        // Add Html
                        using (new RegionContentWrapper(contentsBuilder, htmlHelper,  projection, model.CanManageContent))
                        {
                            contentsBuilder.Append(projection.GetHtml(htmlHelper));
                        }
                    }
                }

                var html = contentsBuilder.ToString();

                if (!string.IsNullOrWhiteSpace(html))
                {
                    RenderSectionAsLayoutRegion(webPage, html, region.RegionIdentifier);
                }
            }
        }
 public Capture(WebPageBase page, Action<ResourceCollection, string> callBack, ResourcePosition position, string key)
 {
     _key = key;
     this._page = page;
     _position = position;
     _callBack = callBack;
 }
        protected override void ConfigurePage(WebPageBase parentPage)
        {
            base.ConfigurePage(parentPage);

            //Child pages need to get their context from the Parent
            Context = parentPage.Context;
        }
		/// <summary>
		/// 创建一个 razor 页面容器.
		/// </summary>
		/// <param name="page">表示页面的 WebPage 对象.</param>
		public RazorScriptHolder ( WebPageBase page )
		{

			if ( null != page && !page.PageData.ContainsKey ( "__ScriptKeys" ) )
				page.PageData["__ScriptKeys"] = new List<string> ( );

			this.page = page;
		}
Beispiel #6
0
		/// <summary>
		/// 创建一个实现 jQuery UI 交互插件的类.
		/// </summary>
		/// <param name="page">Razor 页面自身.</param>
		public JQueryRazor ( WebPageBase page )
		{

			if ( null == page )
				throw new ArgumentNullException ( "page", "页面不能为空" );

			this.page = page;
		}
        protected override void ConfigurePage(WebPageBase parentPage)
        {
            base.ConfigurePage(parentPage);
            Context = parentPage.Context;

            SkinControlWebPage parent = (SkinControlWebPage)parentPage;
            Ctl = parent.Ctl;
            Dnn = parent.Dnn;
            Html = parent.Html;
            Url = parent.Url;
        }
Beispiel #8
0
        public static T GetValueFor <T>(this WebPageBase webPageBase, string name, T defaultValue)
        {
            var nameKey = name.ToLower();

            if (webPageBase.Context.Items[nameKey] == null)
            {
                return(defaultValue);
            }
            var result = (T)webPageBase.Context.Items[nameKey];

            return(result);
        }
        public WebFormsForm(HtmlHelper helper, string formId)
        {
            _context = WebFormsMvcContext.GetCurrent(helper);
            _container = helper.ViewDataContainer as WebPageBase;
            _output = helper.ViewContext.Writer;
            if (_container != null)
            {
                _container.OutputStack.Push(_capturingWriter = new StringWriter());
            }

            _context.TryEnter(_capturingWriter, formId);
        }
Beispiel #10
0
        public string ExecutCore(string basePath, string virtualPath, WebPageBase page)
        {
            var sb = new StringBuilder();
            using (var tw = new StringWriter(sb))
            {
                var context = new HttpContextWrapper(CreateContext(basePath, virtualPath, tw));
                var pageContext = new WebPageContext(context, page, null);
                page.PushContext(pageContext, tw);
                page.Execute();
                page.PopContext();
            }

            return sb.ToString();
        }
        protected override void ConfigurePage(WebPageBase parentPage) {
            var baseViewPage = parentPage as WebViewPage;
            if (baseViewPage == null) {
                // TODO : review if this check is even necessary.
                // When this method is called by the framework parentPage should already be an instance of WebViewPage
                // Need to review what happens if this method gets called in Plan9 pointing at an MVC view
                throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, MvcResources.CshtmlView_WrongViewBase, parentPage.VirtualPath));
            }

            // Set ViewContext and ViewData here so that the layout page inherits ViewData from the main page
            ViewContext = baseViewPage.ViewContext;
            ViewData = baseViewPage.ViewData;
            InitHelpers();
        }
Beispiel #12
0
        internal static WebPageBase CreateInstanceFromVirtualPath(string virtualPath, VirtualPathFactoryManager virtualPathFactoryManager)
        {
            // Get the compiled object (through the VPP)
            try {
                WebPageBase webPage = virtualPathFactoryManager.CreateInstance <WebPageBase>(virtualPath);

                // Give it its virtual path
                webPage.VirtualPath = virtualPath;

                return(webPage);
            }
            catch (HttpException e) {
                Util.ThrowIfUnsupportedExtension(virtualPath, e);
                throw;
            }
        }
Beispiel #13
0
        private HelperResult RenderPageCore(string path, bool isLayoutPage, object[] data)
        {
            if (String.IsNullOrEmpty(path))
            {
                throw new ArgumentException(CommonResources.Argument_Cannot_Be_Null_Or_Empty, "path");
            }

            return(new HelperResult(writer =>
            {
                path = NormalizePath(path);
                WebPageBase subPage = CreatePageFromVirtualPath(path, Context, VirtualPathFactory.Exists, DisplayModeProvider, DisplayMode);
                var pageContext = CreatePageContextFromParameters(isLayoutPage, data);

                subPage.ConfigurePage(this);
                subPage.ExecutePageHierarchy(pageContext, writer);
            }));
        }
Beispiel #14
0
        private HelperResult RenderPageCore(string path, bool isLayoutPage, object[] data)
        {
            if (String.IsNullOrEmpty(path))
            {
                throw ExceptionHelper.CreateArgumentNullOrEmptyException("path");
            }

            return(new HelperResult(writer => {
                path = NormalizePath(path);
                Util.EnsureValidPageType(this, path);

                WebPageBase subPage = CreatePageFromVirtualPath(path);
                var pageContext = CreatePageContextFromParameters(isLayoutPage, data);

                subPage.ConfigurePage(this);
                subPage.ExecutePageHierarchy(pageContext, writer);
            }));
        }
Beispiel #15
0
        internal static WebPageBase CreateInstanceFromVirtualPath(string virtualPath, IVirtualPathFactory virtualPathFactory)
        {
            // Get the compiled object
            try
            {
                WebPageBase webPage = virtualPathFactory.CreateInstance <WebPageBase>(virtualPath);

                // Give it its virtual path
                webPage.VirtualPath = virtualPath;

                // Assign it the VirtualPathFactory
                webPage.VirtualPathFactory = virtualPathFactory;

                return(webPage);
            }
            catch (HttpException e)
            {
                BuildManagerExceptionUtil.ThrowIfUnsupportedExtension(virtualPath, e);
                throw;
            }
        }
Beispiel #16
0
        internal static void EnsureValidPageType(WebPageBase page, string virtualPath)
        {
            bool error = true;

            try {
                if (page.FileExists(virtualPath))
                {
                    var factory = page.GetObjectFactory(virtualPath);
                    if (factory != null)
                    {
                        var result = factory();
                        if (result != null && typeof(WebPageBase).IsAssignableFrom(result.GetType()))
                        {
                            error = false;
                        }
                    }
                }
            }
            catch (HttpException e) {
                // If the path uses an unregistered extension, such as Foo.txt,
                // then an error regarding build providers will be thrown.
                // Check if this is the case and throw a simpler error.
                ThrowIfUnsupportedExtension(virtualPath, e);

                // If the path uses an extension registered with codedom, such as Foo.js,
                // then an unfriendly compilation error might get thrown by the underlying compiler.
                // Check if this is the case and throw a simpler error.
                ThrowIfCodeDomDefinedExtension(virtualPath, e);

                // Rethrow any errors
                throw;
            }

            if (error)
            {
                // The page is missing, could not be compiled or is of an invalid type.
                throw new HttpException(String.Format(CultureInfo.CurrentCulture, WebPageResources.WebPage_InvalidPageType, virtualPath));
            }
        }
Beispiel #17
0
 public static void SetLayoutWithContainer(this WebPageBase webPageBase, bool value)
 {
     webPageBase.SetValueFor("LayoutWithContainer", value);
 }
 public StyleRegister(WebPageBase page, Action<ResourceCollection, string> callBack)
     : base(page, callBack)
 {
 }
 protected virtual void ConfigurePage(WebPageBase parentPage)
 {
 }
 public static WebPagesBootstrapHelper Bootstrap(this HtmlHelper htmlHelper, WebPageBase webPageBase)
 {
     return new WebPagesBootstrapHelper(webPageBase);
 }
        private bool Validate(WebPageBase webPageBase)
        {
            var razorFunction = webPageBase as RazorFunction;
            if (razorFunction == null)
            {
                ShowWarning(GetText("EditRazorFunctionWorkflow.Validation.IncorrectBaseClass")
                            .FormatWith(typeof(RazorFunction).FullName));
                return false;
            }


            return true;
        }
Beispiel #22
0
 public static void SetAngularSupport(this WebPageBase webPageBase, bool value)
 {
     webPageBase.SetValueFor("AngularSupport", value);
 }
 public void RazorRender(WebPageBase Webpage, TextWriter writer, dynamic model)
 {
     var HttpContext = new HttpContextWrapper(System.Web.HttpContext.Current);
     if ((Webpage) is DotNetNukeWebPage<dynamic>)
     {
         var mv = (DotNetNukeWebPage<dynamic>)Webpage;
         mv.Model = model;
     }
     if (Webpage != null)
         Webpage.ExecutePageHierarchy(new WebPageContext(HttpContext, Webpage, null), writer, Webpage);
 }
Beispiel #24
0
 protected virtual void ConfigurePage(WebPageBase parentPage)
 {
 }
Beispiel #25
0
 public static void SetShowBreadcrumbs(this WebPageBase webPageBase, bool value)
 {
     webPageBase.SetValueFor("ShowBreadcrumbs", value);
 }
Beispiel #26
0
 public static bool GetLayoutWithContainer(this WebPageBase webPageBase, bool defaultValue = true)
 {
     return(webPageBase.GetValueFor("LayoutWithContainer", defaultValue));
 }
Beispiel #27
0
 public static bool GetDebugMode(this WebPageBase webPageBase)
 {
     //todo read from context
     return(webPageBase.GetValueFor("DebugMode", true));
 }
Beispiel #28
0
 public static void SetDebugMode(this WebPageBase webPageBase, bool value)
 {
     webPageBase.SetValueFor("DebugMode", value);
 }
Beispiel #29
0
 public static bool GetShowBreadcrumbs(this WebPageBase webPageBase, bool defaultValue = true)
 {
     return(webPageBase.GetValueFor("ShowBreadcrumbs", defaultValue));
 }
        internal bool LoadRazorTemplate(
            string virtualPath,
            out WebPageBase webPage,
            out PageTemplateDescriptor parsedTemplate,
            out IDictionary<string, PropertyInfo> placeholderProperties,
            out Exception loadingException)
        {
            try
            {
                webPage = WebPageBase.CreateInstanceFromVirtualPath(virtualPath);
            }
            catch(Exception ex)
            {
                Log.LogError(LogTitle, "Failed to compile razor file '{0}'", virtualPath);
                Log.LogError(LogTitle, ex);

                loadingException = ex is TargetInvocationException ? ex.InnerException : ex;

                webPage = null;
                parsedTemplate = null;
                placeholderProperties = null;
                return false;
            }

            if (webPage == null || !(webPage is RazorPageTemplate))
            {
                parsedTemplate = null;
                placeholderProperties = null;
                loadingException = null;
                return true;
            }

            RazorPageTemplate razorPageTemplate = webPage as RazorPageTemplate;
            razorPageTemplate.Configure();

            try
            {
                ParseTemplate(virtualPath, razorPageTemplate, out parsedTemplate, out placeholderProperties);
            }
            catch (Exception ex)
            {
                Log.LogError(LogTitle, "Failed to load razor page template '{0}'", virtualPath);
                Log.LogError(LogTitle, ex);

                loadingException = ex;
                parsedTemplate = null;
                placeholderProperties = null;
                return false;
            }
            finally
            {
                razorPageTemplate.Dispose();
            }

            loadingException = null;
            return true;
        }
 public static void WriteLiteralTo(TextWriter writer, object value)
 {
     WebPageBase.WriteLiteralTo(writer, value);
 }
 protected ResourceRegister(WebPageBase page, Action<ResourceCollection, string> callBack)
 {
     this._page = page;
     _callBack = callBack;
 }
 public static void WriteLiteralTo(TextWriter writer, HelperResult value)
 {
     WebPageBase.WriteLiteralTo(writer, value);
 }
Beispiel #34
0
 private static void RenderSectionAsLayoutRegion(WebPageBase webPage, string partialViewHtml, string sectionName)
 {
     webPage.DefineSection(
         sectionName,
         () =>
         {
             Action<TextWriter> writerAction = tw => tw.Write(partialViewHtml);
             var result = new HelperResult(writerAction);
             webPage.Write(result);
         });
 }
 public WebPagesBootstrapConfig(WebPageBase webPageBase)
 {
     WebPageBase = webPageBase;
 }
Beispiel #36
0
 public static bool GetAngularSupport(this WebPageBase webPageBase, bool defaultValue = true)
 {
     return(webPageBase.GetValueFor("AngularSupport", defaultValue));
 }
Beispiel #37
0
        public static void SetValueFor <T>(this WebPageBase webPageBase, string name, T value)
        {
            var nameKey = name.ToLower();

            webPageBase.Context.Items[nameKey] = value;
        }