public void Exporting(ExportLayoutContext context) { var elementTree = LoadElements(context.Layout).ToArray(); var elements = elementTree.Flatten().ToArray(); _elementManager.Exporting(elements, context); context.Layout.LayoutData = _serializer.Serialize(elementTree); }
protected override void Exporting(ElementWrapperPart part, ExportContentContext context) { var describeContext = CreateDescribeContext(part); var descriptor = _elementManager.GetElementDescriptorByTypeName(describeContext, part.ElementTypeName); var data = ElementDataHelper.Deserialize(part.ElementData); var element = _elementManager.ActivateElement(descriptor, e => e.Data = data); _elementManager.Exporting(new[] { element }, new ExportLayoutContext()); var exportableData = _serializer.Serialize(element); context.Element(part.PartDefinition.Name).SetValue(exportableData); }
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)))); } }