コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DateSpan"/> structure.
        /// </summary>
        /// <param name="start">A <see cref="DateTime"/> value for the <see cref="DateSpan"/> calculation.</param>
        /// <param name="end">A <see cref="DateTime"/> value for the <see cref="DateSpan"/> calculation.</param>
        /// <param name="calendar">The <see cref="Calendar"/> that applies to this <see cref="DateSpan"/>.</param>
        public DateSpan(DateTime start, DateTime end, Calendar calendar) : this()
        {
            if (calendar == null)
            {
                throw new ArgumentNullException(nameof(calendar));
            }

            Highest  = EnumerableConverter.FromArray(start, end).Max();
            Lowest   = EnumerableConverter.FromArray(start, end).Min();
            Calendar = calendar;

            int totalMonths, deltaMonths;

            GetMonths(out deltaMonths, out totalMonths);

            TimeSpan timespan = (Highest - Lowest);

            Hours             = timespan.Hours;
            TotalHours        = (long)timespan.TotalHours;
            Milliseconds      = timespan.Milliseconds;
            TotalMilliseconds = (long)timespan.TotalMilliseconds;
            Minutes           = timespan.Minutes;
            TotalMinutes      = (long)timespan.TotalMinutes;
            Months            = deltaMonths;
            TotalMonths       = totalMonths;
            Days         = Highest.Day;
            TotalDays    = (int)Math.Floor(timespan.TotalDays);
            Seconds      = timespan.Seconds;
            TotalSeconds = (long)timespan.TotalSeconds;
            Ticks        = timespan.Ticks;
            Years        = GetYears(Highest, Lowest);
        }
コード例 #2
0
 /// <summary>
 /// Adds the specified <paramref name="key"/> and <paramref name="value"/> to the cache.
 /// </summary>
 /// <param name="key">The cache key used to identify the item.</param>
 /// <param name="value">The object to be inserted in the cache.</param>
 /// <param name="group">The group to associate the <paramref name="key"/> with.</param>
 /// <param name="dependencies">The dependencies for the <paramref name="value"/>. When any dependency changes, the <paramref name="value"/> becomes invalid and is removed from the cache.</param>
 /// <exception cref="T:System.ArgumentNullException">
 ///     <paramref name="key"/> is null.
 /// </exception>
 /// <remarks>
 /// This method will not throw an <see cref="ArgumentException"/> in case of an existing cache item whose key matches the key parameter.
 /// </remarks>
 public void Add(string key, object value, string group, params IDependency[] dependencies)
 {
     Add(key, value, group, EnumerableConverter.FromArray(dependencies));
 }
コード例 #3
0
 /// <summary>
 /// Gets the most significant (largest) value of either <see cref="Created"/> or <see cref="Modified"/>.
 /// </summary>
 /// <returns>The most significant (largest) value of either <see cref="Created"/> or <see cref="Modified"/>.</returns>
 public DateTime GetMostSignificant()
 {
     return(EnumerableConverter.FromArray(Created, Modified ?? DateTime.MinValue).Max());
 }