Example #1
0
 protected DateComparisonBaseAttribute(string otherProperty, DateComparisonType dateComparisonType)
 {
     _dateComparisonType = dateComparisonType;
     if (otherProperty == null)
     {
         throw new ArgumentNullException("otherProperty");
     }
     OtherProperty = otherProperty;
 }
 protected DateComparisonBaseAttribute(string otherProperty, DateComparisonType dateComparisonType)
 {
     _dateComparisonType = dateComparisonType;
     if (otherProperty == null)
     {
         throw new ArgumentNullException("otherProperty");
     }
     OtherProperty = otherProperty;
 }
        private bool MatchDirByDate(DirectoryInfo directoryInfo, DateTime date, DateComparisonType dateComparisonType)
        {
            DateTime dirInfoDate = new DateTime();

            switch (dateComparisonType)
            {
            case DateComparisonType.CreationDate:
                dirInfoDate = directoryInfo.CreationTime;
                break;

            case DateComparisonType.LastAccessDate:
                dirInfoDate = directoryInfo.LastAccessTime;
                break;

            case DateComparisonType.LastModificationDate:
                dirInfoDate = directoryInfo.LastWriteTime;
                break;
            }
            return(DateTime.Equals(dirInfoDate.Date, date.Date));
        }
        private static bool MatchByDateEx(FileInfo fileInfo, DateTime dateTime, DateComparisonType comparisonType)
        {
            DateTime fileInfoDate = new DateTime();

            switch (comparisonType)
            {
            case DateComparisonType.CreationDate:
                fileInfoDate = fileInfo.CreationTime.Date;
                break;

            case DateComparisonType.LastModificationDate:
                fileInfoDate = fileInfo.LastWriteTime.Date;
                break;

            case DateComparisonType.LastAccessDate:
                fileInfoDate = fileInfo.LastAccessTime.Date;
                break;
            }
            return(DateTime.Equals(fileInfoDate.Date, dateTime.Date));
        }
Example #5
0
 /// <summary>
 /// Constructs a new access policy condition that compares the current time
 /// (on the AWS servers) to the specified date.
 /// </summary>
 /// <param name="type">The type of comparison to perform. For example,
 ///            DateComparisonType.DateLessThan will cause this policy
 ///            condition to evaluate to true if the current date is less than
 ///            the date specified in the second argument.</param>
 /// <param name="date">The date to compare against.</param>
 public static Condition NewCondition(DateComparisonType type, DateTime date)
 {
     return(new Condition(type.ToString(), CURRENT_TIME_CONDITION_KEY, date.ToString(AWSSDKUtils.ISO8601DateFormat)));
 }
Example #6
0
 public static Condition NewCondition(DateComparisonType type, DateTime date)
 {
     return(new Condition(type.ToString(), "aws:CurrentTime", date.ToString("yyyy-MM-dd\\THH:mm:ss.fff\\Z", CultureInfo.InvariantCulture)));
 }
 /// <summary>
 /// Constructs a new access policy condition that compares the current time
 /// (on the AWS servers) to the specified date.
 /// </summary>
 /// <param name="type">The type of comparison to perform. For example,
 ///            DateComparisonType.DateLessThan will cause this policy
 ///            condition to evaluate to true if the current date is less than
 ///            the date specified in the second argument.</param>
 /// <param name="date">The date to compare against.</param>
 public static Condition NewConditionUtc(DateComparisonType type, DateTime date)
 {
     return(new Condition(type.ToString(), CURRENT_TIME_CONDITION_KEY, date.ToUniversalTime().ToString(AWSSDKUtils.ISO8601DateFormat, CultureInfo.InvariantCulture)));
 }
