Ejemplo n.º 1
0
        public string SignDocument(string xml)
        {
            var doc = new SignedXmlDocument(xml);

            CrytoProvider.SignDocument(doc);
            var cdata = new XCData(doc.ToString());

            return(cdata.ToString());
        }
        static void Main(string[] args)
        {
            XDocument doc = XDocument.Load(FILENAME);

            foreach (XElement node in doc.Descendants("Node"))
            {
                XElement songs    = node.Descendants("songs").FirstOrDefault();
                XCData   child    = (XCData)songs.FirstNode;
                string   childStr = child.ToString();
                childStr = childStr.Replace("Some text here", "Some text there");
                child.ReplaceWith(childStr);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Tests the CDATA element
        /// </summary>
        public void HtmlElement_Cdata()
        {
            Browser b = new Browser();

            b.SetContent(Helper.GetFromResources("SimpleBrowser.UnitTests.SampleDocs.CommentElements.htm"));
            b.Find("link1");

            IEnumerable <XCData> comments = from node in b.XDocument.Elements().DescendantNodesAndSelf()
                                            where node.NodeType == XmlNodeType.CDATA
                                            select node as XCData;

            XCData comment = comments.First();

            Assert.That(comment.ToString(), Is.EqualTo("<![CDATA[Some content]]>"));
        }
Ejemplo n.º 4
0
        private string RemoveHyperlinks(string text)
        {
            // removes hyperlinks from the text of a heading so the TOC hyperlink can be applied

            // clean up illegal directives; can be caused by using "Clip to OneNote" from Edge
            var wrapper = new XCData(text).GetWrapper();
            var links   = wrapper.Elements("a").ToList();

            foreach (var link in links)
            {
                link.ReplaceWith(link.Value);
            }

            return(wrapper.ToString(SaveOptions.DisableFormatting));
        }
Ejemplo n.º 5
0
        public void Disassemble(IPipelineContext pContext, IBaseMessage pInMsg)
        {
            var inStream  = pInMsg.BodyPart.GetOriginalDataStream();
            var encoding  = Encoding.GetEncoding(string.IsNullOrWhiteSpace(EncodingName) ? "utf-8" : EncodingName);
            var outStream = new MemoryStream();

            using (var sr = new StreamReader(inStream, encoding, true, 1024 * 4, true))
                using (var sw = new StreamWriter(outStream, utf8, 1024 * 4, true))
                {
                    var cdata = new XCData(sr.ReadToEnd());

                    sw.Write("<string>");
                    sw.Write(cdata.ToString());
                    sw.Write("</string>");
                }

            outStream.Position   = 0;
            pInMsg.BodyPart.Data = outStream;
            pContext.ResourceTracker.AddResource(outStream);
            pInMsg.Context.Promote("MessageType", "http://schemas.microsoft.com/BizTalk/2003/system-properties", "string");

            _queue.Enqueue(pInMsg);
        }