You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DocProperty.cs 836B

123456789101112131415161718192021222324
  1. using System.Xml.Linq;
  2. using System.Text.RegularExpressions;
  3. namespace Novacode
  4. {
  5. /// <summary>
  6. /// Represents a field of type document property. This field displays the value stored in a custom property.
  7. /// </summary>
  8. public class DocProperty: DocXElement
  9. {
  10. internal Regex extractName = new Regex(@"DOCPROPERTY (?<name>.*) ");
  11. /// <summary>
  12. /// The custom property to display.
  13. /// </summary>
  14. public string Name { get; }
  15. internal DocProperty(DocX document, XElement xml):base(document, xml)
  16. {
  17. string instr = Xml.Attribute(XName.Get("instr", "http://schemas.openxmlformats.org/wordprocessingml/2006/main")).Value;
  18. Name = extractName.Match(instr.Trim()).Groups["name"].Value;
  19. }
  20. }
  21. }