PageRenderTime 41ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/Mercurial.Net/Gui/BrowserGuiCommandBase.cs

#
C# | 106 lines | 45 code | 7 blank | 54 comment | 0 complexity | 621a7e42c4d6ec5a37574be7ed1c73f4 MD5 | raw file
Possible License(s): BSD-3-Clause, GPL-2.0
  1. using System;
  2. using System.ComponentModel;
  3. using Mercurial.Attributes;
  4. namespace Mercurial.Gui
  5. {
  6. /// <summary>
  7. /// This is the base class for <see cref="AnnotateGuiCommand"/> and <see cref="ManifestGuiCommand"/>.
  8. /// </summary>
  9. /// <typeparam name="T">
  10. /// The actual type descending from <see cref="BrowserGuiCommandBase{T}"/>, used to generate type-correct
  11. /// methods in this base class.
  12. /// </typeparam>
  13. public abstract class BrowserGuiCommandBase<T> : GuiCommandBase<T>
  14. where T : BrowserGuiCommandBase<T>
  15. {
  16. /// <summary>
  17. /// This is the backing field for the <see cref="SearchPattern"/> property.
  18. /// </summary>
  19. private string _SearchPattern = string.Empty;
  20. /// <summary>
  21. /// Initializes a new instance of the <see cref="BrowserGuiCommandBase{T}"/> class.
  22. /// </summary>
  23. /// <param name="command">
  24. /// The name of the command that will be passed to the TortoiseHg command line client.
  25. /// </param>
  26. /// <exception cref="ArgumentNullException">
  27. /// <para><paramref name="command"/> is <c>null</c> or empty.</para>
  28. /// </exception>
  29. protected BrowserGuiCommandBase(string command)
  30. : base(command)
  31. {
  32. // Do nothing here
  33. }
  34. /// <summary>
  35. /// Gets or sets the <see cref="RevSpec"/> to annotate or show the manifest for.
  36. /// Default value is <c>null</c>.
  37. /// </summary>
  38. [NullableArgument(NonNullOption = "--rev")]
  39. [DefaultValue(null)]
  40. public RevSpec Revision
  41. {
  42. get;
  43. set;
  44. }
  45. /// <summary>
  46. /// Gets or sets the initial search pattern.
  47. /// Default value is <see cref="string.Empty"/>.
  48. /// </summary>
  49. [NullableArgument(NonNullOption = "--pattern")]
  50. [DefaultValue("")]
  51. public string SearchPattern
  52. {
  53. get
  54. {
  55. return _SearchPattern;
  56. }
  57. set
  58. {
  59. _SearchPattern = (value ?? string.Empty).Trim();
  60. }
  61. }
  62. /// <summary>
  63. /// Sets the <see cref="Revision"/> property to the specified value and
  64. /// returns this command instance.
  65. /// </summary>
  66. /// <param name="value">
  67. /// The new value for the <see cref="Revision"/> property.
  68. /// </param>
  69. /// <returns>
  70. /// This command instance.
  71. /// </returns>
  72. /// <remarks>
  73. /// This method is part of the fluent interface.
  74. /// </remarks>
  75. public T WithRevision(RevSpec value)
  76. {
  77. Revision = value;
  78. return (T)this;
  79. }
  80. /// <summary>
  81. /// Sets the <see cref="SearchPattern"/> property to the specified value and
  82. /// returns this command instance.
  83. /// </summary>
  84. /// <param name="value">
  85. /// The new value for the <see cref="SearchPattern"/> property.
  86. /// </param>
  87. /// <returns>
  88. /// This command instance.
  89. /// </returns>
  90. /// <remarks>
  91. /// This method is part of the fluent interface.
  92. /// </remarks>
  93. public T WithSearchPattern(string value)
  94. {
  95. SearchPattern = value;
  96. return (T)this;
  97. }
  98. }
  99. }