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 993B

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