コード例 #1
0
 /// <summary>
 /// Unions the specified interval.
 /// </summary>
 /// <param name="interval">The interval.</param>
 /// <returns></returns>
 public DateTimeInterval Union(DateTimeInterval interval)
 {
     return(new DateTimeInterval
            (
                DateTimeUtility.Min
                (
                    Beginning,
                    interval.Beginning),
                DateTimeUtility.Max
                (
                    Ending,
                    interval.Ending)));
 }
コード例 #2
0
        /// <summary>
        /// Converts the given object to the type of this converter,
        /// using the specified context and culture information.
        /// </summary>
        /// <returns>
        /// An <see cref="System.Object"/>
        /// that represents the converted value.
        /// </returns>
        /// <param name="culture">The
        /// <see cref="T:System.Globalization.CultureInfo"/>
        /// to use as the current culture.</param>
        /// <param name="context">An
        /// <see cref="T:System.ComponentModel.ITypeDescriptorContext"/>
        /// that provides a format context.</param>
        /// <param name="value">The <see cref="T:System.Object"/>
        /// to convert.</param>
        /// <exception cref="T:System.NotSupportedException">
        /// The conversion cannot be performed.</exception>
        public override object ConvertFrom
        (
            ITypeDescriptorContext context,
            CultureInfo culture,
            object value)
        {
            string text = value as string;

            if (!string.IsNullOrEmpty(text))
            {
                return(DateTimeInterval.Parse
                       (
                           text,
                           culture));
            }
            return(base.ConvertFrom
                   (
                       context,
                       culture,
                       value));
        }
コード例 #3
0
        /// <summary>
        /// Converts the given value object to the specified type,
        /// using the specified context and culture information.
        /// </summary>
        /// <returns>
        /// An <see cref="T:System.Object"/>
        /// that represents the converted value.
        /// </returns>
        /// <param name="culture">A
        /// <see cref="T:System.Globalization.CultureInfo"/>.
        /// If null is passed, the current culture is assumed.</param>
        /// <param name="context">An
        /// <see cref="T:System.ComponentModel.ITypeDescriptorContext"/>
        /// that provides a format context.</param>
        /// <param name="destinationType">The <see cref="T:System.Type"/>
        /// to convert the value parameter to.</param>
        /// <param name="value">The <see cref="T:System.Object"/>
        /// to convert.</param>
        /// <exception cref="T:System.NotSupportedException">The conversion
        /// cannot be performed.</exception>
        /// <exception cref="T:System.ArgumentNullException">The
        /// <paramref name="destinationType"/> parameter is <c>null</c>.
        /// </exception>
        public override object ConvertTo
        (
            ITypeDescriptorContext context,
            CultureInfo culture,
            object value,
            Type destinationType)
        {
            DateTimeInterval interval = value as DateTimeInterval;

            if ((interval != null) &&
                (destinationType == typeof(string)))
            {
                return(interval.ToString());
            }
            return(base.ConvertTo
                   (
                       context,
                       culture,
                       value,
                       destinationType));
        }
コード例 #4
0
        /// <summary>
        /// Determines whether the specified <see cref="T:System.Object"></see> is equal to the current <see cref="T:System.Object"></see>.
        /// </summary>
        /// <param name="obj">The <see cref="T:System.Object"></see> to compare with the current <see cref="T:System.Object"></see>.</param>
        /// <returns>
        /// true if the specified <see cref="T:System.Object"></see> is equal to the current <see cref="T:System.Object"></see>; otherwise, false.
        /// </returns>
        public override bool Equals(object obj)
        {
            if (this == obj)
            {
                return(true);
            }
            DateTimeInterval dateTimeInterval = obj as DateTimeInterval;

            if (dateTimeInterval == null)
            {
                return(false);
            }
            return(Equals
                   (
                       _beginning,
                       dateTimeInterval._beginning) && Equals
                   (
                       _ending,
                       dateTimeInterval
                       ._ending));
        }
コード例 #5
0
 /// <summary>
 /// Determines whether the <see cref="DateTimeInterval"/>
 /// overlaps with the specified interval.
 /// </summary>
 /// <param name="interval">Interval to check.</param>
 /// <returns><c>true</c> if two intervals overlaps;
 /// otherwise, <c>false</c>.</returns>
 public bool Overlaps(DateTimeInterval interval)
 {
     return(Contains(interval.Beginning) ||
            Contains(interval.Ending));
 }
コード例 #6
0
 /// <summary>
 /// Determines whether the <see cref="DateTimeInterval"/>
 /// contains the specified interval.
 /// </summary>
 /// <param name="interval">Interval to check.</param>
 /// <returns>
 ///     <c>true</c> if the <see cref="DateTimeInterval"/>contains
 /// the specified interval; otherwise, <c>false</c>.
 /// </returns>
 public bool Contains(DateTimeInterval interval)
 {
     return(Contains(interval.Beginning) &&
            Contains(interval.Ending));
 }