Working on new method
This commit is contained in:
parent
9bf4b675e4
commit
a17ea99642
@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using ExifLibrary;
|
||||
using JetBrains.Annotations;
|
||||
|
||||
namespace PhotoRenamer.Base
|
||||
{
|
||||
@ -22,5 +25,31 @@ namespace PhotoRenamer.Base
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<MediaFile> GetMediaFiles([NotNull] IEnumerable<string> files)
|
||||
{
|
||||
if (files == null) throw new ArgumentNullException(nameof(files));
|
||||
|
||||
foreach (var file in files)
|
||||
{
|
||||
var imageFile = ImageFile.FromFile(file);
|
||||
var dateTime = imageFile.Properties.Get<ExifDateTime>(ExifTag.DateTimeOriginal);
|
||||
var mediaFile = new MediaFile(file, dateTime.Value);
|
||||
yield return mediaFile;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public class MediaFile
|
||||
{
|
||||
public string Path { get; }
|
||||
public DateTime CreationDate { get; }
|
||||
|
||||
public MediaFile(string path, DateTime creationDate)
|
||||
{
|
||||
Path = path;
|
||||
CreationDate = creationDate;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
||||
using PhotoRenamer.Base;
|
||||
|
||||
namespace PhotoRenamer.Test
|
||||
{
|
||||
@ -13,7 +14,7 @@ namespace PhotoRenamer.Test
|
||||
public FilesTest()
|
||||
{
|
||||
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Assets");
|
||||
_files = Base.FilesHelper.FindSupportedFilesRecursively(path).ToArray();
|
||||
_files = FilesHelper.FindSupportedFilesRecursively(path).ToArray();
|
||||
}
|
||||
|
||||
[TestMethod, Priority(0)]
|
||||
@ -27,7 +28,8 @@ namespace PhotoRenamer.Test
|
||||
[TestMethod, Priority(1)]
|
||||
public void GetMetaData()
|
||||
{
|
||||
|
||||
var expected = new[] {new MediaFile("r", DateTime.Now), new MediaFile("r", DateTime.Now)};
|
||||
var actual = FilesHelper.GetMediaFiles(_files);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user