// get sort function from media sort type public static Func <string, long> GetSortFunc(MediaSortType mediaSortType) { switch (mediaSortType) { case MediaSortType.BY_DURATION: return(filePath => (long)new WindowsMediaPlayer().newMedia(filePath).duration); // TODO need elegant convert!! case MediaSortType.BY_SIZE: return(filePath => new FileInfo(filePath).Length); default: throw new Exception("Cannot detect sort function of mediaSortType=" + mediaSortType); } }
// get media sort type info public static string GetMediaSortTypeInfo(MediaSortType mediaSortType) { switch (mediaSortType) { case MediaSortType.BY_DURATION: return("By duration"); case MediaSortType.BY_SIZE: return("By size"); default: throw new Exception("Cannot detect media type info of mediaSortType=" + mediaSortType); } }
public MediaSortComparer(MediaSortType sort, SortDirection direction) : base(direction) { _sort = sort; }