Ejemplo n.º 1
0
        /// <summary>
        /// Registers a document to use a shared paragragraph collection, which potentially may ensure uniqueness among many documents.
        /// </summary>
        /// <param name="shared">Shared collection feature.</param>
        /// <param name="doc">Document to register with shared paragraph collection.</param>
        /// <returns></returns>
        public static ISharedFeature <IParagraphIdCollectionFeature> Add(this ISharedFeature <IParagraphIdCollectionFeature> shared, WordprocessingDocument doc)
        {
            doc.AddPackageEventsFeature();
            doc.AddParagraphIdFeature();

            var paragraphIdCollection = doc.Features.GetRequired <IParagraphIdCollectionFeature>();

            shared.Add(paragraphIdCollection);
            doc.Features.SetDisposable(new ParagraphIdSnapshotGenerator(paragraphIdCollection, shared, doc.Features.GetRequired <IPackageEventsFeature>()));
            doc.Features.Set(shared);
            doc.Features.Set(shared.Composite);

            return(shared);
        }