Beispiel #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:GsmComm.PduConverter.RelativeValidityPeriod" />.
        /// </summary>
        /// <param name="period">The validity period.</param>
        /// <remarks>
        /// There are some rules to note:
        /// <list type="bullet">
        /// <item><description>
        /// The smallest validity period is 5 minutes, 63 weeks the largest.
        /// </description></item>
        /// <item><description>
        /// Periods between 5 minutes and 12 hours can be specified in 5 minute steps.
        /// </description></item>
        /// <item><description>
        /// Periods between 12h30min and 24 hours can be specified in 30 minute steps.
        /// </description></item>
        /// <item><description>
        /// Periods between two days and 30 days can be specified in 1 day steps.
        /// </description></item>
        /// <item><description>
        /// Periods between 5 weeks and 63 weeks can be specified in 1 week (=7 days) steps.
        /// </description></item>
        /// </list>
        /// </remarks>
        /// <exception cref="T:System.ArgumentException">Validity timespan is invalid.</exception>
        public RelativeValidityPeriod(TimeSpan period)
        {
            byte num = 0;

            while (num <= 255)
            {
                TimeSpan timeSpan = RelativeValidityPeriod.ToTimeSpan(num);
                if (timeSpan.CompareTo(period) != 0)
                {
                    num = (byte)(num + 1);
                }
                else
                {
                    this.@value = num;
                    return;
                }
            }
            throw new ArgumentException("Invalid validity timespan.");
        }
Beispiel #2
0
 /// <summary>
 /// Returns the TimeSpan equivalent of this instance.
 /// </summary>
 /// <returns>The TimeSpan value.</returns>
 public TimeSpan ToTimeSpan()
 {
     return(RelativeValidityPeriod.ToTimeSpan(this.@value));
 }