예제 #1
0
        protected override void Exported(ElementWrapperPart part, ExportContentContext context)
        {
            var describeContext = CreateDescribeContext(part);
            // Deserialize element from the version set in the Exporting method
            var currentContextValue = context.Element(part.PartDefinition.Name).Value;
            var element             = _serializer.Deserialize(currentContextValue, describeContext);

            _elementManager.Exported(new[] { element }, new ExportLayoutContext());
            var exportableData = _serializer.Serialize(element);

            context.Element(part.PartDefinition.Name).SetValue(exportableData);
        }
        public void Deserialize(
            JToken dataSource,
            IModelMember destination,
            ISerializerProvider provider,
            IElementSerializer elementSerializer)
        {
            var current = destination as IModelElementMember;

            var jObjDataSource = dataSource as JObject;
            if (jObjDataSource == null) return;

            elementSerializer.Deserialize(jObjDataSource, current.Element, provider);
        }
        private void HandleImportEvent(ElementWrapperPart part, ImportContentContext context, Action <DescribeElementsContext, Element> callback)
        {
            var root = context.Data.Element(part.PartDefinition.Name);

            if (root == null)
            {
                return;
            }

            var exportedData    = root.Value;
            var describeContext = CreateDescribeContext(part);
            var element         = _serializer.Deserialize(exportedData, describeContext);

            callback(describeContext, element);
            part.ElementData = element.Data.Serialize();
        }
        public void Deserialize(
            JToken dataSource,
            IModelMember destination,
            ISerializerProvider provider,
            IElementSerializer elementSerializer)
        {
            var current = destination as IModelCollectionMember;

            var jArrayDataSource = dataSource as JArray;
            if (jArrayDataSource == null) return;

            foreach (var childJObject in jArrayDataSource.Children().OfType<JObject>())
            {
                var newEl = current.Elements.Create();
                elementSerializer.Deserialize(childJObject, newEl, provider);
            }
        }
        protected override void Importing(ElementWrapperPart part, ImportContentContext context)
        {
            var root = context.Data.Element(part.PartDefinition.Name);

            if (root == null)
            {
                return;
            }

            var exportedData    = root.Value;
            var describeContext = CreateDescribeContext(part);
            var element         = _serializer.Deserialize(exportedData, describeContext);

            _elementManager.Importing(new[] { element }, new ImportLayoutContext {
                Session = new ImportContentContextWrapper(context)
            });
            part.ElementData = element.Data.Serialize();
        }
        public void Deserialize(
            JToken dataSource,
            IModelMember destination,
            ISerializerProvider provider,
            IElementSerializer elementSerializer)
        {
            var current = destination as IModelDictionaryMember;

            var jObjDataSource = dataSource as JObject;
            if (jObjDataSource == null) return;

            foreach (var childJProp in jObjDataSource.Children().OfType<JProperty>())
            {
                var childJObj = childJProp.Value as JObject;
                if (childJObj == null) return;

                var newEl = current.Elements.Create(childJProp.Name);
                elementSerializer.Deserialize(childJObj, newEl, provider);
            }
        }