コード例 #1
0
ファイル: StubViewFactory.cs プロジェクト: bbarry/spark
        public void RenderView(StubViewContext viewContext)
        {
            var descriptor = new SparkViewDescriptor();
            descriptor.Templates.Add(viewContext.ControllerName + "\\" + viewContext.ViewName + ".spark");
            if (viewContext.MasterName != null)
                descriptor.Templates.Add("Shared\\" + viewContext.MasterName + ".spark");

            var sparkView = Engine.CreateInstance(descriptor);
            ((StubSparkView)sparkView).ViewData = viewContext.Data;
            sparkView.RenderView(new StringWriter(viewContext.Output));
        }
コード例 #2
0
ファイル: StubViewFactory.cs プロジェクト: Eilon/spark
        public void RenderView(StubViewContext viewContext, string extension = null)
        {
            var descriptor = new SparkViewDescriptor();
            descriptor.Templates.Add(Path.Combine(viewContext.ControllerName, viewContext.ViewName + (extension ?? Constants.DotSpark)));
            if (viewContext.MasterName != null)
                descriptor.Templates.Add(Path.Combine(Constants.Shared, viewContext.MasterName + (extension ?? Constants.DotSpark)));

            var sparkView = Engine.CreateInstance(descriptor);
            ((StubSparkView)sparkView).ViewData = viewContext.Data;
            ((StubSparkView)sparkView).CacheService = CacheService;
            sparkView.RenderView(new StringWriter(viewContext.Output));
        }
コード例 #3
0
ファイル: StubViewFactory.cs プロジェクト: yhtsnda/spark
        public void RenderView(StubViewContext viewContext)
        {
            var descriptor = new SparkViewDescriptor();

            descriptor.Templates.Add(viewContext.ControllerName + "\\" + viewContext.ViewName + ".spark");
            if (viewContext.MasterName != null)
            {
                descriptor.Templates.Add("Shared\\" + viewContext.MasterName + ".spark");
            }

            var sparkView = Engine.CreateInstance(descriptor);

            ((StubSparkView)sparkView).ViewData     = viewContext.Data;
            ((StubSparkView)sparkView).CacheService = CacheService;
            sparkView.RenderView(new StringWriter(viewContext.Output));
        }
コード例 #4
0
        public void RenderView(StubViewContext viewContext, string extension = null)
        {
            var descriptor = new SparkViewDescriptor();

            descriptor.Templates.Add(Path.Combine(viewContext.ControllerName, viewContext.ViewName + (extension ?? Constants.DotSpark)));
            if (viewContext.MasterName != null)
            {
                descriptor.Templates.Add(Path.Combine(Constants.Shared, viewContext.MasterName + (extension ?? Constants.DotSpark)));
            }

            var sparkView = Engine.CreateInstance(descriptor);

            ((StubSparkView)sparkView).ViewData     = viewContext.Data;
            ((StubSparkView)sparkView).CacheService = CacheService;
            sparkView.RenderView(new StringWriter(viewContext.Output));
        }
コード例 #5
0
 private string Render(string viewName, StubViewData viewData)
 {
     var context = new StubViewContext { ControllerName = "home", ViewName = viewName, Output = new StringBuilder(), Data = viewData };
     _factory.RenderView(context);
     return context.Output.ToString()
         .Replace("\r\n\r\n", "\r\n")
         .Replace("\r\n\r\n", "\r\n");
 }