Exemplo n.º 1
0
        public void Save(WidgetSpecification widgetSpecification)
        {
            var surrogate = new WidgetSpecificationSurrogateBuilder().Build(widgetSpecification);
            var path      = Path.Combine(WidgetsDirectory, widgetSpecification.Name + ".xml");

            this.serializationHelper.Serialize <WidgetSpecificationSurrogate>(surrogate, path);
        }
        /*
         * == given specifications ==
         * Widget specification 1
         * ├─ Atom
         * ├─ Placeholder
         * └─ Container
         *    └─ Placeholder
         *
         * Widget specification 2
         * ├─ Atom
         * └─ Placeholder
         *
         * == and widget template ==
         * Widget (widget specification 1)
         * ├─ Area
         * │  └─ Atom
         * └─ Area
         *    ├─ Atom
         *    ├─ Atom
         *    └─ Widget (widget specification 2)
         *       └─ Area
         *          └─ Atom
         *
         * == should build to ==
         * WidgetInstance (widget specification 1)
         * ├─ AtomInstance
         * ├─ PlaceholderInstance
         * │  └─ AtomInstance
         * └─ ContainerInstance
         *    └─ PlaceholderInstance
         *       ├─ AtomInstance
         *       ├─ AtomInstance
         *       └─ WidgetInstance (widget specification 2)
         *          ├─ AtomInstance
         *          └─ PlaceholderInstance
         *             └─ Atom
         */
        public void SetUp()
        {
            var specification1 = new WidgetSpecification(
                "widget 1",
                Enumerable.Empty <PropertySpecification>(),
                new IComponent[]
            {
                new Atom("atom", Enumerable.Empty <Property>()),
                new Placeholder("area 1"),
                new Container(
                    "container",
                    Enumerable.Empty <Property>(),
                    new[] { new Placeholder("area 2") })
            });

            var specification2 = new WidgetSpecification(
                "widget 2",
                Enumerable.Empty <PropertySpecification>(),
                new IComponent[]
            {
                new Atom("atom", Enumerable.Empty <Property>()),
                new Placeholder("area 1")
            });

            var widget = new Widget(
                "widget 1",
                new[]
            {
                new Area(
                    "area 1",
                    new IComponent[]
                {
                    new Atom("atom", Enumerable.Empty <Property>())
                }),
                new Area(
                    "area 2",
                    new IComponent[]
                {
                    new Atom("atom", Enumerable.Empty <Property>()),
                    new Atom("atom", Enumerable.Empty <Property>()),
                    new Widget(
                        "widget 2",
                        new[]
                    {
                        new Area(
                            "area 1",
                            new[]
                        {
                            new Atom("atom", Enumerable.Empty <Property>())
                        })
                    })
                })
            });

            var buildContext = new BuildData(Enumerable.Empty <IContextItem>());

            var builder = new Builder(RenderingInstructions.BuildForPreview(), n => n == "widget 1" ? specification1 : specification2, null);

            this.instance = (WidgetInstance)widget.Build(builder, new[] { 0 }, buildContext);
        }
        public void SetUp()
        {
            var placeholder1        = new Placeholder("area 1");
            var placeholder2        = new Placeholder("area 2");
            var widgetSpecification = new WidgetSpecification("widget");

            widgetSpecification.Insert(0, placeholder1);
            widgetSpecification.Insert(1, placeholder2);

            var area   = new Area("area 1");
            var widget = new Widget("widget", new[] { area });

            var buildContext = new BuildData(Enumerable.Empty <IContextItem>());

            var builder = new Builder(RenderingInstructions.BuildForPreview(), w => widgetSpecification, null);

            var instance = widget.Build(builder, new[] { 0 }, buildContext);

            var rendererFactory = MockRepository.GenerateStub <IRendererFactory>();

            this.viewHelper = MockRepository.GenerateStub <IViewHelper>();
            var multiRenderer = new MultiRenderer(rendererFactory);

            KolaConfigurationRegistry.RegisterRenderer(multiRenderer);

            this.result = instance.Render(multiRenderer);
        }
        public void Save(WidgetSpecification widgetSpecification)
        {
            var surrogate = new WidgetSpecificationSurrogateBuilder().Build(widgetSpecification);
            var path = Path.Combine(WidgetsDirectory, widgetSpecification.Name + ".xml");

            this.serializationHelper.Serialize<WidgetSpecificationSurrogate>(surrogate, path);
        }
        public void SetUp()
        {
            var atom = new Atom(
                "atom",
                new[] { new Property("property-name", "property-type", new InheritedPropertyValue("property-alias")) });

            var containerSpecification = new ContainerSpecification("container");
            var container = containerSpecification.Create();
            container.Insert(0, atom);

            var widgetSpecification = new WidgetSpecification(
                "widget",
                new[] { new PropertySpecification("property-alias", "property-type", string.Empty) },
                new[] { container });

            var buildContext = new BuildData(Enumerable.Empty<IContextItem>());

            var widget = widgetSpecification.Create();
            widget.FindOrCreateProperty(new PropertySpecification("property-alias", "property-type", string.Empty));
            widget.Properties.Single().Value = new FixedPropertyValue("property-value");

            var builder = new Builder(RenderingInstructions.BuildForPreview(), w => widgetSpecification, null);

            this.instance = widget.Build(builder, new[] { 0 }, buildContext);
        }