Example #8
0
 /// <summary>
 /// Constructs a new access policy condition that compares the current time
 /// (on the AWS servers) to the specified date.
 /// </summary>
 /// <param name="type">The type of comparison to perform. For example,
 ///            DateComparisonType.DateLessThan will cause this policy
 ///            condition to evaluate to true if the current date is less than
 ///            the date specified in the second argument.</param>
 /// <param name="date">The date to compare against.</param>
 public static Condition NewCondition(DateComparisonType type, DateTime date)
 {
     return new Condition(type.ToString(), CURRENT_TIME_CONDITION_KEY, date.ToString(AWSSDKUtils.ISO8601DateFormat));
 }
        private static bool MatchByDateRangeEx(FileInfo fileInfo, DateTime lowerBoundDate, DateTime upperBoundDate, DateComparisonType comparisonType)
        {
            DateTime fileInfoDate = new DateTime();

            switch (comparisonType)
            {
            case DateComparisonType.CreationDate:
                fileInfoDate = fileInfo.CreationTime.Date;
                break;

            case DateComparisonType.LastModificationDate:
                fileInfoDate = fileInfo.LastWriteTime.Date;
                break;

            case DateComparisonType.LastAccessDate:
                fileInfoDate = fileInfo.LastAccessTime.Date;
                break;
            }
            return(fileInfoDate >= lowerBoundDate.Date && fileInfoDate <= upperBoundDate.Date);
        }
 /// <summary> Initializes a new instance of the DateComparer class. </summary>
 /// <remarks> ebrown, 6/18/2011. </remarks>
 /// <param name="dateComparisonType"> The method by which dates should be compared. </param>
 public DateComparer(DateComparisonType dateComparisonType)
 {
     this.comparisonType = dateComparisonType;
 }
 /// <summary>
 /// Default constructor.
 /// </summary>
 /// <param name="date">Date only.</param>
 /// <param name="dateComparisonType">Date comparison type.</param>
 public SearchDirectoryByDateOption(DateTime date, DateComparisonType dateComparisonType)
 {
     Date = date;
     DateComparisonType = dateComparisonType;
 }
 /// <summary>
 /// Default constructor for instantiating this class.
 /// </summary>
 /// <param name="lowerBoundDate">Lower bound date. Please, specifiy in date format only.</param>
 /// <param name="upperBoundDate">Upper bound date. Please, specifiy in date format only,</param>
 /// <param name="dateComparisonType">Date comparison type.</param>
 public SearchFileByDateRangeOption(DateTime lowerBoundDate, DateTime upperBoundDate, DateComparisonType dateComparisonType)
 {
     LowerBoundDate     = lowerBoundDate;
     UpperBoundDate     = upperBoundDate;
     DateComparisonType = dateComparisonType;
 }
 /// <summary>
 /// Default constructor for instantiating this class.
 /// </summary>
 /// <param name="date">Date only. No time is used.</param>
 /// <param name="dateComparisonType">Date comparison type.</param>
 public SearchFileByDateOption(DateTime date, DateComparisonType dateComparisonType)
 {
     Date = date;
     DateComparisonType = dateComparisonType;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="DateFieldsCompareValidator"/> class.
 /// </summary>
 /// <param name="dateFormat">The date format.</param>
 /// <param name="dateFieldToCompareWith">The date field to compare with.</param>
 /// <param name="dateComparisonType">Type of the date comparison.</param>
 public DateFieldsCompareValidatorAttribute(string dateFormat, string dateFieldToCompareWith, DateComparisonType dateComparisonType)
 {
     this.dateFormat             = dateFormat;
     this.dateFieldToCompareWith = dateFieldToCompareWith;
     this.comparisonType         = dateComparisonType;
 }
Example #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CompareToCurrentDateTimeValidator"/> class.
 /// </summary>
 /// <param name="dateFormat">The date format.</param>
 /// <param name="dateComparisonType">Type of the date comparison.</param>
 /// <param name="onlyDate">if set to <c>true</c> [only date].</param>
 public DateTimeNowComparisonAttribute(string dateFormat, DateComparisonType dateComparisonType, bool onlyDate = false)
 {
     this.dateFormat     = dateFormat;
     this.comparisonType = dateComparisonType;
     this.onlyDate       = onlyDate;
 }
Example #16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CompareToCurrentDateTimeValidator"/> class.
 /// </summary>
 /// <param name="dateComparisonType">Type of the date comparison.</param>
 /// <param name="onlyDate">if set to <c>true</c> [only date].</param>
 public DateTimeNowComparisonAttribute(DateComparisonType dateComparisonType, bool onlyDate = false)
 {
     this.comparisonType = dateComparisonType;
     this.onlyDate       = onlyDate;
 }