当前位置: 首页>>代码示例>>C#>>正文


C# IView.Render方法代码示例

本文整理汇总了C#中IView.Render方法的典型用法代码示例。如果您正苦于以下问题:C# IView.Render方法的具体用法?C# IView.Render怎么用?C# IView.Render使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IView的用法示例。


在下文中一共展示了IView.Render方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteResultDataToView

 public void WriteResultDataToView(IView view)
 {
     if (_result.Data != null) {
         view.Render ("Thank you! Enjoy the book");
     }
     else {
         view.Render ("That book is not available.");
     }
 }
开发者ID:joshisreedhar,项目名称:Biblotica,代码行数:9,代码来源:CheckoutCommand.cs

示例2: InjectViewInPlace

        protected IView InjectViewInPlace(string placeholder, IView view, object model)
        {
            if (placeholder != null)
            {
                var contentRendering = new ContentRendering()
                {
                    Id = new Guid(),
                    UniqueId = new Guid(),
                    Placeholder = placeholder,
                    DeviceId = PageContext.Current.Device.Id
                };

                var sw = new StringWriter();
                if (model != null) ViewData.Model = model;

                var viewConext = new ViewContext(this.ControllerContext, view, ViewData, TempData, sw);
                view.Render(viewConext, sw);
                contentRendering.Content = sw.ToString();

                var currentRenderings = PageContext.Current.PageDefinition.Renderings;
                currentRenderings.Add(contentRendering);
            }

            return PageContext.Current.PageView;
        }
开发者ID:PatriciaPecingina,项目名称:Sitecore-Mvc-Contrib,代码行数:25,代码来源:ViewInjectingController.cs

示例3: RenderViewAsString

        private string RenderViewAsString(ControllerContext context, IView view)
        {
            using (var writer = new StringWriter())
            {
                var viewContext = new ViewContext(context, view, ViewData, TempData, writer);
                view.Render(viewContext, writer);

                string output = writer.GetStringBuilder().ToString();
                if (_trimBody)
                    output = output.Trim();

                return output;
            }
        }
开发者ID:mmoore99,项目名称:ActionMailerNext,代码行数:14,代码来源:EmailResult.cs

示例4: WriteResultDataToView

 public void WriteResultDataToView(IView view)
 {
     view.Render (_result.Data as string);
 }
开发者ID:joshisreedhar,项目名称:Biblotica,代码行数:4,代码来源:ExitCommand.cs

示例5: RenderView

 string RenderView(IView view, ViewDataDictionary viewData, ControllerContext controllerContext)
 {
     using (var writer = new StringWriter())
     {
         var viewContext = new ViewContext(controllerContext, view, viewData, new TempDataDictionary(), writer);
         view.Render(viewContext, writer);
         return writer.GetStringBuilder().ToString();
     }
 }
开发者ID:mcaradec,项目名称:postal,代码行数:9,代码来源:EmailViewRenderer.cs

示例6: RenderViewToString

 /// <summary>
 /// Takes a view and renders it into an string representation.
 /// </summary>
 private string RenderViewToString(ControllerContext context, IView view, object model)
 {
     if (view == null)
     {
         return null;
     }
     StringBuilder sb = new StringBuilder();
     using (StringWriter writer = new StringWriter(sb))
     {
         ViewContext viewContext = new ViewContext(context, view, new ViewDataDictionary(model), new TempDataDictionary(), writer);
         view.Render(viewContext, writer);
         writer.Flush();
     }
     string result = sb.ToString();
     return result;
 }
开发者ID:bevacqua,项目名称:bruttissimo,代码行数:19,代码来源:StringRenderingController.cs

示例7: WriteResultDataToView

 public void WriteResultDataToView(IView view)
 {
     foreach (Book b in _result.Data as List<Book>) {
         view.Render (b.ToString ());
     }
 }
开发者ID:joshisreedhar,项目名称:Biblotica,代码行数:6,代码来源:ListCommand.cs

示例8: CreateSiteHtml

        private static async Task<string> CreateSiteHtml(IView view, IPageViewDefinition siteDefinition)
		{
			var pageHtmlBuilder = new StringBuilder();
			using (var writer = new StringWriter(pageHtmlBuilder))
			{
				var context = new RenderingContext(writer);
				context.Data.Add("pageEditor", true);
				context.Data.Add("siteDefinition", siteDefinition);

				view.Render(JObject.FromObject(siteDefinition), context);
			}

			var html = pageHtmlBuilder.ToString();

			html = html.Replace("<!DOCTYPE html>", "").Replace("<html>", "").Replace("</html>", "");
			html = new Regex("<head>(.*)</head>", RegexOptions.Singleline).Replace(html, "");
			html = new Regex("<script( src[=]\".*\")?>(.*)</script>", RegexOptions.Singleline).Replace(html, "");

			return html;
		}
