Novacode.DocX.AddHyperlink C# (CSharp) Method

AddHyperlink() public method

Adds a hyperlink to a document and creates a Paragraph which uses it.
public AddHyperlink ( string text, Uri uri ) : Novacode.Hyperlink
text string The text as displayed by the hyperlink.
uri System.Uri The hyperlink itself.
return Novacode.Hyperlink
        public Hyperlink AddHyperlink(string text, Uri uri)
        {
            XElement i = new XElement
            (
                XName.Get("hyperlink", w.NamespaceName),
                new XAttribute(r + "id", string.Empty),
                new XAttribute(w + "history", "1"),
                new XElement(XName.Get("r", w.NamespaceName),
                new XElement(XName.Get("rPr", w.NamespaceName),
                new XElement(XName.Get("rStyle", w.NamespaceName),
                new XAttribute(w + "val", "Hyperlink"))),
                new XElement(XName.Get("t", w.NamespaceName), text))
            );

            Hyperlink h = new Hyperlink(this, mainPart, i);

            h.text = text;
            h.uri = uri;

            AddHyperlinkStyleIfNotPresent();

            return h;
        }