コード例 #1
0
ファイル: ContentCache.cs プロジェクト: greystate/Umbraco-CMS
        // gets a published content as a previewing draft, if preview is true
        // this is for published content when previewing
        private static IPublishedContent GetPublishedContentAsDraft(IPublishedContent content /*, bool preview*/)
        {
            if (content == null /*|| preview == false*/)
            {
                return(null);                                         //content;
            }
            // an object in the cache is either an IPublishedContentOrMedia,
            // or a model inheriting from PublishedContentExtended - in which
            // case we need to unwrap to get to the original IPublishedContentOrMedia.

            var inner = PublishedContent.UnwrapIPublishedContent(content);

            return(inner.AsDraft());
        }
コード例 #2
0
        // clone with new content type
        public ContentNode(ContentNode origin, PublishedContentType contentType, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor)
        {
            Id              = origin.Id;
            Uid             = origin.Uid;
            ContentType     = contentType; // change!
            Level           = origin.Level;
            Path            = origin.Path;
            SortOrder       = origin.SortOrder;
            ParentContentId = origin.ParentContentId;
            CreateDate      = origin.CreateDate;
            CreatorId       = origin.CreatorId;

            var originDraft     = origin.Draft == null ? null : PublishedContent.UnwrapIPublishedContent(origin.Draft);
            var originPublished = origin.Published == null ? null : PublishedContent.UnwrapIPublishedContent(origin.Published);

            Draft     = originDraft == null ? null : new PublishedContent(this, originDraft._contentData, publishedSnapshotAccessor, variationContextAccessor).CreateModel();
            Published = originPublished == null ? null : new PublishedContent(this, originPublished._contentData, publishedSnapshotAccessor, variationContextAccessor).CreateModel();

            ChildContentIds = origin.ChildContentIds; // can be the *same* list FIXME oh really?
        }
コード例 #3
0
        // clone parent
        private ContentNode(ContentNode origin)
        {
            // everything is the same, except for the child items
            // list which is a clone of the original list

            Id              = origin.Id;
            Uid             = origin.Uid;
            ContentType     = origin.ContentType;
            Level           = origin.Level;
            Path            = origin.Path;
            SortOrder       = origin.SortOrder;
            ParentContentId = origin.ParentContentId;
            CreateDate      = origin.CreateDate;
            CreatorId       = origin.CreatorId;

            var originDraft     = origin.Draft == null ? null : PublishedContent.UnwrapIPublishedContent(origin.Draft);
            var originPublished = origin.Published == null ? null : PublishedContent.UnwrapIPublishedContent(origin.Published);

            Draft     = originDraft == null ? null : new PublishedContent(this, originDraft).CreateModel();
            Published = originPublished == null ? null : new PublishedContent(this, originPublished).CreateModel();

            ChildContentIds = new List <int>(origin.ChildContentIds); // needs to be *another* list
        }