ItemStatus.cs :  » Build-Systems » CruiseControl.NET » ThoughtWorks » CruiseControl » Remote » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » Build Systems » CruiseControl.NET 
CruiseControl.NET » ThoughtWorks » CruiseControl » Remote » ItemStatus.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;
using System.Xml;

namespace ThoughtWorks.CruiseControl.Remote{
    /// <summary>
    /// Defines the status on an item.
    /// </summary>
    [Serializable]
    [XmlRoot("itemStatus")]
    public class ItemStatus
    {
        #region Private fields
        private Guid identifier = Guid.NewGuid();
        private string name;
        private ItemBuildStatus status = ItemBuildStatus.Unknown;
        private DateTime? timeStarted;
        private DateTime? timeCompleted;
        private DateTime? timeOfEstimatedCompletion;
        private string description;
        private List<ItemStatus> childItems = new List<ItemStatus>();
        private ItemStatus parent;
        #endregion

        #region Constructors
        /// <summary>
        /// Initialise a new blank <see cref="ItemStatus"/>.
        /// </summary>
        public ItemStatus()
        {
        }

        /// <summary>
        /// Initialise a new <see cref="ItemStatus"/> with a name.
        /// </summary>
        /// <param name="name">The name of the item.</param>
        public ItemStatus(string name)
        {
            this.name = name;
        }
        #endregion

        #region Public properties
        #region Identifier
        /// <summary>
        /// The unique identifier of the item.
        /// </summary>
        [XmlAttribute("identifier")]
        public Guid Identifier
        {
            get { return identifier; }
        }
        #endregion

        #region Name
        /// <summary>
        /// The name of the item.
        /// </summary>
        [XmlAttribute("name")]
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        #endregion

        #region Description
        /// <summary>
        /// The name of the item.
        /// </summary>
        [XmlElement("description")]
        public string Description
        {
            get { return description; }
            set { description = value; }
        }
        #endregion

        #region Error
        /// <summary>
        /// Any error message for why the item failed.
        /// </summary>
        [XmlElement("error")]
        public string Error { get; set; }
        #endregion

        #region Status
        /// <summary>
        /// The status of the item.
        /// </summary>
        [XmlAttribute("status")]
        public ItemBuildStatus Status
        {
            get { return status; }
            set { status = value; }
        }
        #endregion

        #region TimeStarted
        /// <summary>
        /// The date and time the item started building.
        /// </summary>
        [XmlElement("timeStarted")]
        public DateTime? TimeStarted
        {
            get { return timeStarted; }
            set { timeStarted = value; }
        }
        #endregion

        #region TimeCompleted
        /// <summary>
        /// The date and time the item completed building.
        /// </summary>
        [XmlElement("timeCompleted")]
        public DateTime? TimeCompleted
        {
            get { return timeCompleted; }
            set { timeCompleted = value; }
        }
        #endregion

        #region TimeOfEstimatedCompletion
        /// <summary>
        /// The date and time the item is estimated to complete building.
        /// </summary>
        [XmlElement("timeOfEstimatedCompletion")]
        public DateTime? TimeOfEstimatedCompletion
        {
            get { return timeOfEstimatedCompletion; }
            set { timeOfEstimatedCompletion = value; }
        }
        #endregion

        #region ChildItems
        /// <summary>
        /// Any child status items.
        /// </summary>
        [XmlArray("childItems")]
        [XmlArrayItem("childItem")]
        public List<ItemStatus> ChildItems
        {
            get { return childItems; }
        }
        #endregion

        #region Parent
        /// <summary>
        /// The parent of this item.
        /// </summary>
        [XmlIgnore()]
        public ItemStatus Parent
        {
            get { return parent; }
            set { parent = value; }
        }
        #endregion
        #endregion

        #region Public methods
        #region AddChild()
        /// <summary>
        /// Adds a child and correctly links it.
        /// </summary>
        /// <param name="child"></param>
        public void AddChild(ItemStatus child)
        {
            child.parent = this;
            childItems.Add(child);
        }
        #endregion

        #region Clone()
        /// <summary>
        /// Generates a clone of this status.
        /// </summary>
        /// <returns></returns>
        public virtual ItemStatus Clone()
        {
            ItemStatus clone = new ItemStatus();
            CopyTo(clone);
            return clone;
        }
        #endregion

        #region CopyTo()
        /// <summary>
        /// Copies this item to another.
        /// </summary>
        /// <param name="value"></param>
        public virtual void CopyTo(ItemStatus value)
        {
            value.identifier = identifier;
            value.description = description;
            value.name = name;
            value.status = status;
            value.timeCompleted = timeCompleted;
            value.timeOfEstimatedCompletion = timeOfEstimatedCompletion;
            value.timeStarted = timeStarted;
            foreach (ItemStatus item in childItems)
            {
                value.AddChild(item.Clone());
            };
        }
        #endregion

        #region GetHashCode()
        /// <summary>
        /// Gets the hash code for the status.
        /// </summary>
        /// <returns></returns>
        public override int GetHashCode()
        {
            return identifier.GetHashCode();
        }
        #endregion

        #region Equals()
        /// <summary>
        /// Checks if two statuses are the same.
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public override bool Equals(object obj)
        {
            if (obj is ItemStatus)
            {
                bool areEqual = identifier.Equals((obj as ItemStatus).identifier);
                return areEqual;
            }
            else
            {
                return false;
            }
        }
        #endregion

        #region ToString()
        /// <summary>
        /// Returns an XML representation of the status.
        /// </summary>
        /// <returns></returns>
        public override string ToString()
        {
            XmlSerializer serialiser = new XmlSerializer(this.GetType());
            StringBuilder builder = new StringBuilder();
            XmlWriterSettings settings = new XmlWriterSettings();
            settings.Encoding = UTF8Encoding.UTF8;
            settings.Indent = false;
            settings.OmitXmlDeclaration = true;
            XmlWriter writer = XmlWriter.Create(builder, settings);
            serialiser.Serialize(writer, this);
            return builder.ToString();
        }
        #endregion
        #endregion
    }
}
www.java2v.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.