OSDN Git Service

WinGui:
[handbrake-jp/handbrake-jp-git.git] / win / C# / HandBrake.ApplicationServices / Parsing / Source.cs
1 /*  Source.cs $    This file is part of the HandBrake source code.\r
2     Homepage: <http://handbrake.fr>.\r
3     It may be used under the terms of the GNU General Public License. */\r
4 \r
5 namespace HandBrake.ApplicationServices.Parsing\r
6 {\r
7     using System.Collections.Generic;\r
8     using System.IO;\r
9 \r
10     /// <summary>\r
11     /// An object representing a scanned DVD\r
12     /// </summary>\r
13     public class Source\r
14     {\r
15         /// <summary>\r
16         /// Initializes a new instance of the <see cref="Source"/> class. \r
17         /// Default constructor for this object\r
18         /// </summary>\r
19         public Source()\r
20         {\r
21             Titles = new List<Title>();\r
22         }\r
23 \r
24         /// <summary>\r
25         /// Gets or sets Titles. A list of titles from the source\r
26         /// </summary>\r
27         public List<Title> Titles { get; set; }\r
28 \r
29         /// <summary>\r
30         /// Parse the StreamReader output into a List of Titles\r
31         /// </summary>\r
32         /// <param name="output">\r
33         /// The output.\r
34         /// </param>\r
35         /// <returns>\r
36         /// A DVD object which contains a list of title inforamtion\r
37         /// </returns>\r
38         public static Source Parse(StreamReader output)\r
39         {\r
40             var thisDVD = new Source();\r
41 \r
42             while (!output.EndOfStream)\r
43             {\r
44                 if ((char) output.Peek() == '+')\r
45                     thisDVD.Titles.AddRange(Title.ParseList(output.ReadToEnd()));\r
46                 else\r
47                     output.ReadLine();\r
48             }\r
49 \r
50             return thisDVD;\r
51         }\r
52     }\r
53 }