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
            });
        }
Exemple #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
            });
        }
Exemple #3
0
        public override ComponentParts Write(Component component, Page page)
        {
            var element   = component as Element;
            var parts     = new ComponentParts();
            var endpoints = new List <Endpoint>();

            if (element.JavaScriptPath != null)
            {
                parts.ElementScripts.Add(element.JavaScriptId.Value, element.JavaScriptPath);
            }

            if (element.Events != null)
            {
                foreach (var eventHandler in element.Events)
                {
                    var endpoint = eventHandler.Callback;
                    endpoint.Page = page;
                    endpoint.Name = element.Id + eventHandler.Event;
                    endpoints.Add(endpoint);
                }
            }

            if (element.Callback != null)
            {
                element.Callback.Name = element.Id;
                endpoints.Add(element.Callback);
            }

            parts.Endpoints = endpoints;

            if (element.Content != null)
            {
                foreach (var child in element.Content.OfType <Component>())
                {
                    var writer = _factory.GetWriter(child);
                    if (writer != null)
                    {
                        var moreParts = writer.Write(child, page);
                        parts.Combine(moreParts);
                    }
                }
            }


            return(parts);
        }
        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
            });
        }