diff options
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Parsing/Title.cs')
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Parsing/Title.cs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs b/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs index 4bb47f201..7bce41669 100644 --- a/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs +++ b/win/CS/HandBrake.ApplicationServices/Parsing/Title.cs @@ -9,6 +9,7 @@ namespace HandBrake.ApplicationServices.Parsing using System.Collections.Generic;
using System.Globalization;
using System.IO;
+ using System.Linq;
using System.Text.RegularExpressions;
using HandBrake.ApplicationServices.Services.Interfaces;
@@ -244,12 +245,11 @@ namespace HandBrake.ApplicationServices.Parsing /// <returns>A Timespan</returns>
public TimeSpan CalculateDuration(int startPoint, int endPoint)
{
+ IEnumerable<Chapter> chapers =
+ this.Chapters.Where(c => c.ChapterNumber >= startPoint && c.ChapterNumber <= endPoint);
+
TimeSpan duration = TimeSpan.FromSeconds(0.0);
- if (endPoint <= this.Chapters.Count)
- {
- for (int i = startPoint; i <= endPoint; i++)
- duration += this.Chapters[i].Duration;
- }
+ duration = chapers.Aggregate(duration, (current, chapter) => current + chapter.Duration);
return duration;
}
|