PageRenderTime 5ms CodeModel.GetById 1ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/Mercurial.Net/Gui/MoveCopyRenameGuiCommandBase.cs

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