Exemplo n.º 1
0
 /// <summary>
 ///   Adds the contents of another <see cref='TimeRangeCollection'/> to the end of the collection.
 /// </summary>
 /// <param name='val'>
 ///    A <see cref='TimeRangeCollection'/> containing the objects to add to the collection.
 /// </param>
 /// <seealso cref='TimeRangeCollection.Add'/>
 public void AddRange(TimeRangeCollection val)
 {
     for (int i = 0; i < val.Count; i++)
     {
         this.Add(val[i]);
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// This creates a <c>DayTimeConstraint</c> from an <see cref="System.Xml.XmlNode">XmlNode</see>.
        /// </summary>
        /// <param name="itemsNode">
        /// A <see cref="XmlNode">XmlNode</see> representing the <c>DayTimeConstraint</c>.
        /// </param>
        /// <exception cref="ArgumentNullException">
        /// Thrown if the <see cref="XmlNode">XmlNode</see> is null.
        /// </exception>
        public override void FromXml(XmlNode itemsNode)
        {
            if (itemsNode == null)
            {
                throw new ArgumentNullException("The license data is null.");
            }

            XmlNode     nameTextNode        = itemsNode.SelectSingleNode("Name/text()");
            XmlNode     descriptionTextNode = itemsNode.SelectSingleNode("Description/text()");
            XmlNodeList rangeListNode       = itemsNode.SelectNodes("Range");

            if (nameTextNode != null)
            {
                Name = nameTextNode.Value;
            }

            if (descriptionTextNode != null)
            {
                Description = descriptionTextNode.Value;
            }

            if (this.timeRange == null && rangeListNode.Count > 0)
            {
                this.timeRange = new TimeRangeCollection( );
            }

            for (int i = 0; i < rangeListNode.Count; i++)
            {
                XmlAttributeCollection attrColection = ((XmlNode)rangeListNode[i]).Attributes;

                XmlAttribute startTimeNode = (XmlAttribute)attrColection.GetNamedItem("StartTime");
                XmlAttribute endTimeNode   = (XmlAttribute)attrColection.GetNamedItem("EndTime");

                Time start = null;
                Time end   = null;

                if (startTimeNode != null)
                {
                    start = new Time(Convert.ToInt32(startTimeNode.Value));
                }

                if (endTimeNode != null)
                {
                    end = new Time(Convert.ToInt32(endTimeNode.Value));
                }

                this.timeRange.Add(new TimeRange(start, end));
            }
        }
Exemplo n.º 3
0
 /// <summary>
 ///   Initializes a new instance of <see cref='TimeRangeEnumerator'/>.
 /// </summary>
 public TimeRangeEnumerator(TimeRangeCollection mappings)
 {
     this.temp           = ((IEnumerable)(mappings));
     this.baseEnumerator = temp.GetEnumerator();
 }
Exemplo n.º 4
0
 /// <summary>
 ///   Initializes a new instance of <see cref='TimeRangeCollection'/> based on another <see cref='TimeRangeCollection'/>.
 /// </summary>
 /// <param name='val'>
 ///   A <see cref='TimeRangeCollection'/> from which the contents are copied
 /// </param>
 public TimeRangeCollection(TimeRangeCollection val)
 {
     this.AddRange(val);
 }