PageRenderTime 45ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/Mercurial.Net/Gui/MoveCopyRenameGuiCommandBase.cs

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