protected SlickSliderConfig GetConfigObjectFromString(string xml) { if (string.IsNullOrEmpty(xml)) { return(new SlickSliderConfig()); } return(XmlHelper.Deserialize <SlickSliderConfig>(xml)); }
protected override EditorResult OnBuildEditor(SlickSlider element, ElementEditorContext context) { var viewModel = new SlickSliderEditorViewModel(); var editor = context.ShapeFactory.EditorTemplate(TemplateName: "Elements.SlickSlider", Model: viewModel); if (context.Updater != null) { context.Updater.TryUpdateModel(viewModel, context.Prefix, null, null); element.MediaItemIds = ContentItem.Deserialize(viewModel.ContentItemIds); element.SliderId = viewModel.SliderId; element.Config = XmlHelper.Serialize(viewModel.Config); } var contentItemIds = element.MediaItemIds; var layoutPart = context.Content; var layoutId = layoutPart != null ? layoutPart.Id : 0; viewModel.ContentItems = GetContentItems(RemoveCurrentContentItemId(contentItemIds, layoutId)).ToArray(); viewModel.SliderId = element.SliderId; viewModel.Config = GetConfigObjectFromString(element.Config); return(Editor(context, editor)); }