Пример #1
0
        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()));
        }
Пример #2
0
 private string getViewSource(IRazorTemplate template)
 {
     using (var stream = new FileStream(template.FilePath, FileMode.Open))
     {
         using (var reader = new StreamReader(stream))
         {
             return reader.ReadToEnd();
         }
     }
 }
Пример #3
0
 private string getViewSource(IRazorTemplate template)
 {
     using (var stream = new FileStream(template.FilePath, FileMode.Open))
     {
         using (var reader = new StreamReader(stream))
         {
             return(reader.ReadToEnd());
         }
     }
 }
Пример #4
0
        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 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");
        }
Пример #6
0
        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>>());
        }
Пример #7
0
        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());
        }
Пример #8
0
 void IModelProvider.InitializeTemplate(IRazorTemplate template, IShellContext context)
 {
     template.TabularData = this;
     template.Name        = Name;
     template.Schema      = Schema;
 }
Пример #9
0
        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());
        }
Пример #10
0
 public RazorModel(string project, IRazorTemplate template)
 {
     ProjectName = project;
     Template = template;
 }
Пример #11
0
 void IModelProvider.InitializeTemplate(IRazorTemplate template, IShellContext context)
 {
     template.TabularData = this;
 }
Пример #12
0
 public void InitializeTemplate(IRazorTemplate template, IShellContext context)
 {
     template.TabularData = this;
 }
Пример #13
0
 void IModelProvider.InitializeTemplate(IRazorTemplate template, IShellContext context)
 {
     template.TabularData = this;
 }
Пример #14
0
 public void InitializeTemplate(IRazorTemplate template, IShellContext context)
 {
 }
Пример #15
0
		public ViewContext(IHttpContext context, IRazorTemplate template, ModelStateDictionary modelState)
		{
			_context = context;
			_template = template;
			ModelState = modelState;
		}
Пример #16
0
 public TypeModel(TypeBase type, IEnumerable<TypeBase> types, IRazorTemplate template)
     : base(type.ProjectInfo.Name, template)
 {
     Type = type;
     Types = types;
 }
Пример #17
0
 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, _templateFactory, modifier);
            var view = (IFubuRazorView)viewFactory.GetView();
            view.ServiceLocator = _serviceLocator;
            view.As<IRenderableView>().Render();
            return view.Result.ToString();
        }
Пример #19
0
 public void InitializeTemplate(IRazorTemplate template, IShellContext context)
 {
     template.TabularData = this;
 }
Пример #20
0
 public TypeCollectionModel(IEnumerable<TypeBase> types, IRazorTemplate template)
     : base(types.First().ProjectInfo.Name, template)
 {
     Types = types;
 }