OSDN Git Service

na-get-lib,all-get,依存関係解決機能をとりあえず追加。動作確認完了。
[applistation/AppliStation.git] / na-get-lib / NaGet.Packages.Install / DependeciesResolver.cs
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