Exemplo n.º 7
0
        public void SetUp()
        {
            var atom = new Atom(
                "atom",
                new[] { new Property("property-name", "property-type", new InheritedPropertyValue("property-alias")) });

            var containerSpecification = new ContainerSpecification("container");
            var container = containerSpecification.Create();

            container.Insert(0, atom);

            var widgetSpecification = new WidgetSpecification(
                "widget",
                new[] { new PropertySpecification("property-alias", "property-type", string.Empty) },
                new[] { container });

            var buildContext = new BuildData(Enumerable.Empty <IContextItem>());

            var widget = widgetSpecification.Create();

            widget.FindOrCreateProperty(new PropertySpecification("property-alias", "property-type", string.Empty));
            widget.Properties.Single().Value = new FixedPropertyValue("property-value");

            var builder = new Builder(RenderingInstructions.BuildForPreview(), w => widgetSpecification, null);

            this.instance = widget.Build(builder, new[] { 0 }, buildContext);
        }
        public void SetUp()
        {
            this.widgetSpecification = new WidgetSpecification("widgetName");
            var placeholder = new Placeholder("area 1");

            this.widgetSpecification.Insert(0, placeholder);
        }
Exemplo n.º 9
0
        public void SetUp()
        {
            var specification = new WidgetSpecification(
                "widget name",
                Enumerable.Empty<PropertySpecification>(),
                new IComponent[]
                    {
                        new Atom("atom", Enumerable.Empty<Property>()),
                        new Placeholder("area 1"),
                        new Container("container", Enumerable.Empty<Property>(), new[] { new Placeholder("area 2") })
                    });

            var widget = new Widget(
                "widget name",
                new[]
                    {
                        new Area("area 1", new IComponent[] { new Atom("atom", Enumerable.Empty<Property>()), new Atom("atom", Enumerable.Empty<Property>()) }),
                        new Area("area 2", new IComponent[] { new Atom("atom", Enumerable.Empty<Property>()), new Atom("atom", Enumerable.Empty<Property>()), new Atom("atom", Enumerable.Empty<Property>()) })
                    });

            var buildContext = new BuildData(Enumerable.Empty<IContextItem>());

            var builder = new Builder(RenderingInstructions.BuildForPreview(), n => specification, null);

            this.instance = (WidgetInstance)widget.Build(builder, new[] { 0 }, buildContext);
        }
        public void SetUp()
        {
            var placeholder1 = new Placeholder("area 1");
            var placeholder2 = new Placeholder("area 2");
            var widgetSpecification = new WidgetSpecification("widget");
            widgetSpecification.Insert(0, placeholder1);
            widgetSpecification.Insert(1, placeholder2);

            var area = new Area("area 1");
            var widget = new Widget("widget", new[] { area });

            var buildContext = new BuildData(Enumerable.Empty<IContextItem>());

            var builder = new Builder(RenderingInstructions.BuildForPreview(), w => widgetSpecification, null);

            var instance = widget.Build(builder, new[] { 0 }, buildContext);

            var rendererFactory = MockRepository.GenerateStub<IRendererFactory>();
            this.viewHelper = MockRepository.GenerateStub<IViewHelper>();
            var multiRenderer = new MultiRenderer(rendererFactory);

            KolaConfigurationRegistry.RegisterRenderer(multiRenderer);

            this.result = instance.Render(multiRenderer);
        }
        public void SetUp()
        {
            var widgetSpecification = new WidgetSpecification("widget");
            widgetSpecification.Insert(0, new Placeholder("area 1"));
            widgetSpecification.Insert(1, new Placeholder("area 2"));

            this.widget = widgetSpecification.Create();
        }
        public void SetUp()
        {
            var widgetSpecification = new WidgetSpecification("widget");

            widgetSpecification.Insert(0, new Placeholder("area 1"));
            widgetSpecification.Insert(1, new Placeholder("area 2"));

            this.widget = widgetSpecification.Create();
        }
