public ContentSection Clone(ReleaseContentSection newReleaseContentSection, Release.CloneContext context)
        {
            var copy = MemberwiseClone() as ContentSection;

            copy.Id = Guid.NewGuid();

            copy.Release = newReleaseContentSection;

            copy.Content = copy
                           .Content?
                           .Select(content => content.Clone(context, copy))
                           .ToList();

            return(copy);
        }
Esempio n. 2
0
        public ReleaseContentSection Clone(Release.CloneContext context)
        {
            var copy = MemberwiseClone() as ReleaseContentSection;
            copy.Release = context.NewRelease;
            copy.ReleaseId = context.NewRelease.Id;

            var contentSection = copy
                .ContentSection
                .Clone(copy, context);

            copy.ContentSection = contentSection;
            copy.ContentSectionId = contentSection.Id;

            return copy;
        }
Esempio n. 3
0
        public ReleaseContentBlock Clone(Release newRelease, Release.CloneContext context)
        {
            var copy = MemberwiseClone() as ReleaseContentBlock;

            copy.Release   = newRelease;
            copy.ReleaseId = newRelease.Id;

            var clonedContentBlock =
                context.ContentBlocks.GetValueOrDefault(ContentBlock)
                ?? ContentBlock.Clone(context, null);

            copy.ContentBlock   = clonedContentBlock;
            copy.ContentBlockId = clonedContentBlock.Id;

            return(copy);
        }
        private static void UpdateAmendmentContent(Release.CloneContext context)
        {
            var replacements = new Dictionary <string, MatchEvaluator>();

            // Bit cheeky to re-use the clone context, but it's a nice
            // easy way to access and modify all of the content blocks
            // that we used during the clone.
            context.ContentBlocks
            .ForEach(
                pair =>
            {
                switch (pair)
                {
                case { Key: DataBlock oldDataBlock, Value: DataBlock newDataBlock } :
                    replacements[$"/fast-track/{oldDataBlock.Id}"] = _ => $"/fast-track/{newDataBlock.Id}";
                    break;
                }
        public ContentBlock Clone(Release.CloneContext context, ContentSection newContentSection)
        {
            var copy = MemberwiseClone() as ContentBlock;

            copy.Id = Guid.NewGuid();

            if (newContentSection != null)
            {
                copy.ContentSection   = newContentSection;
                copy.ContentSectionId = newContentSection.Id;
            }

            // start a new amendment with no comments
            copy.Comments = new List <Comment>();

            context.ContentBlocks.Add(this, copy);

            return(copy);
        }
        public static Release CreateAmendment(this Release release, DateTime createdDate, Guid createdByUserId)
        {
            var amendment = release.Clone();

            // Set new values for fields that should be altered in the amended
            // Release rather than copied from the original Release
            amendment.Id                = Guid.NewGuid();
            amendment.Published         = null;
            amendment.PublishScheduled  = null;
            amendment.ApprovalStatus    = ReleaseApprovalStatus.Draft;
            amendment.Created           = createdDate;
            amendment.CreatedById       = createdByUserId;
            amendment.Version           = release.Version + 1;
            amendment.PreviousVersionId = release.Id;

            var context = new Release.CloneContext(amendment);

            amendment.Content = amendment
                                .Content
                                ?.Select(rcs => rcs.Clone(context))
                                .ToList();

            amendment.ContentBlocks = amendment
                                      .ContentBlocks
                                      ?.Select(rcb => rcb.Clone(context))
                                      .ToList();

            amendment.RelatedInformation = amendment
                                           .RelatedInformation
                                           ?.Select(link => link.Clone())
                                           .ToList();

            amendment.Updates = amendment
                                .Updates
                                ?.Select(update => update.Clone(amendment))
                                .ToList();

            UpdateAmendmentContent(context);

            return(amendment);
        }