private string renderTemplate(IRazorTemplate template, params IRazorTemplate[] templates) { var descriptor = new ViewDescriptor <IRazorTemplate>(template); var current = descriptor; for (var i = 0; i < templates.Length; ++i) { var layoutTemplate = templates[i]; var layout = new ViewDescriptor <IRazorTemplate>(layoutTemplate); layoutTemplate.Descriptor = layout; current.Master = templates[i]; current = layout; } var modifier = new ViewModifierService <IFubuRazorView>(Enumerable.Empty <IViewModifier <IFubuRazorView> >()); var viewFactory = new ViewFactory(descriptor, _templateService, modifier); var view = (IFubuRazorView)viewFactory.GetView(); view.ServiceLocator = _serviceLocator; view.RenderPartialWith = name => { var partialTemplate = _sharedTemplateLocator.LocatePartial(name, view.OriginTemplate); partialTemplate.Descriptor = new ViewDescriptor <IRazorTemplate>(partialTemplate); var partialView = _templateService.GetView(partialTemplate.Descriptor.As <ViewDescriptor <IRazorTemplate> >()); var partialRendered = partialView.Run(new ExecuteContext()); return(new TemplateWriter(x => x.Write(partialRendered))); }; return(view.Run(new ExecuteContext())); }
private string getViewSource(IRazorTemplate template) { using (var stream = new FileStream(template.FilePath, FileMode.Open)) { using (var reader = new StreamReader(stream)) { return reader.ReadToEnd(); } } }
private string getViewSource(IRazorTemplate template) { using (var stream = new FileStream(template.FilePath, FileMode.Open)) { using (var reader = new StreamReader(stream)) { return(reader.ReadToEnd()); } } }
public TemplateExtensionsTester() { var rootPath = Path.Combine(Directory.GetCurrentDirectory(), "Templates"); var bottomPath = Path.Combine(rootPath, "Finding", "Sherlock", "Homes.cshtml"); var middlePath = Path.Combine(rootPath, "Dining", "Philosophers.cshtml"); var topPath = Path.Combine(rootPath, "Livelock.cshtml"); _bottomTemplate = new Template(bottomPath, rootPath, "chuck"); _middleTemplate = new Template(middlePath, rootPath, "chuck"); _topTemplate = new Template(topPath, rootPath, "chuck"); }
public void SetUp() { var root = AppDomain.CurrentDomain.BaseDirectory; _template = new Template(Path.Combine(root, "Views", "Home", "Home.cshtml"), root, TemplateConstants.HostOrigin); _descriptor = new ViewDescriptor<IRazorTemplate>(_template) { ViewModel = typeof (ProductModel) }; _template.Descriptor = _descriptor; _token = new RazorViewToken(_template.Descriptor.As<ViewDescriptor<IRazorTemplate>>()); }
private string renderTemplate(IRazorTemplate template, params IRazorTemplate[] templates) { var descriptor = new ViewDescriptor <IRazorTemplate>(template); var current = descriptor; for (var i = 0; i < templates.Length; ++i) { var layoutTemplate = templates[i]; var layout = new ViewDescriptor <IRazorTemplate>(layoutTemplate); layoutTemplate.Descriptor = layout; current.Master = templates[i]; current = layout; } var modifier = new ViewModifierService <IFubuRazorView>(Enumerable.Empty <IViewModifier <IFubuRazorView> >()); var viewFactory = new ViewFactory(descriptor, _templateFactory, modifier); var view = (IFubuRazorView)viewFactory.GetView(); view.ServiceLocator = _serviceLocator; view.As <IRenderableView>().Render(); return(view.Result.ToString()); }
void IModelProvider.InitializeTemplate(IRazorTemplate template, IShellContext context) { template.TabularData = this; template.Name = Name; template.Schema = Schema; }
private string renderTemplate(IRazorTemplate template, params IRazorTemplate[] templates) { var descriptor = new ViewDescriptor<IRazorTemplate>(template); var current = descriptor; for (var i = 0; i < templates.Length; ++i) { var layoutTemplate = templates[i]; var layout = new ViewDescriptor<IRazorTemplate>(layoutTemplate); layoutTemplate.Descriptor = layout; current.Master = templates[i]; current = layout; } var modifier = new ViewModifierService<IFubuRazorView>(Enumerable.Empty<IViewModifier<IFubuRazorView>>()); var viewFactory = new ViewFactory(descriptor, _templateService, modifier); var view = (IFubuRazorView)viewFactory.GetView(); view.ServiceLocator = _serviceLocator; view.RenderPartialWith = name => { var partialTemplate = _sharedTemplateLocator.LocatePartial(name, view.OriginTemplate); partialTemplate.Descriptor = new ViewDescriptor<IRazorTemplate>(partialTemplate); var partialView = _templateService.GetView(partialTemplate.Descriptor.As<ViewDescriptor<IRazorTemplate>>()); var partialRendered = partialView.Run(new ExecuteContext()); return new TemplateWriter(x => x.Write(partialRendered)); }; return view.Run(new ExecuteContext()); }
public RazorModel(string project, IRazorTemplate template) { ProjectName = project; Template = template; }
void IModelProvider.InitializeTemplate(IRazorTemplate template, IShellContext context) { template.TabularData = this; }
public void InitializeTemplate(IRazorTemplate template, IShellContext context) { template.TabularData = this; }
public void InitializeTemplate(IRazorTemplate template, IShellContext context) { }
public ViewContext(IHttpContext context, IRazorTemplate template, ModelStateDictionary modelState) { _context = context; _template = template; ModelState = modelState; }
public TypeModel(TypeBase type, IEnumerable<TypeBase> types, IRazorTemplate template) : base(type.ProjectInfo.Name, template) { Type = type; Types = types; }
private string renderTemplate(IRazorTemplate template, params IRazorTemplate[] templates) { var descriptor = new ViewDescriptor<IRazorTemplate>(template); var current = descriptor; for (var i = 0; i < templates.Length; ++i) { var layoutTemplate = templates[i]; var layout = new ViewDescriptor<IRazorTemplate>(layoutTemplate); layoutTemplate.Descriptor = layout; current.Master = templates[i]; current = layout; } var modifier = new ViewModifierService<IFubuRazorView>(Enumerable.Empty<IViewModifier<IFubuRazorView>>()); var viewFactory = new ViewFactory(descriptor, _templateFactory, modifier); var view = (IFubuRazorView)viewFactory.GetView(); view.ServiceLocator = _serviceLocator; view.As<IRenderableView>().Render(); return view.Result.ToString(); }
public TypeCollectionModel(IEnumerable<TypeBase> types, IRazorTemplate template) : base(types.First().ProjectInfo.Name, template) { Types = types; }