Exemplo n.º 13
0
        public IResult <WidgetSpecification> CreateWidgetSpecification(string widgetName)
        {
            if (this.widgetSpecificationRepository.Find(widgetName) != null)
            {
                return(new ConflictResult <WidgetSpecification>());
            }

            var widgetSpecification = new WidgetSpecification(widgetName);

            this.widgetSpecificationRepository.Save(widgetSpecification);

            return(new CreatedResult <WidgetSpecification>(widgetSpecification));
        }
Exemplo n.º 14
0
        public IResult<WidgetSpecification> CreateWidgetSpecification(string widgetName)
        {
            if (this.widgetSpecificationRepository.Find(widgetName) != null)
            {
                return new ConflictResult<WidgetSpecification>();
            }

            var widgetSpecification = new WidgetSpecification(widgetName);

            this.widgetSpecificationRepository.Save(widgetSpecification);

            return new CreatedResult<WidgetSpecification>(widgetSpecification);
        }
Exemplo n.º 15
0
        public void SetUp()
        {
            var specification =
                new WidgetSpecification(
                    "widget name",
                    Enumerable.Empty<PropertySpecification>(),
                    new IComponent[]
                        {
                            new Placeholder("area 1"),
                            new Container(
                                "container name",
                                Enumerable.Empty<Property>(),
                                new IComponent[] { new Placeholder("area 2") })
                        });

            this.widget = specification.Create();
        }
Exemplo n.º 16
0
        public void SetUp()
        {
            var specification =
                new WidgetSpecification(
                    "widget name",
                    Enumerable.Empty <PropertySpecification>(),
                    new IComponent[]
            {
                new Placeholder("area 1"),
                new Container(
                    "container name",
                    Enumerable.Empty <Property>(),
                    new IComponent[] { new Placeholder("area 2") })
            });

            this.widget = specification.Create();
        }
        public WidgetSpecificationSurrogate Build(WidgetSpecification widgetSpecification)
        {
            var componentBuilder = new SurrogateBuildingComponentVisitor();
            var amendmentBuilder = new SurrogateBuildingAmendmentVisitor();

            return(new WidgetSpecificationSurrogate
            {
                Category = widgetSpecification.Category,
                Components = widgetSpecification.Components.Select(c => c.Accept(componentBuilder)).ToArray(),
                Amendments = widgetSpecification.Amendments.Select(a => a.Accept(amendmentBuilder)).ToArray(),
                PropertySpecifications = widgetSpecification.Properties.Select(s =>
                                                                               new PropertySpecificationSurrogate
                {
                    Name = s.Name,
                    Type = s.Type,
                    DefaultValue = s.DefaultValue
                }).ToArray()
            });
        }
        public WidgetSpecificationSurrogate Build(WidgetSpecification widgetSpecification)
        {
            var componentBuilder = new SurrogateBuildingComponentVisitor();
            var amendmentBuilder = new SurrogateBuildingAmendmentVisitor();

            return new WidgetSpecificationSurrogate
                       {
                           Category = widgetSpecification.Category,
                           Components = widgetSpecification.Components.Select(c => c.Accept(componentBuilder)).ToArray(),
                           Amendments = widgetSpecification.Amendments.Select(a => a.Accept(amendmentBuilder)).ToArray(),
                           PropertySpecifications = widgetSpecification.Properties.Select(s =>
                                   new PropertySpecificationSurrogate
                                       {
                                           Name = s.Name,
                                           Type = s.Type,
                                           DefaultValue = s.DefaultValue
                                       }).ToArray()
                       };
        }
Exemplo n.º 19
0
 public string Visit(WidgetSpecification widgetSpecification)
 {
     return($"/_kola/widgets/{this.subPath}?name={widgetSpecification.Name}");
 }
 public void SetUp()
 {
     this.widgetSpecification = new WidgetSpecification("widget name");
     this.widgetSpecification.Insert(0, new Atom("atom name", Enumerable.Empty <Property>()));
 }
 public string Visit(WidgetSpecification widgetSpecification)
 {
     return("widget");
 }
 public void SetUp()
 {
     this.widgetSpecification = new WidgetSpecification("widget name");
     this.widgetSpecification.Insert(0, new Atom("atom name", Enumerable.Empty<Property>()));
 }