Ejemplo n.º 1
0
        /// <summary>
        /// Deserializes the specified element.
        /// </summary>
        /// <param name="element">The element.</param>
        public override void Deserialize(XmlElement element)
        {
            this.BuildCondition = null;
            this.Seconds        = null;
            this.Name           = string.Empty;

            if (string.Compare(element.Name, this.TypeName, false) != 0)
            {
                throw new InvalidCastException(string.Format("Unable to convert {0} to a {1}", element.Name, this.TypeName));
            }

            if (!string.IsNullOrEmpty(element.GetAttribute("name")))
            {
                this.Name = element.GetAttribute("name");
            }

            if (!string.IsNullOrEmpty(element.GetAttribute("seconds")))
            {
                int i = 0;
                if (int.TryParse(element.GetAttribute("seconds"), out i))
                {
                    this.Seconds = i;
                }
                else
                {
                    this.Seconds = null;
                }
            }

            if (!string.IsNullOrEmpty(element.GetAttribute("buildCondition")))
            {
                Core.Enums.BuildCondition bc = (Core.Enums.BuildCondition)Enum.Parse(typeof(Core.Enums.BuildCondition), element.GetAttribute("buildCondition"), true);
                this.BuildCondition = bc;
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Deserializes the specified element.
        /// </summary>
        /// <param name="element">The element.</param>
        public override void Deserialize(XmlElement element)
        {
            this.Trigger  = null;
            this.WeekDays = new CloneableList <DayOfWeek> ();

            if (string.Compare(element.Name, this.TypeName, false) != 0)
            {
                throw new InvalidCastException(string.Format("Unable to convert {0} to a {1}", element.Name, this.TypeName));
            }

            TimeSpan ts = new TimeSpan(0);

            TimeSpan.TryParse(element.GetAttribute("startTime"), out ts);
            this.StartTime = ts;
            TimeSpan.TryParse(element.GetAttribute("endTime"), out ts);
            this.EndTime = ts;

            // this is the filter trigger
            XmlElement ele = (XmlElement)element.SelectSingleNode("trigger");

            if (ele != null)
            {
                XmlElement nElement = element.OwnerDocument.CreateElement(ele.GetAttribute("type"));
                foreach (XmlAttribute attrib in ele.Attributes)
                {
                    nElement.SetAttribute(attrib.Name, attrib.InnerText);
                }
                this.Trigger = Util.GetTriggerFromElement(nElement);
            }

            // get the weekdays
            ele = (XmlElement)element.SelectSingleNode("weekDays");
            if (ele != null)
            {
                foreach (XmlElement wde in ele.SelectNodes("weekDay"))
                {
                    DayOfWeek dow = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), wde.InnerText, true);
                    this.WeekDays.Add(dow);
                }
            }

            // get the build condition
            ele = (XmlElement)element.SelectSingleNode("buildCondition");
            if (ele != null)
            {
                Core.Enums.BuildCondition bc = (Core.Enums.BuildCondition)Enum.Parse(typeof(Core.Enums.BuildCondition), ele.InnerText, true);
                this.BuildCondition = bc;
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Deserializes the specified element.
        /// </summary>
        /// <param name="element">The element.</param>
        public override void Deserialize(XmlElement element)
        {
            this.WeekDays       = new CloneableList <DayOfWeek> ();
            this.BuildCondition = null;

            if (string.Compare(element.Name, this.TypeName, false) != 0)
            {
                throw new InvalidCastException(string.Format("Unable to convert {0} to a {1}", element.Name, this.TypeName));
            }

            TimeSpan ts = new TimeSpan(0, 0, 0);

            TimeSpan.TryParse(element.GetAttribute("time"), out ts);
            this.Time = ts;

            if (!string.IsNullOrEmpty(element.GetAttribute("name")))
            {
                this.Name = element.GetAttribute("name");
            }

            if (!string.IsNullOrEmpty(element.GetAttribute("buildCondition")))
            {
                Core.Enums.BuildCondition bc = (Core.Enums.BuildCondition)Enum.Parse(typeof(Core.Enums.BuildCondition), element.GetAttribute("buildCondition"), true);
                this.BuildCondition = bc;
            }

            XmlElement ele = (XmlElement)element.SelectSingleNode("weekDays");

            if (ele != null)
            {
                foreach (XmlElement wde in ele.SelectNodes("weekDay"))
                {
                    DayOfWeek dow = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), wde.InnerText, true);
                    this.WeekDays.Add(dow);
                }
            }
        }