OSDN Git Service

99eba63170f5fc214748ccd65c1717af120333fa
[applistation/AppliStation.git] / na-get-lib / NaGet.Packages / RepositoriesList.cs
1 using System;\r
2 using System.Xml.Serialization;\r
3 using System.Collections.Generic;\r
4 \r
5 namespace NaGet.Packages\r
6 {\r
7         /// <summary>\r
8         /// レポジトリのリストを表現するクラス\r
9         /// </summary>\r
10         public class RepositoriesList\r
11         {\r
12                 /// <summary>\r
13                 /// レポジトリの配列\r
14                 /// </summary>\r
15                 public RepositoryInfo[] Repositories = null;\r
16                 \r
17                 /// <summary>\r
18                 /// デフォルトコンストラクタ\r
19                 /// </summary>\r
20                 public RepositoriesList()\r
21                 {\r
22                 }\r
23                 \r
24                 /// <summary>\r
25                 /// 有効なレポジトリの配列を返す\r
26                 /// </summary>\r
27                 [XmlIgnore]\r
28                 public RepositoryInfo[] EnabledRepositories {\r
29                         get {\r
30                                 return Array.FindAll(Repositories, delegate(RepositoryInfo repo) {\r
31                                                         return repo.Enabled;\r
32                                                      });\r
33                         }\r
34                 }\r
35                 \r
36                 /// <summary>\r
37                 /// provider.list.txtから変換してRepositoriesListとして返す\r
38                 /// </summary>\r
39                 /// <param name="path">変換もとのprovider.list.txtのパス</param>\r
40                 /// <returns>変換されたRepositoriesList</returns>\r
41                 public static RepositoriesList MigrateFromProviderListTxt(string path)\r
42                 {\r
43                         List<RepositoryInfo> repos = new List<RepositoryInfo>();\r
44                         using(System.IO.StreamReader reader = new System.IO.StreamReader(path)) {\r
45                                 string line;\r
46                                 while ((line = reader.ReadLine()) != null) {\r
47                                         RepositoryInfo repo = new RepositoryInfo();\r
48                                         repo.Enabled = true;\r
49                                         repo.Url = new LocationEntry(line);\r
50                                         repo.Name = string.Empty;\r
51                                         repos.Add(repo);\r
52                                 }\r
53                         }\r
54                         \r
55                         RepositoriesList repolist = new RepositoriesList();\r
56                         repolist.Repositories = repos.ToArray();\r
57                         return repolist;\r
58                 }\r
59         }\r
60         \r
61         /// <summary>\r
62         /// パッケージリストを提供するレポジトリの参照情報を格納するクラス\r
63         /// </summary>\r
64         public sealed class RepositoryInfo\r
65         {\r
66                 /// <summary>\r
67                 /// レポジトリの提供するソフトリストの名称\r
68                 /// </summary>\r
69                 [XmlAttribute]\r
70                 public string Name;\r
71                 \r
72                 /// <summary>\r
73                 /// ソフトリストの取得先URL\r
74                 /// </summary>\r
75                 public LocationEntry Url;\r
76                 \r
77                 /// <summary>\r
78                 /// ソフトリストを読み取るか否か(無視するか否か)のフラグ。\r
79                 /// </summary>\r
80                 [XmlAttribute]\r
81                 public bool Enabled = true;\r
82         }\r
83 }\r