OSDN Git Service

na-get-lib,all-get,依存関係解決機能をとりあえず追加。動作確認完了。
authorttp <ttp@users.sourceforge.jp>
Sat, 6 Sep 2008 07:38:17 +0000 (07:38 +0000)
committerttp <ttp@users.sourceforge.jp>
Sat, 6 Sep 2008 07:38:17 +0000 (07:38 +0000)
 * ひとまずall-getでは、何も表示せずに何気にインストールリストに依存で必要とされるパッケージが追加される実装にした。
 * Requiresに限り、かつバージョン比較を行わない条件のもと、柔軟性のあまり高くないコーディングとした

git-svn-id: http://localhost/svn/AppliStation/trunk@966 34ed2c89-c49f-4a4b-abdb-c318350108cf

all-get/Main.cs
na-get-lib/NaGet.Packages.Install/DependeciesResolver.cs

index 592f7ef..e3f7672 100644 (file)
@@ -289,6 +289,13 @@ namespace AllGet
                                }\r
                        }\r
                        \r
+                       Installation[] depInstallations;\r
+                       {\r
+                               Installation[] resolved;\r
+                               DependeciesResolver.ResolveInstallations(installations, pkgListMan, out resolved, out depInstallations);\r
+                               installations = resolved;\r
+                       }\r
+                       \r
                        Console.WriteLine("The following packages will be downloaded:");\r
                        Console.WriteLine("  {0}", Installation.ToString(installations));\r
                        if (AllGet.Util.Confirm("Do you want to continue [Y/n]?", true) == false) {\r
index 2df1836..0b266c7 100644 (file)
@@ -43,7 +43,7 @@ namespace NaGet.Packages.Install
                {\r
                        List<Installation> reqInsts = new List<Installation>();\r
                        \r
-                       foreach (Entry entry in DeleteDuplicatedEntries(CreateDependencyEntries(insts, "Requires"))) {\r
+                       foreach (Entry entry in DeleteDuplicatedEntries(CreateRequiresEntries(insts))) {\r
                                if (!pkgListsMan.IsInstalledFor(entry)) {                       \r
                                        if (Array.Exists(insts, delegate(Installation inst) {\r
                                                        return inst.InstalledPackage.Name == entry.Name;\r
@@ -79,26 +79,15 @@ namespace NaGet.Packages.Install
                }\r
                \r
                /// <summary>\r
-               /// 指定した依存エントリのイテレータを返す\r
+               /// Requires依存エントリのイテレータを返す\r
                /// </summary>\r
                /// <remarks>現段階の実装では再帰的な依存は検索しない</remarks>\r
                /// <param name="insts">対象のインストールリスト</param>\r
-               /// <param name="dependencyName">依存の種類名。<code>Package</code>クラスのフィールド名を入れる</param>\r
                /// <returns>依存エントリのイテレータ。重複に関して解決は行わない</returns>\r
-               /// <exception cref="ArgumentException"><code>dependencyName</code>が不正であった場合</exception>\r
-               public static IEnumerable<Entry> CreateDependencyEntries(Installation[] insts, string dependencyName)\r
+               private static IEnumerable<Entry> CreateRequiresEntries(Installation[] insts)\r
                {\r
-                       FieldInfo depFInfo = null;\r
-                       \r
-                       try {\r
-                               depFInfo = typeof(Installation).GetField(dependencyName, BindingFlags.Public);\r
-                               if (depFInfo.FieldType != typeof(Installation[])) throw new ApplicationException("Field type does not Installation[].");\r
-                       } catch (Exception ex) {\r
-                               throw new ArgumentException("Not suitable dependencyName", "dependencyName", ex);\r
-                       }\r
-                       \r
                        foreach (Installation inst in insts) {\r
-                               Entry[] deps = (Entry[]) depFInfo.GetValue(inst);\r
+                               Entry[] deps = inst.InstalledPackage.Requires;\r
                                if (deps == null) continue;\r
                                foreach (Entry dep in deps) {\r
                                        yield return dep;\r