示例#1
0
        private bool ShouldFilterDate(KeyValuePair <string, BrowsingItem> value)
        {
            bool after  = dateFilters.HasFlag(BrowsingDateFilters.After);
            bool before = dateFilters.HasFlag(BrowsingDateFilters.Before);

            if (!after && !before)
            {
                return(true);
            }
            else
            {
                DateTime date = DateTime.Now;

                if (sortType == BrowsingSortType.CreationTime)
                {
                    date = value.Value.CreationTime;
                }
                else if (sortType == BrowsingSortType.LastAccessTime)
                {
                    date = value.Value.LastAccessTime;
                }
                else if (sortType == BrowsingSortType.LastWriteTime)
                {
                    date = value.Value.LastWriteTime;
                }

                if (after && before)
                {
                    return(date > afterDate && date < beforeDate);
                }
                else if (!after && before)
                {
                    return(date < beforeDate);
                }
                else if (after && !before)
                {
                    return(date > afterDate);
                }

                return(false);
            }
        }
示例#2
0
        public static BrowsingDateFilters ToggleFlag(this BrowsingDateFilters flags, BrowsingDateFilters flag)
        {
            if (flags.HasFlag(flag))
            {
                flags &= ~flag;
            }
            else
            {
                flags |= flag;
            }

            return(flags);
        }