开发者ID:TerrificNet,项目名称:TerrificNet,代码行数:20,代码来源:PageEditController.cs

示例9: RenderViewAsString

 /// <summary>
 /// Render the view as string
 /// </summary>
 /// <param name="context">current http context</param>
 /// <param name="view">valid view</param>
 /// <returns></returns>
 private string RenderViewAsString(ControllerContext context, IView view)
 {
     using (StringWriter sw = new StringWriter())
     {
         var viewContext = new ViewContext(context,view,ViewData,TempData,sw);
         view.Render(viewContext, sw);
         return sw.GetStringBuilder().ToString();
     }
 }
开发者ID:linuxbender,项目名称:mix-work,代码行数:15,代码来源:excelresult.cs

示例10: AssertView

        protected void AssertView( IView view, string expectedName )
        {
            Assert.IsNotNull(view, "ViewEngine does not returned a view");
            var mockViewContext = new Mock<ViewContext>();
            mockViewContext.SetupGet(x => x.View).Returns(view);
            mockViewContext.SetupGet(x => x.Controller).Returns(_controllerContext.Controller);
            mockViewContext.SetupGet(x => x.HttpContext).Returns(_controllerContext.HttpContext);
            mockViewContext.SetupGet(x => x.ViewData).Returns(new ViewDataDictionary());
            mockViewContext.SetupGet(x => x.TempData).Returns(new TempDataDictionary());
            mockViewContext.SetupGet(x => x.RouteData).Returns(_controllerContext.RouteData);
            mockViewContext.SetupGet(x => x.Writer).Returns(Output);
            view.Render(mockViewContext.Object, Output);

            AssertRender(Output, expectedName);
        }
开发者ID:peterjoh,项目名称:NHaml,代码行数:15,代码来源:TestFixtureMvcBase.cs

示例11: Respond

 public async Task<IHttpResponse> Respond(IHttpContext context, IView view)
 {
     var output = await view.Render(context, _state).ConfigureAwait(false);
     return StringHttpResponse.Create(output.Body, _code, output.ContentType);
 }
开发者ID:rancohen1,项目名称:uHttpSharp,代码行数:5,代码来源:IControllerResponse.cs

示例12: RenderView

 string RenderView(IView view, ViewDataDictionary viewData, ControllerContext controllerContext, ImageEmbedder imageEmbedder)
 {
     using (var writer = new StringWriter())
     {
         var viewContext = new ViewContext(controllerContext, view, viewData, new TempDataDictionary(), writer);
         viewData[ImageEmbedder.ViewDataKey] = imageEmbedder;
         view.Render(viewContext, writer);
         viewData.Remove(ImageEmbedder.ViewDataKey);
         return writer.GetStringBuilder().ToString();
     }
 }
开发者ID:Choulla-Naresh8264,项目名称:postal,代码行数:11,代码来源:EmailViewRenderer.cs

示例13: CaptureHtml

        /// <summary>
        /// Abstract method to capture and return HTML from the ControllerContext and RazorView
        /// </summary>
        /// <param name="controllerContext">ControllerContext of the calling Controller - contains ViewData, etc.</param>
        /// <param name="view">Instantiated RazorView</param>
        /// <returns>HTML</returns>
        protected virtual string CaptureHtml(ControllerContext controllerContext, IView view)
        {
            var builder = new StringBuilder();
            using (var stringWriter = new StringWriter(builder))
            {
                using (var htmlTextWriter = new HtmlTextWriter(stringWriter))
                {

                    // build our view context - we need this to be able to render the view and capture the output
                    var viewContext = new ViewContext(
                        controllerContext,                          // the ControllerContext we are in
                        view,                                       // the IView object - created by the RazorViewEngine above
                        GetViewData(controllerContext),             // ViewData contains the model - without this model data would not be rendered
                        GetTempData(controllerContext),             // TempData contains the Controller's TempData
                        htmlTextWriter);                            // the TextWriter the output is being written to - we control this!

                    // now render the view - because we own htmlTextWriter, we can now capture all the rendered output
                    view.Render(viewContext, htmlTextWriter);

                    // don't forget to flush!
                    htmlTextWriter.Flush();
                    stringWriter.Flush();
                }
            }
            return builder.ToString();
        }
开发者ID:GroM,项目名称:Shaver,代码行数:32,代码来源:ShaverView.cs


注:本文中的IView.Render方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。