Пример #1
0
        // clone parent
        private ContentNode(ContentNode origin, IUmbracoContextAccessor umbracoContextAccessor)
        {
            // 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.DraftContent;
            var originPublished = origin.PublishedContent;


            DraftContent     = originDraft == null ? null : new PublishedContent(this, originDraft, umbracoContextAccessor);
            PublishedContent = originPublished == null ? null : new PublishedContent(this, originPublished, umbracoContextAccessor);
            DraftModel       = DraftContent?.CreateModel();
            PublishedModel   = PublishedContent?.CreateModel();

            ChildContentIds = new List <int>(origin.ChildContentIds); // needs to be *another* list
        }
Пример #2
0
        // clone with new content type
        public ContentNode(ContentNode origin, PublishedContentType contentType, IPublishedSnapshotAccessor publishedSnapshotAccessor, IVariationContextAccessor variationContextAccessor, IUmbracoContextAccessor umbracoContextAccessor)
        {
            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.DraftContent;
            var originPublished = origin.PublishedContent;

            DraftContent     = originDraft == null ? null : new PublishedContent(this, originDraft.ContentData, publishedSnapshotAccessor, variationContextAccessor, umbracoContextAccessor);
            DraftModel       = DraftContent?.CreateModel();
            PublishedContent = originPublished == null ? null : new PublishedContent(this, originPublished.ContentData, publishedSnapshotAccessor, variationContextAccessor, umbracoContextAccessor);
            PublishedModel   = PublishedContent?.CreateModel();

            ChildContentIds = origin.ChildContentIds; // can be the *same* list
        }