Exemplo n.º 1
0
        public void Exported(ExportLayoutContext context)
        {
            var elementTree = LoadElements(context.Layout).ToArray();
            var elements    = elementTree.Flatten().ToArray();

            _elementManager.Exported(elements, context);
            context.Layout.LayoutData = _serializer.Serialize(elementTree);
        }
Exemplo n.º 2
0
 public void Exporting(IEnumerable <Element> elements, ExportLayoutContext context)
 {
     InvokeDriver(elements, (driver, element) => {
         var exportElementContext = new ExportElementContext {
             Layout  = context.Layout,
             Element = element
         };
         driver.Exporting(exportElementContext);
         element.ExportableData = new ElementDataDictionary(exportElementContext.ExportableData);
     });
 }
Exemplo n.º 3
0
        public void Exported(IEnumerable <Element> elements, ExportLayoutContext context)
        {
            foreach (var element in elements)
            {
                var exportingContext = new ExportElementContext(element, context.Layout, element.ExportableData ?? new ElementDataDictionary());
                _elementEventHandler.Exported(exportingContext);
                element.Descriptor.Exported(exportingContext);

                // Update potentially modified ExportableData.
                element.ExportableData = new ElementDataDictionary(exportingContext.ExportableData);
            }
        }
Exemplo n.º 4
0
        public override void Build(BuildContext context)
        {
            var blueprints = _repository.Table.OrderBy(x => x.ElementTypeName).ToList();

            if (!blueprints.Any())
            {
                return;
            }

            var blueprintEntries = blueprints.Select(blueprint => {
                var describeContext = DescribeElementsContext.Empty;
                var descriptor      = _elementManager.GetElementDescriptorByTypeName(describeContext, blueprint.BaseElementTypeName);
                var baseElement     = _elementManager.ActivateElement(descriptor);
                baseElement.Data    = ElementDataHelper.Deserialize(blueprint.BaseElementState);
                return(new { Blueprint = blueprint, BaseElement = baseElement });
            }).ToList();

            var baseElements        = blueprintEntries.Select(e => e.BaseElement).ToList();
            var exportLayoutContext = new ExportLayoutContext();

            _elementManager.Exporting(baseElements, exportLayoutContext);
            _elementManager.Exported(baseElements, exportLayoutContext);

            var root = new XElement("CustomElements");

            context.RecipeDocument.Element("Orchard").Add(root);

            foreach (var blueprintEntry in blueprintEntries)
            {
                root.Add(new XElement("Element",
                                      new XAttribute("ElementTypeName", blueprintEntry.Blueprint.ElementTypeName),
                                      new XAttribute("BaseElementTypeName", blueprintEntry.Blueprint.BaseElementTypeName),
                                      new XAttribute("ElementDisplayName", blueprintEntry.Blueprint.ElementDisplayName),
                                      new XAttribute("ElementDescription", blueprintEntry.Blueprint.ElementDescription ?? ""),
                                      new XAttribute("ElementCategory", blueprintEntry.Blueprint.ElementCategory ?? ""),
                                      new XAttribute("BaseExportableData", blueprintEntry.BaseElement.ExportableData.Serialize()),
                                      new XElement("BaseElementState", new XCData(blueprintEntry.Blueprint.BaseElementState))));
            }
        }