Exemple #1
0
        public ComponentInstance Find(PageInstance page, IEnumerable <int> path)
        {
            if (!path.Any() || page.Components.Count() < path.First())
            {
                throw new KolaException("No component at specified path");
            }

            return(page.Components.ElementAt(path.First()).Accept(this, path.Skip(1)));
        }
 public IResult Render(PageInstance component)
 {
     return this.inner.Render(component);
 }
 public IResult Render(PageInstance page)
 {
     throw new NotImplementedException();
 }
Exemple #4
0
 public IResult Render(PageInstance page)
 {
     return new CompositeResult(page.Components.Select(c => c.Render(this)));
 }
Exemple #5
0
        public void SetUp()
        {
            var atom1Specification = MockRepository.GenerateStub<IPluginComponentSpecification<IComponentWithProperties>>();
            var atom2Specification = MockRepository.GenerateStub<IPluginComponentSpecification<IComponentWithProperties>>();
            var atom3Specification = MockRepository.GenerateStub<IPluginComponentSpecification<IComponentWithProperties>>();
            var containerSpecification = MockRepository.GenerateStub<IPluginComponentSpecification<IComponentWithProperties>>();

            var renderingInstructions = MockRepository.GenerateStub<IRenderingInstructions>();

            atom1Specification.ViewName = "Atom1View";
            atom2Specification.ViewName = "Atom2View";
            atom3Specification.ViewName = "Atom3View";
            containerSpecification.ViewName = "Container1View";

            var handlerFactory = MockRepository.GenerateStub<IRendererFactory>();
            handlerFactory.Stub(h => h.GetAtomRenderer("atom1")).Return(new DefaultRenderer(atom1Specification));
            handlerFactory.Stub(h => h.GetAtomRenderer("atom2")).Return(new DefaultRenderer(atom2Specification));
            handlerFactory.Stub(h => h.GetAtomRenderer("atom3")).Return(new DefaultRenderer(atom3Specification));
            handlerFactory.Stub(h => h.GetContainerRenderer("container1")).Return(new DefaultRenderer(containerSpecification));

            var renderer = new MultiRenderer(handlerFactory);

            KolaConfigurationRegistry.RegisterRenderer(renderer);

            var page =
                new PageInstance(
                    new ComponentInstance[]
                        {
                            new AtomInstance(new[] { 0 }, renderingInstructions, "atom1", Enumerable.Empty<PropertyInstance>()),
                            new AtomInstance(new[] { 1 }, renderingInstructions, "atom2", Enumerable.Empty<PropertyInstance>()),
                            new ContainerInstance(new[] { 2 }, renderingInstructions, "container1", null, new[] { new AtomInstance(new[] { 2, 0 }, renderingInstructions, "atom3", Enumerable.Empty<PropertyInstance>()) })
                        }, renderingInstructions);

            var viewFactory = new TestViewFactory(renderer);
            var viewHelper = new TestViewHelper(viewFactory);

            var renderedPage = renderer.Render(page);
            this.result = renderedPage.ToHtml(viewHelper);
        }