コード例 #1
0
        protected override EditorResult OnBuildEditor(MediaItem element, ElementEditorContext context)
        {
            var viewModel = new ContentItemEditorViewModel();
            var editor    = context.ShapeFactory.EditorTemplate(TemplateName: "Elements.MediaItem", Model: viewModel);

            if (context.Updater != null)
            {
                context.Updater.TryUpdateModel(viewModel, context.Prefix, null, null);
                element.MediaItemIds = ContentItem.Deserialize(viewModel.ContentItemIds);
                element.DisplayType  = viewModel.DisplayType;
            }

            var contentItemIds = element.MediaItemIds;
            var displayType    = element.DisplayType;
            var layoutPart     = context.Content;
            var layoutId       = layoutPart != null ? layoutPart.Id : 0;

            viewModel.ContentItems = GetContentItems(RemoveCurrentContentItemId(contentItemIds, layoutId)).ToArray();
            viewModel.DisplayType  = displayType;

            return(Editor(context, editor));
        }
コード例 #2
0
 private static int?ParseImageId(string imageId)
 {
     return(ContentItem.Deserialize(imageId).FirstOrDefault());
 }