Example #1
0
    internal static void smethod_0(Class1132 A_0, CustomXmlPartCollection A_1)
    {
        int       num    = 5;
        Class1089 class2 = A_0.method_0().method_6(BookmarkStart.b("昪帬䀮田刲䄴嘶樸伺刼䴾⑀", 5));

        if (class2 != null)
        {
            foreach (DictionaryEntry entry in class2)
            {
                CustomXmlPart part   = new CustomXmlPart();
                Class1089     class3 = (Class1089)entry.Value;
                foreach (DictionaryEntry entry2 in class3)
                {
                    string key = (string)entry2.Key;
                    if (key != null)
                    {
                        if (!(key == BookmarkStart.b("截夬䨮尰", num)))
                        {
                            if (key == BookmarkStart.b("笪弬䀮䄰嘲䜴䌶倸帺丼", num))
                            {
                                smethod_1((Stream)entry2.Value, part);
                            }
                        }
                        else
                        {
                            part.Data = Class567.smethod_10((Stream)entry2.Value);
                        }
                    }
                }
                A_1.Add(part);
            }
        }
    }
Example #2
0
    internal static Class1089 smethod_4(CustomXmlPartCollection A_0)
    {
        int num = 7;

        if (A_0.Count == 0)
        {
            return(null);
        }
        Class1089 class4 = new Class1089();

        for (int i = 0; i < A_0.Count; i++)
        {
            CustomXmlPart part   = A_0[i];
            Class1089     class3 = new Class1089();
            class3.method_2(BookmarkStart.b("搬嬮吰帲", num), new MemoryStream(part.Data));
            Stream   stream = new MemoryStream();
            Class397 class2 = new Class397(stream, Encoding.UTF8, false);
            if (class2.method_0().method_1().Count == 0)
            {
                class2.method_0().method_1().Add(BookmarkStart.b("䤬尮", num), BookmarkStart.b("䔬嬮䔰䌲༴ᠶᘸ䠺帼圾⑀⹂⑄㑆杈⑊㵌⩎㽐⭒㡔㭖㽘㑚⽜㉞`ᝢᙤ䥦٨ᥪ੬䁮Ṱᕲ፴Ṷ᩸Ṻ㥼ၾハꊌ붎ꆐꎒꎔ뢖滛캠캢ﶤ쪦얨", num));
            }
            smethod_5(part, class2);
            class3.Add(BookmarkStart.b("紬崮帰䌲倴䔶䴸刺堼䰾", num), stream);
            class4.method_3(string.Format(BookmarkStart.b("丬圮唰䀲临ܶ䐸", num), i), class3);
        }
        return(class4);
    }
        internal void method_0(CustomXmlPartCollection A_0)
        {
            int num = 0x12;

            if ((A_0.Count > 0) && (this.DataBinding != null))
            {
                if (!this.RepeatingSection)
                {
                    XmlNode node = this.DataBinding.method_2(A_0);
                    if (node != null)
                    {
                        string str2 = this.method_6(node.InnerText);
                        this.method_4(this.Owner, str2);
                    }
                }
                else
                {
                    Regex  regex = new Regex(BookmarkStart.b("搷愹ᐻ戽␿桁浃ᩅᕇ湉", num));
                    string input = this.DataBinding.method_13();
                    if (!regex.IsMatch(input))
                    {
                        DocumentObject owner = this.Owner.Owner;
                        XmlNodeList    list  = this.DataBinding.method_5(A_0, input);
                        if ((list != null) && (list.Count > 0))
                        {
                            if (list.Count > 1)
                            {
                                int num2  = 1;
                                int count = list.Count;
                                while (num2 < count)
                                {
                                    this.method_1(owner, list[num2], input, false);
                                    num2++;
                                }
                            }
                            this.method_1(owner, list[0], input, true);
                        }
                    }
                    regex = null;
                }
            }
        }
Example #4
0
    internal XmlNode method_3(CustomXmlPartCollection A_0, string A_1)
    {
        if (string.IsNullOrEmpty(this.method_14()) && string.IsNullOrEmpty(this.method_13()))
        {
            return(null);
        }
        XmlNode node = null;

        if (A_0.GetById(this.method_14()) == null)
        {
            foreach (CustomXmlPart part in A_0)
            {
                node = this.method_4(part, A_1);
                if (node != null)
                {
                    return(node);
                }
            }
            return(node);
        }
        return(this.method_4(A_0.GetById(this.method_14()), A_1));
    }
Example #5
0
    internal XmlNodeList method_5(CustomXmlPartCollection A_0, string A_1)
    {
        if (string.IsNullOrEmpty(this.method_14()))
        {
            return(null);
        }
        XmlNodeList list = null;

        if (A_0.GetById(this.method_14()) == null)
        {
            foreach (CustomXmlPart part in A_0)
            {
                list = this.method_6(part, A_1);
                if (list != null)
                {
                    return(list);
                }
            }
            return(list);
        }
        return(this.method_6(A_0.GetById(this.method_14()), A_1));
    }
