3 using System.Collections.Generic;
\r
4 using System.Xml.Serialization;
\r
5 using System.Text.RegularExpressions;
\r
6 using NaGet.Packages;
\r
8 namespace NaGet.Packages.Install
\r
10 public class InstalledPackage : Package
\r
15 public UninstallInformation UninstallInfo;
\r
17 public static InstalledPackage PackageConverter(Package basePkg)
\r
19 InstalledPackage pkg = new InstalledPackage();
\r
21 NaGet.Utils.FieldCopy(basePkg, ref pkg);
\r
22 pkg.UninstallInfo = UninstallInformation.NewInstance(basePkg);
\r
27 public static InstalledPackage PackageConverter(Package basePkg, UninstallInformation info)
\r
29 InstalledPackage instPkg = new InstalledPackage();
\r
31 NaGet.Utils.FieldCopy(basePkg, ref instPkg);
\r
32 instPkg.UninstallInfo = info;
\r
34 Match match = Regex.Match(info.DisplayName, basePkg.UninstallerKey);
\r
35 if (! match.Success) {
\r
36 throw new ArgumentException(string.Format("{0}({1}) does not matched for {2}.", basePkg.Name, basePkg.Version, info.DisplayName));
\r
37 } else if (match.Groups[1].Success) { // DisplayNameの方のバージョン表記を優先
\r
38 instPkg.Version = match.Groups[1].Value;
\r
39 } else if (! string.IsNullOrEmpty(info.DisplayVersion) ) {
\r
40 instPkg.Version = info.DisplayVersion;
\r
42 instPkg.Version = string.Empty;
\r