PlugIn1PlugIn.cs 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Windows.Forms;
  5. using System.Xml.XPath;
  6. using SandcastleBuilder.Utils;
  7. using SandcastleBuilder.Utils.BuildComponent;
  8. using SandcastleBuilder.Utils.BuildEngine;
  9. // Search for "TODO" to find changes that you need to make to this plug-in template.
  10. namespace PlugIn1
  11. {
  12. /// <summary>
  13. /// TODO: Set your plug-in's unique ID and description in the export attribute below.
  14. /// </summary>
  15. /// <remarks>The <c>HelpFileBuilderPlugInExportAttribute</c> is used to export your plug-in so that the help
  16. /// file builder finds it and can make use of it. The example below shows the basic usage for a common
  17. /// plug-in. Set the additional attribute values as needed:
  18. ///
  19. /// <list type="bullet">
  20. /// <item>
  21. /// <term>IsConfigurable</term>
  22. /// <description>Set this to true if your plug-in contains configurable settings. The
  23. /// <c>ConfigurePlugIn</c> method will be called to let the user change the settings.</description>
  24. /// </item>
  25. /// <item>
  26. /// <term>RunsInPartialBuild</term>
  27. /// <description>Set this to true if your plug-in should run in partial builds used to generate
  28. /// reflection data for the API Filter editor dialog or namespace comments used for the Namespace Comments
  29. /// editor dialog. Typically, this is left set to false.</description>
  30. /// </item>
  31. /// </list>
  32. ///
  33. /// Plug-ins are singletons in nature. The composition container will create instances as needed and will
  34. /// dispose of them when the container is disposed of.</remarks>
  35. [HelpFileBuilderPlugInExport("PlugIn1", Version = AssemblyInfo.ProductVersion,
  36. Copyright = AssemblyInfo.Copyright, Description = "PlugIn1 plug-in")]
  37. public sealed class PlugIn1PlugIn : IPlugIn
  38. {
  39. #region Private data members
  40. //=====================================================================
  41. private List<ExecutionPoint> executionPoints;
  42. private BuildProcess builder;
  43. #endregion
  44. #region IPlugIn implementation
  45. //=====================================================================
  46. /// <summary>
  47. /// This read-only property returns a collection of execution points that define when the plug-in should
  48. /// be invoked during the build process.
  49. /// </summary>
  50. public IEnumerable<ExecutionPoint> ExecutionPoints
  51. {
  52. get
  53. {
  54. if (executionPoints == null)
  55. executionPoints = new List<ExecutionPoint>
  56. {
  57. // TODO: Modify this to set your execution points
  58. new ExecutionPoint(BuildStep.ValidatingDocumentationSources, ExecutionBehaviors.Before),
  59. new ExecutionPoint(BuildStep.GenerateReflectionInfo, ExecutionBehaviors.Before)
  60. };
  61. return executionPoints;
  62. }
  63. }
  64. /// <summary>
  65. /// This method is used by the Sandcastle Help File Builder to let the plug-in perform its own
  66. /// configuration.
  67. /// </summary>
  68. /// <param name="project">A reference to the active project</param>
  69. /// <param name="currentConfig">The current configuration XML fragment</param>
  70. /// <returns>A string containing the new configuration XML fragment</returns>
  71. /// <remarks>The configuration data will be stored in the help file builder project</remarks>
  72. public string ConfigurePlugIn(SandcastleProject project, string currentConfig)
  73. {
  74. // TODO: Add and invoke a configuration dialog if you need one. You will also need to set the
  75. // IsConfigurable property to true on the class's export attribute.
  76. MessageBox.Show("This plug-in has no configurable settings", "Build Process Plug-In",
  77. MessageBoxButtons.OK, MessageBoxIcon.Information);
  78. return currentConfig;
  79. }
  80. /// <summary>
  81. /// This method is used to initialize the plug-in at the start of the build process
  82. /// </summary>
  83. /// <param name="buildProcess">A reference to the current build process</param>
  84. /// <param name="configuration">The configuration data that the plug-in should use to initialize itself</param>
  85. public void Initialize(BuildProcess buildProcess, XPathNavigator configuration)
  86. {
  87. builder = buildProcess;
  88. var metadata = (HelpFileBuilderPlugInExportAttribute)this.GetType().GetCustomAttributes(
  89. typeof(HelpFileBuilderPlugInExportAttribute), false).First();
  90. builder.ReportProgress("{0} Version {1}\r\n{2}", metadata.Id, metadata.Version, metadata.Copyright);
  91. // TODO: Add your initialization code here such as reading the configuration data
  92. }
  93. /// <summary>
  94. /// This method is used to execute the plug-in during the build process
  95. /// </summary>
  96. /// <param name="context">The current execution context</param>
  97. public void Execute(ExecutionContext context)
  98. {
  99. // TODO: Add your execution code here
  100. builder.ReportProgress("In PlugIn1PlugIn Execute() method");
  101. }
  102. #endregion
  103. #region IDisposable implementation
  104. //=====================================================================
  105. // TODO: If the plug-in hasn't got any disposable resources, this finalizer can be removed
  106. /// <summary>
  107. /// This handles garbage collection to ensure proper disposal of the plug-in if not done explicitly
  108. /// with <see cref="Dispose()"/>.
  109. /// </summary>
  110. ~PlugIn1PlugIn()
  111. {
  112. this.Dispose();
  113. }
  114. /// <summary>
  115. /// This implements the Dispose() interface to properly dispose of the plug-in object
  116. /// </summary>
  117. public void Dispose()
  118. {
  119. // TODO: Dispose of any resources here if necessary
  120. GC.SuppressFinalize(this);
  121. }
  122. #endregion
  123. }
  124. }