PageRenderTime 74ms CodeModel.GetById 5ms RepoModel.GetById 0ms app.codeStats 0ms

/Main/Source/HtmlToMaml/MSHelpKeywordCollection.cs

#
C# | 98 lines | 46 code | 9 blank | 43 comment | 1 complexity | 51f4a4f094ef95133fa779b65d5fb496 MD5 | raw file
Possible License(s): CC-BY-SA-3.0
  1. //=============================================================================
  2. // System : Sandcastle Help File Builder Utilities
  3. // File : MSHelpKeywordCollection.cs
  4. // Author : Eric Woodruff (Eric@EWoodruff.us)
  5. // Updated : 09/16/2008
  6. // Note : Copyright 2008, Eric Woodruff, All rights reserved
  7. // Compiler: Microsoft Visual C#
  8. //
  9. // This file contains a collection class used to hold the help index keyword
  10. // information.
  11. //
  12. // This code is published under the Microsoft Public License (Ms-PL). A copy
  13. // of the license should be distributed with the code. It can also be found
  14. // at the project website: http://www.CodePlex.com/SandcastleStyles. This
  15. // notice, the author's name, and all copyright notices must remain intact in
  16. // all applications, documentation, and source files.
  17. //
  18. // Version Date Who Comments
  19. // ============================================================================
  20. // 1.6.0.7 03/25/2008 EFW Created the code
  21. //=============================================================================
  22. using System;
  23. using System.Collections.Generic;
  24. using System.ComponentModel;
  25. using System.IO;
  26. using System.Text;
  27. using System.Xml;
  28. namespace SandcastleBuilder.Utils
  29. {
  30. /// <summary>
  31. /// This collection class is used to hold the help index keyword items for
  32. /// a project.
  33. /// </summary>
  34. public class MSHelpKeywordCollection : BindingList<MSHelpKeyword>
  35. {
  36. #region Sort collection
  37. //=====================================================================
  38. // Sort the collection
  39. /// <summary>
  40. /// This is used to sort the collection
  41. /// </summary>
  42. /// <remarks>Values are sorted by index name and term</remarks>
  43. public void Sort()
  44. {
  45. ((List<MSHelpKeyword>)base.Items).Sort(
  46. delegate(MSHelpKeyword x, MSHelpKeyword y)
  47. {
  48. return Comparer<MSHelpKeyword>.Default.Compare(x, y);
  49. });
  50. }
  51. #endregion
  52. #region Read/write as XML
  53. //=====================================================================
  54. /// <summary>
  55. /// This is used to save the keyword collection to the project
  56. /// file.
  57. /// </summary>
  58. /// <param name="xw">The XML text writer to which the information
  59. /// is written.</param>
  60. public void WriteXml(XmlWriter xw)
  61. {
  62. if(base.Count > 0)
  63. {
  64. xw.WriteStartElement("HelpKeywords");
  65. foreach(MSHelpKeyword kw in this)
  66. {
  67. xw.WriteStartElement("HelpKeyword");
  68. xw.WriteAttributeString("index", kw.Index);
  69. xw.WriteAttributeString("term", kw.Term);
  70. xw.WriteEndElement();
  71. }
  72. xw.WriteEndElement();
  73. }
  74. }
  75. #endregion
  76. #region Helper methods
  77. //=====================================================================
  78. /// <summary>
  79. /// This is used to mark the collection as changed when there is no
  80. /// associated project.
  81. /// </summary>
  82. public void MarkAsDirty()
  83. {
  84. this.OnListChanged(new ListChangedEventArgs(
  85. ListChangedType.ItemChanged, -1));
  86. }
  87. #endregion
  88. }
  89. }