public DashboardApp Build(IEnumerable <Page> pages)
        {
            var componentWriterFactory = new ComponentWriterFactory();

            var parts = new List <ComponentParts>();

            foreach (var page in pages)
            {
                parts.AddRange(page.Components.Select(x => WriteComponent(componentWriterFactory, x, page)).Where(m => m != null));
                parts.Add(WriteComponent(componentWriterFactory, page, page));
            }

            var componentParts = new ComponentParts();

            foreach (var part in parts)
            {
                componentParts.Combine(part);
            }

            foreach (var endpoint in componentParts.Endpoints)
            {
                Log.Debug("Adding endpoint: " + endpoint.Url);
            }

            return(new DashboardApp
            {
                Endpoints = componentParts.Endpoints,
                ElementScripts = componentParts.ElementScripts
            });
        }
Exemplo n.º 2
0
        public DashboardApp Build(IEnumerable <Page> pages)
        {
            var componentWriterFactory = new ComponentWriterFactory();

            var parts = pages.SelectMany(m => m.Components).Select(x => WriteComponent(componentWriterFactory, x)).Where(m => m != null).ToArray();

            parts = parts.Concat(pages.Select(m => WriteComponent(componentWriterFactory, m)).Where(m => m != null).ToArray()).ToArray();

            var componentParts = new ComponentParts();

            foreach (var part in parts)
            {
                componentParts.Combine(part);
            }

            foreach (var endpoint in componentParts.Endpoints)
            {
                Log.Debug("Adding endpoint: " + endpoint.Url);
            }

            return(new DashboardApp
            {
                Endpoints = componentParts.Endpoints,
                ElementScripts = componentParts.ElementScripts
            });
        }
        public DashboardApp Build(IEnumerable <Component> components, Page page)
        {
            var componentWriterFactory = new ComponentWriterFactory();

            var parts = components.Select(x => WriteComponent(componentWriterFactory, x, page)).Where(m => m != null).ToArray();

            var componentParts = new ComponentParts();

            foreach (var part in parts)
            {
                componentParts.Combine(part);
            }



            return(new DashboardApp
            {
                Endpoints = componentParts.Endpoints,
                ElementScripts = componentParts.ElementScripts
            });
        }
 private ComponentParts WriteComponent(ComponentWriterFactory factory, Component component, Page page)
 {
     return(factory.GetWriter(component).Write(component, page));
 }
Exemplo n.º 5
0
 public ElementWriter(ComponentWriterFactory factory)
 {
     _factory = factory;
 }