Esempio n. 1
0
        /// <summary>
        /// Extracts the xml for the given attribute.
        /// </summary>
        /// <returns>The xml contents, as a <see cref="DocPiece"/>.</returns>
        /// <param name="element">An <see cref="T:System.Xml.Linq.XElement"/>.</param>
        /// <param name="attr">The <see cref="T:Attribute"/> for the doc piece to extract.</param>
        static DocPiece[] ExtractXmlFor(XElement element, Attribute attr)
        {
            var toret         = new List <DocPiece>();
            var contentsNodes = element.Elements(GetXmlTagFor(attr));

            if (contentsNodes != null)
            {
                foreach (XElement contents in contentsNodes)
                {
                    XNode      child    = contents.FirstNode;
                    string     name     = attr.ToString();
                    XAttribute attrName = contents.Attribute("name");

                    if (attr == Attribute.Param &&
                        attrName != null)
                    {
                        name = attrName.Value;
                    }

                    var docPiece = new DocPiece(name, "");

                    toret.Add(docPiece);

                    while (child != null)
                    {
                        if (child is XText text)
                        {
                            docPiece.Contents += text.Value;
                        }
                        else
                        if (child is XElement subElement)
                        {
                            docPiece.Add(
                                Modifier.Create(
                                    docPiece.Contents.Length,
                                    subElement));
                        }

                        child = child.NextNode;
                    }
                }
            }

            return(toret.ToArray());
        }
Esempio n. 2
0
 /// <summary>
 /// Adds the specified param.
 /// </summary>
 /// <param name="param">The <see cref="DocPiece"/> for the parameter.</param>
 public void AddParameter(DocPiece param)
 {
     this.parameters.Add(param.Name, param);
 }
Esempio n. 3
0
 /// <summary>
 /// Add the specified attr and contents.
 /// </summary>
 /// <param name="attr">An <see cref="Attribute"/>.</param>
 /// <param name="contents">The contents, as a string.</param>
 public void Add(Attribute attr, DocPiece contents)
 {
     this.attributes.Add(attr, contents);
 }