ApiExamples.ExStyles.CopyStyleSameDocument C# (CSharp) Метод

CopyStyleSameDocument() приватный Метод

private CopyStyleSameDocument ( ) : void
Результат void
        public void CopyStyleSameDocument()
        {
            Document doc = new Document(MyDir + "Document.doc");

            //ExStart
            //ExFor:StyleCollection.AddCopy
            //ExFor:Style.Name
            //ExSummary:Demonstrates how to copy a style within the same document.
            // The AddCopy method creates a copy of the specified style and automatically generates a new name for the style, such as "Heading 1_0".
            Style newStyle = doc.Styles.AddCopy(doc.Styles["Heading 1"]);

            // You can change the new style name if required as the Style.Name property is read-write.
            newStyle.Name = "My Heading 1";
            //ExEnd

            Assert.NotNull(newStyle);
            Assert.AreEqual("My Heading 1", newStyle.Name);
            Assert.AreEqual(doc.Styles["Heading 1"].Type, newStyle.Type);
        }