public static InstantArticleItemModel CreateFrom(int type, InstantArticleItemModel model)
        {
            _createFromDic.ToDictionary(kvp => kvp.Key,
                                        kvp => kvp.Value);

            return(_createFromDic[(InstantArticleItemType)type](model));
        }
示例#2
0
        protected XElement AddCaption(InstantArticleItemModel item)
        {
            var caption        = (CaptionItem)item.Children.First(c => c.IsCaption);
            var captionAttrDic = caption.Attributes.ToDictionary(a => a.Name, a => a);

            return(new XElement("figcaption",
                                new XElement("h1", GetAttributeValue(captionAttrDic["title"])),
                                new XElement("cite", GetAttributeValue(captionAttrDic["credits"]))));
        }
        private InstantArticleItemModel _CreateItemChildViewModel(InstantArticleItemModel model)
        {
            var type = (InstantArticleItemType)model.ItemTypeId;
            var vm   = InstantArticleModelFactory.CreateFrom((int)model.ItemTypeId, model);


            vm.Name            = InstantArticleModelFactory.Items[type].Name;
            vm.Type            = (InstantArticleItemType)model.ItemTypeId;
            vm.AttributeValues = Common.ItemData.ContainsKey(type) ? Common.ItemData[type].AttributeValues : null;

            return(vm);
        }
        private InstantArticleItemModel _CreateItemViewModel(InstantArticleItemModel model)
        {
            var type = (InstantArticleItemType)model.ItemTypeId;

            return(new InstantArticleItemModel(model)
            {
                Name = InstantArticleModelFactory.Items[type].Name,
                Type = (InstantArticleItemType)model.ItemTypeId,
                AttributeValues = Common.ItemData.ContainsKey(type) ? Common.ItemData[type].AttributeValues : null,
                Children = model.Children.IsNullOrEmpty() ? null : model.Children.Select(c => _CreateItemChildViewModel(c)).ToList()
            });
        }
示例#5
0
        public override XElement ToXElement()
        {
            var attrDic = Attributes.ToDictionary(a => a.Name, a => a);

            var attrs = InstantArticleItemModel.ToXAttribute(attrDic);

            //var attrs = new[]
            //{
            //    new XAttribute("src", attrDic["src"].Value),
            //    new XAttribute("data-mode", attrDic["data-mode"].Value),
            //    new XAttribute("data-fb-disable-360", attrDic["data-fb-disable-360"].Value),
            //};

            var el = new XElement(
                "figure",
                new XElement("img", attrs),
                AddCaption(this));

            return(el);
        }
        public ContentResult DeleteItem(InstantArticleItemModel item)
        {
            var itemModels = new List <InstantArticleItemModel>();

            try
            {
                //remove children first
                if (!item.Children.IsNullOrEmpty())
                {
                    _articleItemRepos.Remove(item.Children.Select(c => c.Id).ToList());
                }
                _articleItemRepos.Remove(item.Id);
                itemModels = _GetItems(item.InstantArticleId);
            }
            catch
            {
                return(_ConvertToJSON(new { Success = false }));
            }


            return(_ConvertToJSON(new { Success = true, Items = itemModels }));
        }
 public PullQuoteItem(InstantArticleItemModel model) : base(model)
 {
 }
示例#8
0
 public VideoItem(InstantArticleItemModel model) : base(model)
 {
 }
 public FacebookEmbedItem(InstantArticleItemModel model) : base(model)
 {
 }
示例#10
0
 public MapItem(InstantArticleItemModel model) : base(model)
 {
 }
 public TwitterEmbedItem(InstantArticleItemModel model) : base(model)
 {
 }
示例#12
0
 public CaptionItem(InstantArticleItemModel model) : base(model)
 {
 }
示例#13
0
 public ItemWithCaption(InstantArticleItemModel model) : base(model)
 {
 }
 public SlideShowItem(InstantArticleItemModel model) : base(model)
 {
 }
 public InstagramEmbedItem(InstantArticleItemModel model) : base(model)
 {
 }
示例#16
0
 public TextItem(InstantArticleItemModel model) : base(model)
 {
 }
示例#17
0
 public BlockQuoteItem(InstantArticleItemModel model) : base(model)
 {
 }
示例#18
0
 public YouTubeEmbedItem(InstantArticleItemModel model) : base(model)
 {
 }
示例#19
0
 public ImageItem(InstantArticleItemModel model) : base(model)
 {
 }