Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Project"/> class.
        /// </summary>
        public Project()
        {
            _tasks         = new TasksList();
            _triggers      = new TriggersList( );
            _publishers    = new PublishersList( );
            _externalLinks = new CloneableList <ExternalLink> ();
            _extensions    = new CloneableList <ProjectExtension> ();
            _prebuild      = new PrebuildsList( );

            foreach (Type type in Util.ProjectExtensions)
            {
                this.ProjectExtensions.Add((ProjectExtension)Util.CreateInstanceOfType(type));
            }
        }
Пример #2
0
        /// <summary>
        /// Creates a deep copy of this collection.
        /// </summary>
        /// <returns></returns>
        public virtual CloneableList <T> Clone( )
        {
            CloneableList <T> list = new CloneableList <T> ( );

            foreach (T item in this)
            {
                if (typeof(T).GetType( ).GetInterface("System.ICloneable", true) != null)
                {
                    ICloneable citem = item as ICloneable;
                    if (citem != null)
                    {
                        list.Add(( T )citem.Clone( ));
                    }
                    else
                    {
                        list.Add(( T )citem);
                    }
                }
            }
            return(list);
        }
Пример #3
0
        /// <summary>
        /// Deserializes the specified element.
        /// </summary>
        /// <param name="element">The element.</param>
        public void Deserialize(XmlElement element)
        {
            Version versionInfo = Util.GetTypeDescriptionProviderVersion(this.GetType());

            this.ArtifactDirectory        = string.Empty;
            this._externalLinks           = new CloneableList <ExternalLink> ();
            this.Labeller                 = null;
            this.ModificationDelaySeconds = null;
            this._name = string.Empty;
            this.Publishers.Clear();
            this.PublishExceptions = null;
            this.SourceControl     = null;
            this.State             = null;
            this.Tasks.Clear();
            this.Triggers.Clear();
            this.PreBuild.Clear();
            this.WebUrl           = null;
            this.WorkingDirectory = string.Empty;
            this._extensions      = new CloneableList <ProjectExtension> ();
            this.QueuePriority    = null;
            this.Queue            = string.Empty;
            this.Category         = string.Empty;

            if (string.Compare(element.Name, "project", false) != 0)
            {
                throw new InvalidCastException(string.Format("Unable to deserialize a project from a {0} element.", element.Name));
            }

            this.Name = Util.GetElementOrAttributeValue("name", element);

            if (versionInfo.CompareTo(new Version("1.3")) >= 0)
            {
                this.Queue = Util.GetElementOrAttributeValue("queue", element);
                int qp = 0;
                if (int.TryParse(Util.GetElementOrAttributeValue("queuePriority", element), out qp))
                {
                    this.QueuePriority = qp;
                }
                this.Category = Util.GetElementOrAttributeValue("category", element);
            }

            string s = Util.GetElementOrAttributeValue("workingDirectory", element);

            if (!string.IsNullOrEmpty(s))
            {
                this.WorkingDirectory = s;
            }

            s = Util.GetElementOrAttributeValue("artifactDirectory", element);
            if (!string.IsNullOrEmpty(s))
            {
                this.ArtifactDirectory = s;
            }

            s = Util.GetElementOrAttributeValue("webURL", element);
            if (!string.IsNullOrEmpty(s))
            {
                this.WebUrl = new Uri(s);
            }

            s = Util.GetElementOrAttributeValue("modificationDelaySeconds", element);
            if (!string.IsNullOrEmpty(s))
            {
                int mds = 0;
                if (int.TryParse(s, out mds))
                {
                    this.ModificationDelaySeconds = mds;
                }
            }

            if (Util.IsInVersionRange(null, new Version("1.2.1"), versionInfo))
            {
                s = Util.GetElementOrAttributeValue("publishExceptions", element);
                if (!string.IsNullOrEmpty(s))
                {
                    this.PublishExceptions = string.Compare(s, bool.TrueString, true) == 0;
                }
            }

            XmlElement ele = element.SelectSingleNode("triggers") as XmlElement;

            if (ele != null)
            {
                foreach (XmlElement trig in ele.SelectNodes("./*"))
                {
                    Trigger trigger = Util.GetTriggerFromElement(trig);
                    if (trigger != null)
                    {
                        this.Triggers.Add(trigger);
                    }
                }
            }

            ele = element.SelectSingleNode("sourcecontrol") as XmlElement;
            if (ele != null)
            {
                SourceControl sc = Util.GetSourceControlFromElement(ele);
                if (sc != null)
                {
                    this.SourceControl = sc;
                }
            }

            ele = element.SelectSingleNode("labeller") as XmlElement;
            if (ele != null)
            {
                Labeller labeller = Util.GetLabellerFromElement(ele);
                if (labeller != null)
                {
                    this.Labeller = labeller;
                }
            }

            ele = element.SelectSingleNode("state") as XmlElement;
            if (ele != null)
            {
                State state = Util.GetStateFromElement(ele);
                this.State = state;
            }

            ele = element.SelectSingleNode("tasks") as XmlElement;
            if (ele != null)
            {
                foreach (XmlElement t in ele.SelectNodes("./*"))
                {
                    PublisherTask task = Util.GetPublisherTaskFromElement(t);
                    if (task != null)
                    {
                        this.Tasks.Add(task);
                    }
                }
            }

            ele = element.SelectSingleNode("publishers") as XmlElement;
            if (ele != null)
            {
                foreach (XmlElement t in ele.SelectNodes("./*"))
                {
                    PublisherTask pub = Util.GetPublisherTaskFromElement(t);
                    if (pub != null)
                    {
                        this.Publishers.Add(pub);
                    }
                }
            }

            ele = element.SelectSingleNode("preBuild") as XmlElement;
            if (ele == null) // reported that either are acceptable.
            {
                ele = element.SelectSingleNode("prebuild") as XmlElement;
            }

            if (ele != null)
            {
                foreach (XmlElement t in ele.SelectNodes("./*"))
                {
                    PublisherTask task = Util.GetPublisherTaskFromElement(t);
                    if (task != null)
                    {
                        this.PreBuild.Add(task);
                    }
                }
            }

            ele = element.SelectSingleNode("externalLinks") as XmlElement;
            if (ele != null)
            {
                foreach (XmlElement eleUrl in ele.SelectNodes("externalLink"))
                {
                    ExternalLink el = new ExternalLink();
                    el.Deserialize(eleUrl);
                    this.ExternalLinks.Add(el);
                }
            }

            foreach (Type type in Util.ProjectExtensions)
            {
                this.ProjectExtensions.Add((ProjectExtension)Util.CreateInstanceOfType(type));
            }

            XmlElement securityEl = element.SelectSingleNode("security") as XmlElement;

            if (securityEl != null)
            {
                string          xmlName  = securityEl.GetAttribute("type");
                ProjectSecurity security = Util.CreateInstanceFromXmlName <ProjectSecurity>(xmlName);
                if (security != null)
                {
                    security.Deserialize(securityEl);
                    Security = security;
                }
            }
        }