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

1234567891011121314151617181920212223242526272829
  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: DocXElement
  13. {
  14. internal Regex extractName = new Regex(@"DOCPROPERTY (?<name>.*) ");
  15. private string name;
  16. /// <summary>
  17. /// The custom property to display.
  18. /// </summary>
  19. public string Name { get { return name; } }
  20. internal DocProperty(DocX document, XElement xml):base(document, xml)
  21. {
  22. string instr = Xml.Attribute(XName.Get("instr", "http://schemas.openxmlformats.org/wordprocessingml/2006/main")).Value;
  23. this.name = extractName.Match(instr.Trim()).Groups["name"].Value;
  24. }
  25. }
  26. }