コード例 #1
0
 /// <summary>
 /// ConvertTo : convert InfraTime to Windows file time.
 /// </summary>
 /// <param name="context">The ITypeDescriptorContext.</param>
 /// <param name="culture">The CultureInfo which is respected when converting.</param>
 /// <param name="value">The InfraTime to convert.</param>
 /// <param name="destinationType">The type to which to convert to.</param>
 /// <returns></returns>
 public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
 {
     if (destinationType == typeof(string))
     {
         InfraTime infraTime = value as InfraTime;
         DateTime  dateTime  = infraTime.DateTime;
         long      fileTime  = dateTime.ToFileTime();
         return(Convert.ToString(fileTime, NumberFormatInfo.InvariantInfo));
     }
     return(base.ConvertTo(context, culture, value, destinationType));
 }
コード例 #2
0
        /// <summary>
        /// ConvertFrom - Attempt to convert to InfraTime from the given object.
        /// </summary>
        /// <param name="context">The ITypeDescriptorContext.</param>
        /// <param name="culture">The CulturfraeInfo which is respected when converting.</param>
        /// <param name="value">The object to convert to a InfraTime</param>
        /// <returns>The InfraTime constructed.</returns>
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
        {
            if (value is string)
            {
                long      fileTime  = Int64.Parse((string)value);
                DateTime  dateTime  = DateTime.FromFileTime(fileTime);
                InfraTime infraTime = new InfraTime(dateTime);

                return(infraTime);
            }
            return(base.ConvertFrom(context, culture, value));
        }
コード例 #3
0
 /// <summary/>
 public void End()
 {
     EndTime = new InfraTime(DateTime.Now);
 }