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