using System; using System.Collections.Generic; using NaGet.Tasks; using NaGet.Packages; using NaGet.Packages.Install; namespace NaGet.SubCommands.SubTask { public class VerifyInstallerFileSubTask : NaGetSubTask { IList installations = null; IList invalidInstallers = null; public VerifyInstallerFileSubTask(IList insts) { installations = insts; } public IList InvalidInstallers { get { return invalidInstallers; } } public override void Run() { NotifyStarted(); List invalidInstallers = new List(); for (int i = 0; i < installations.Count; i++) { Installation inst = installations[i]; float percent = 100.0f * i / installations.Count; if (inst.GetRegisteredHashCount() > 0) { if (inst.IsInstallablePackage() && inst.VerifyHashValues() == false) { invalidInstallers.Add(inst); RaiseTaskSetEvent(TaskEventType.WARNING, "検証: "+inst.ToString() + " 非整合", percent); } else { RaiseTaskSetEvent(TaskEventType.INFO, "検証: "+inst.ToString() + " OK", percent); } } else { RaiseTaskSetEvent(TaskEventType.PING, string.Empty, percent); } } if (invalidInstallers.Count > 0) { this.invalidInstallers = invalidInstallers.AsReadOnly(); } else { this.invalidInstallers = null; } NotifyCompleted(); } } }