Ejemplo n.º 1
0
        protected override void Exporting(QueryPart part, ExportContentContext context)
        {
            var element = context.Element(part.PartDefinition.Name);

            element.Add(
                new XElement("FilterGroups",
                             part.FilterGroups.Select(filterGroup =>
                                                      new XElement("FilterGroup",
                                                                   filterGroup.Filters.Select(filter => {
                var descriptor = _projectionManager.GetFilter(filter.Category, filter.Type);

                var state = filter.State;
                if (descriptor != null)
                {
                    state = _formManager.Export(descriptor.Form, filter.State, context);
                }

                return(new XElement("Filter",
                                    new XAttribute("Category", filter.Category ?? ""),
                                    new XAttribute("Description", filter.Description ?? ""),
                                    new XAttribute("Position", filter.Position),
                                    new XAttribute("State", state ?? ""),
                                    new XAttribute("Type", filter.Type ?? "")
                                    ));
            })
                                                                   )
                                                      )
                             ),
                new XElement("SortCriteria",
                             part.SortCriteria.Select(sortCriterion => {
                var descriptor = _projectionManager.GetFilter(sortCriterion.Category, sortCriterion.Type);

                var state = sortCriterion.State;
                if (descriptor != null)
                {
                    state = _formManager.Export(descriptor.Form, sortCriterion.State, context);
                }

                return(new XElement("SortCriterion",
                                    new XAttribute("Category", sortCriterion.Category ?? ""),
                                    new XAttribute("Description", sortCriterion.Description ?? ""),
                                    new XAttribute("Position", sortCriterion.Position),
                                    new XAttribute("State", state ?? ""),
                                    new XAttribute("Type", sortCriterion.Type ?? "")
                                    ));
            })
                             ),
                new XElement("Layouts",
                             part.Layouts.Select(layout => {
                var descriptor = _projectionManager.GetFilter(layout.Category, layout.Type);

                var state = layout.State;
                if (descriptor != null)
                {
                    state = _formManager.Export(descriptor.Form, layout.State, context);
                }

                return(new XElement("Layout",
                                    // Attributes
                                    new XAttribute("Category", layout.Category ?? ""),
                                    new XAttribute("Description", layout.Description ?? ""),
                                    new XAttribute("State", state ?? ""),
                                    new XAttribute("Display", layout.Display),
                                    new XAttribute("DisplayType", layout.DisplayType ?? ""),
                                    new XAttribute("Type", layout.Type ?? ""),

                                    // Properties
                                    new XElement("Properties", layout.Properties.Select(GetPropertyXml)),

                                    // Group
                                    new XElement("Group", GetPropertyXml(layout.GroupProperty))
                                    ));
            })
                             )
                );
        }