Beispiel #1
0
        public void PartitionByDate()
        {
            var ages = new Dictionary <int, string>()
            {
                [0] = "Recent",
                [1] = "A Bit Ago",
                [2] = "A While Ago"
            };

            var partitions = FileLinq.PartitionBy(
                Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), 3,
                fi => fi.LastWriteTime).Select(grp => new
            {
                Text  = $"{ages[grp.Key]}, from {grp.Min(fi => fi.LastWriteTime):M/d/yy} to {grp.Max(fi => fi.LastWriteTime):M/d/yy}",
                Files = grp
            });
        }
Beispiel #2
0
        public void GetLargest()
        {
            var largest = FileLinq.GetLargest(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), 5);

            Assert.IsTrue(largest.Count() == 5);
        }
Beispiel #3
0
        public void GetRecentByExtension()
        {
            var recentByExt = FileLinq.GetRecentByExtension(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), 5);

            Assert.IsTrue(recentByExt.All(ext => ext.Count() <= 5));
        }
Beispiel #4
0
        public void GetFileInfosLimitCount()
        {
            var files = FileLinq.GetFileInfosLimited(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), 10);

            Assert.IsTrue(files.Count() == 10);
        }
Beispiel #5
0
        public void GetFileInfosAll()
        {
            var files = FileLinq.GetFileInfosAll(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));

            Assert.IsTrue(files.Any());
        }
Beispiel #6
0
 public static IEnumerable <Mp3Info> GetMp3InfoLimitedWhere(string path, Func <Mp3Info, bool> predicate, int limit = 0) =>
 FileLinq.GetFileInfosLimited(path, limit, Mp3Filter)
 .Select(fileInfo => new Mp3Info(fileInfo))
 .Where(predicate);
Beispiel #7
0
 public static IEnumerable <Mp3Info> GetMp3InfoLimited(string path, int limit = 0) =>
 FileLinq.GetFileInfosLimited(path, limit, Mp3Filter)
 .Select(fileInfo => new Mp3Info(fileInfo));
Beispiel #8
0
 public static IEnumerable <Mp3Info> GetMp3InfoAll(string path) =>
 FileLinq.GetFileInfosAll(path, Mp3Filter)
 .Select(fileInfo => new Mp3Info(fileInfo));