From a411d501240281ba75ee6ace3a659859cb2fb877 Mon Sep 17 00:00:00 2001 From: ttp Date: Sat, 6 Sep 2008 06:12:29 +0000 Subject: [PATCH 1/1] =?utf8?q?na-get-lib,=E4=BE=9D=E5=AD=98=E9=96=A2?= =?utf8?q?=E4=BF=82=E8=A7=A3=E6=B1=BA=E9=96=A2=E6=95=B0=E7=BE=A4=E3=82=92?= =?utf8?q?=E5=BE=AE=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: http://localhost/svn/AppliStation/trunk@964 34ed2c89-c49f-4a4b-abdb-c318350108cf --- .../NaGet.Packages.Install/DependeciesResolver.cs | 35 +++++++++------------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/na-get-lib/NaGet.Packages.Install/DependeciesResolver.cs b/na-get-lib/NaGet.Packages.Install/DependeciesResolver.cs index e41cb91..2df1836 100644 --- a/na-get-lib/NaGet.Packages.Install/DependeciesResolver.cs +++ b/na-get-lib/NaGet.Packages.Install/DependeciesResolver.cs @@ -13,6 +13,13 @@ namespace NaGet.Packages.Install { } + /// + /// 依存解決済みInstallation配列を生成する + /// + /// 元のインストールリスト + /// インストール確認などをおこなうパッケージリストのマネージャ + /// 解決済みInstallation配列 + /// 依存によって必要とされたInstallation配列。ない場合は空配列 public static void ResolveInstallations(Installation[] insts, PackageListsManager pkgListsMan, out Installation[] resolved, out Installation[] dependencies) { List depInsts; @@ -36,23 +43,6 @@ namespace NaGet.Packages.Install { List reqInsts = new List(); - foreach (Entry entry in CreateRequiresEntries(insts, pkgListsMan)) { - reqInsts.Add(new Installation(pkgListsMan.AvailablePkgList.GetPackageForEntry(entry))); - } - - return reqInsts; - } - - - /// - /// Requires依存による依存パッケージの検索をし、それをパッケージ参照エントリのイテレータで返す。 - /// 返されるイテレータは、インストール済み及び重複のパッケージは取り除かれている。 - /// - /// 対象インストールリスト - /// 現在インストールされているか否かの判断に使われるパッケージリスト - /// Requires依存による依存 - public static IEnumerable CreateRequiresEntries(Installation[] insts, PackageListsManager pkgListsMan) - { foreach (Entry entry in DeleteDuplicatedEntries(CreateDependencyEntries(insts, "Requires"))) { if (!pkgListsMan.IsInstalledFor(entry)) { if (Array.Exists(insts, delegate(Installation inst) { @@ -60,10 +50,13 @@ namespace NaGet.Packages.Install })) { continue; } else { - yield return entry; + Package pkg = pkgListsMan.AvailablePkgList.GetPackageForEntry(entry); + reqInsts.Add(new Installation(pkg)); } } } + + return reqInsts; } /// @@ -74,13 +67,13 @@ namespace NaGet.Packages.Install /// 重複しているものを取り除いたエントリのイテレータ private static IEnumerable DeleteDuplicatedEntries(IEnumerable entries) { - List pkgNames = new List(); + LinkedList pkgNames = new LinkedList(); foreach (Entry entry in entries) { - if (pkgNames.IndexOf(entry.Name) < 0) { + if (! pkgNames.Contains(entry.Name)) { // 新出ならば返す yield return entry; - pkgNames.Add(entry.Name); + pkgNames.AddFirst(entry.Name); } } } -- 2.11.0