Example #6
0
        public void CreatingCustomXml()
        {
            //ExStart
            //ExFor:CustomXmlPart
            //ExFor:CustomXmlPart.Clone
            //ExFor:CustomXmlPart.Data
            //ExFor:CustomXmlPart.Id
            //ExFor:CustomXmlPart.Schemas
            //ExFor:CustomXmlPartCollection
            //ExFor:CustomXmlPartCollection.Add(CustomXmlPart)
            //ExFor:CustomXmlPartCollection.Add(String, String)
            //ExFor:CustomXmlPartCollection.Clear
            //ExFor:CustomXmlPartCollection.Clone
            //ExFor:CustomXmlPartCollection.Count
            //ExFor:CustomXmlPartCollection.GetById(String)
            //ExFor:CustomXmlPartCollection.GetEnumerator
            //ExFor:CustomXmlPartCollection.Item(Int32)
            //ExFor:CustomXmlPartCollection.RemoveAt(Int32)
            //ExFor:Document.CustomXmlParts
            //ExFor:StructuredDocumentTag.XmlMapping
            //ExFor:XmlMapping.SetMapping(CustomXmlPart, String, String)
            //ExSummary:Shows how to create structured document tag with a custom XML data.
            Document doc = new Document();

            // Construct an XML part that contains data and add it to the document's collection
            // Once the "Developer" tab in Microsoft Word is enabled,
            // we can find elements from this collection as well as a couple defaults in the "XML Mapping Pane"
            string        xmlPartId      = Guid.NewGuid().ToString("B");
            string        xmlPartContent = "<root><text>Hello world!</text></root>";
            CustomXmlPart xmlPart        = doc.CustomXmlParts.Add(xmlPartId, xmlPartContent);

            // The data we entered is stored in these attributes
            Assert.AreEqual(Encoding.ASCII.GetBytes(xmlPartContent), xmlPart.Data);
            Assert.AreEqual(xmlPartId, xmlPart.Id);

            // XML parts can be referenced by collection index or GUID
            Assert.AreEqual(xmlPart, doc.CustomXmlParts[0]);
            Assert.AreEqual(xmlPart, doc.CustomXmlParts.GetById(xmlPartId));

            // Once the part is created, we can add XML schema associations like this
            xmlPart.Schemas.Add("http://www.w3.org/2001/XMLSchema");

            // We can also clone parts and insert them into the collection directly
            CustomXmlPart xmlPartClone = xmlPart.Clone();

            xmlPartClone.Id = Guid.NewGuid().ToString("B");
            doc.CustomXmlParts.Add(xmlPartClone);

            Assert.AreEqual(2, doc.CustomXmlParts.Count);

            // Iterate through collection with an enumerator and print the contents of each part
            using (IEnumerator <CustomXmlPart> enumerator = doc.CustomXmlParts.GetEnumerator())
            {
                int index = 0;
                while (enumerator.MoveNext())
                {
                    Console.WriteLine($"XML part index {index}, ID: {enumerator.Current.Id}");
                    Console.WriteLine($"\tContent: {Encoding.UTF8.GetString(enumerator.Current.Data)}");
                    index++;
                }
            }

            // XML parts can be removed by index
            doc.CustomXmlParts.RemoveAt(1);

            Assert.AreEqual(1, doc.CustomXmlParts.Count);

            // The XML part collection itself can be cloned also
            CustomXmlPartCollection customXmlParts = doc.CustomXmlParts.Clone();

            // And all elements can be cleared like this
            customXmlParts.Clear();

            // Create a StructuredDocumentTag that will display the contents of our part,
            // insert it into the document and save the document
            StructuredDocumentTag tag = new StructuredDocumentTag(doc, SdtType.PlainText, MarkupLevel.Block);

            tag.XmlMapping.SetMapping(xmlPart, "/root[1]/text[1]", string.Empty);

            doc.FirstSection.Body.AppendChild(tag);

            doc.Save(ArtifactsDir + "StructuredDocumentTag.CustomXml.docx");
            //ExEnd

            Assert.IsTrue(DocumentHelper.CompareDocs(ArtifactsDir + "StructuredDocumentTag.CustomXml.docx", GoldsDir + "StructuredDocumentTag.CustomXml Gold.docx"));

            doc     = new Document(ArtifactsDir + "StructuredDocumentTag.CustomXml.docx");
            xmlPart = doc.CustomXmlParts[0];

            Assert.True(Guid.TryParse(xmlPart.Id, out Guid temp));
            Assert.AreEqual("<root><text>Hello world!</text></root>", Encoding.UTF8.GetString(xmlPart.Data));
            Assert.AreEqual("http://www.w3.org/2001/XMLSchema", xmlPart.Schemas[0]);

            tag = (StructuredDocumentTag)doc.GetChild(NodeType.StructuredDocumentTag, 0, true);
            Assert.AreEqual("Hello world!", tag.GetText().Trim());
            Assert.AreEqual("/root[1]/text[1]", tag.XmlMapping.XPath);
            Assert.AreEqual(string.Empty, tag.XmlMapping.PrefixMappings);
        }
        public void CreatingCustomXml()
        {
            //ExStart
            //ExFor:CustomXmlPart
            //ExFor:CustomXmlPart.Clone
            //ExFor:CustomXmlPart.Data
            //ExFor:CustomXmlPart.Id
            //ExFor:CustomXmlPart.Schemas
            //ExFor:CustomXmlPartCollection
            //ExFor:CustomXmlPartCollection.Add(CustomXmlPart)
            //ExFor:CustomXmlPartCollection.Add(String, String)
            //ExFor:CustomXmlPartCollection.Clear
            //ExFor:CustomXmlPartCollection.Clone
            //ExFor:CustomXmlPartCollection.Count
            //ExFor:CustomXmlPartCollection.GetById(String)
            //ExFor:CustomXmlPartCollection.GetEnumerator
            //ExFor:CustomXmlPartCollection.Item(Int32)
            //ExFor:CustomXmlPartCollection.RemoveAt(Int32)
            //ExFor:Document.CustomXmlParts
            //ExFor:StructuredDocumentTag.XmlMapping
            //ExFor:XmlMapping.SetMapping(CustomXmlPart, String, String)
            //ExSummary:Shows how to create a structured document tag with custom XML data.
            Document doc = new Document();

            // Construct an XML part that contains data and add it to the document's collection.
            // If we enable the "Developer" tab in Microsoft Word,
            // we can find elements from this collection in the "XML Mapping Pane", along with a few default elements.
            string        xmlPartId      = Guid.NewGuid().ToString("B");
            string        xmlPartContent = "<root><text>Hello world!</text></root>";
            CustomXmlPart xmlPart        = doc.CustomXmlParts.Add(xmlPartId, xmlPartContent);

            Assert.AreEqual(Encoding.ASCII.GetBytes(xmlPartContent), xmlPart.Data);
            Assert.AreEqual(xmlPartId, xmlPart.Id);

            // Below are two ways to refer to XML parts.
            // 1 -  By an index in the custom XML part collection:
            Assert.AreEqual(xmlPart, doc.CustomXmlParts[0]);

            // 2 -  By GUID:
            Assert.AreEqual(xmlPart, doc.CustomXmlParts.GetById(xmlPartId));

            // Add an XML schema association.
            xmlPart.Schemas.Add("http://www.w3.org/2001/XMLSchema");

            // Clone a part, and then insert it into the collection.
            CustomXmlPart xmlPartClone = xmlPart.Clone();

            xmlPartClone.Id = Guid.NewGuid().ToString("B");
            doc.CustomXmlParts.Add(xmlPartClone);

            Assert.AreEqual(2, doc.CustomXmlParts.Count);

            // Iterate through the collection and print the contents of each part.
            using (IEnumerator <CustomXmlPart> enumerator = doc.CustomXmlParts.GetEnumerator())
            {
                int index = 0;
                while (enumerator.MoveNext())
                {
                    Console.WriteLine($"XML part index {index}, ID: {enumerator.Current.Id}");
                    Console.WriteLine($"\tContent: {Encoding.UTF8.GetString(enumerator.Current.Data)}");
                    index++;
                }
            }

            // Use the "RemoveAt" method to remove the cloned part by index.
            doc.CustomXmlParts.RemoveAt(1);

            Assert.AreEqual(1, doc.CustomXmlParts.Count);

            // Clone the XML parts collection, and then use the "Clear" method to remove all its elements at once.
            CustomXmlPartCollection customXmlParts = doc.CustomXmlParts.Clone();

            customXmlParts.Clear();

            // Create a structured document tag that will display our part's contents and insert it into the document body.
            StructuredDocumentTag tag = new StructuredDocumentTag(doc, SdtType.PlainText, MarkupLevel.Block);

            tag.XmlMapping.SetMapping(xmlPart, "/root[1]/text[1]", string.Empty);

            doc.FirstSection.Body.AppendChild(tag);

            doc.Save(ArtifactsDir + "StructuredDocumentTag.CustomXml.docx");
            //ExEnd

            Assert.IsTrue(DocumentHelper.CompareDocs(ArtifactsDir + "StructuredDocumentTag.CustomXml.docx", GoldsDir + "StructuredDocumentTag.CustomXml Gold.docx"));

            doc     = new Document(ArtifactsDir + "StructuredDocumentTag.CustomXml.docx");
            xmlPart = doc.CustomXmlParts[0];

            Assert.True(Guid.TryParse(xmlPart.Id, out Guid temp));
            Assert.AreEqual("<root><text>Hello world!</text></root>", Encoding.UTF8.GetString(xmlPart.Data));
            Assert.AreEqual("http://www.w3.org/2001/XMLSchema", xmlPart.Schemas[0]);

            tag = (StructuredDocumentTag)doc.GetChild(NodeType.StructuredDocumentTag, 0, true);
            Assert.AreEqual("Hello world!", tag.GetText().Trim());
            Assert.AreEqual("/root[1]/text[1]", tag.XmlMapping.XPath);
            Assert.AreEqual(string.Empty, tag.XmlMapping.PrefixMappings);
        }
Example #8
0
 internal XmlNode method_2(CustomXmlPartCollection A_0)
 {
     return(this.method_3(A_0, this.method_13()));
 }