/* * Copyright (c) 2009 Craig Sutherland * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, * copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following * conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. */ namespace FastForward.Monitor { using System; using System.ComponentModel; using System.Linq; using ThoughtWorks.CruiseControl.Remote.Monitor; using ThoughtWorks.CruiseControl.Remote; /// /// Exposes the properties of a server. /// [TypeConverter(typeof(ExpandableObjectConverter))] public class ServerProperties : INotifyPropertyChanged, IDisposable { #region Private fields private Server item; #endregion #region Constructors /// /// Initializes a new instance of the classes. /// /// The item to display. public ServerProperties(Server item) { this.item = item; this.item.PropertyChanged += this.item_PropertyChanged; } #endregion #region Public properties #region Name /// /// The name of the server. /// [DisplayName("Server Name")] [Category("Metadata")] [Description("The name of the server.")] public string Name { get { return item.GetDisplayName(); } } #endregion #region Address /// /// The address of the server. /// [DisplayName("Address")] [Category("Metadata")] [Description("The address of the server.")] public string Address { get { return item.TargetAddress; } } #endregion #region Projects /// /// The projects for the server. /// [DisplayName("Project Count")] [Category("Configuration")] [Description("The number of configured projects.")] public int Projects { get { return item.Projects.Count(); } } #endregion #region BuildQueues /// /// The build queues for the server. /// [DisplayName("Queue Count")] [Category("Configuration")] [Description("The number of build queues.")] public int BuildQueues { get { return item.BuildQueues.Count(); } } #endregion #region Version /// /// The current version of the server. /// [DisplayName("Version")] [Category("Metadata")] [Description("The version of the server.")] public Version Version { get { return item.Version; } } #endregion #region IsLoggedIn /// /// Is there a user logged in (i.e. does the client has a valid session.) /// [DisplayName("Is Logged On")] [Category("Status")] [Description("Is there a logged on ccount.")] public bool IsLoggedIn { get { return item.IsLoggedIn; } } #endregion #endregion #region Public events #region PropertyChanged /// /// A property on the underlying item has changed. /// public event PropertyChangedEventHandler PropertyChanged; #endregion #endregion #region Event handlers #region item_PropertyChanged() /// /// A property on the item has changed. /// /// /// private void item_PropertyChanged(object sender, PropertyChangedEventArgs e) { if (PropertyChanged != null) { PropertyChanged(this, e); } } #endregion #endregion #region Public methods #region Dispose() /// /// Dispose of this item. /// public void Dispose() { this.item.PropertyChanged -= this.item_PropertyChanged; } #endregion #region ToString() /// /// Returns the name of the item. /// /// public override string ToString() { return item.Name; } #endregion #endregion } }