/// <summary> /// Finds packages given a locally-accessible filename /// /// Package information must be returned using <c>request.YieldPackage(...)</c> function. /// </summary> /// <param name="file">the full path to the file to determine if it is a package</param> /// <param name="id">if this is greater than zero (and the number should have been generated using <c>StartFind(...)</c>, the core is calling this multiple times to do a batch search request. The operation can be delayed until <c>CompleteFind(...)</c> is called</param> /// <param name="request">An object passed in from the CORE that contains functions that can be used to interact with the CORE and HOST</param> public void FindPackageByFile(string file, int id, Request request) { request.Debug("Calling '{0}::FindPackageByFile' '{1}','{2}'", PackageProviderName, file, id); /*List<PackageSource> sources; var providerPackageSources = ProviderStorage.GetPackageSources(request); if (request.PackageSources != null && request.PackageSources.Any()) { sources = new List<PackageSource>(); foreach (var userRequestedSource in request.PackageSources) { if (providerPackageSources.ContainsKey(userRequestedSource)) { sources.Add(providerPackageSources[userRequestedSource]); } } } else { sources = providerPackageSources.Select(i => i.Value).ToList(); } var source = sources.FirstOrDefault();*/ var source = new PackageSource("Local Filesystem", file) { Trusted = true }; request.YieldPackage(new PackageItem(source, file, ""), file); }
/// <summary> /// Searches package sources given name and version information /// /// Package information must be returned using <c>request.YieldPackage(...)</c> function. /// </summary> /// <param name="name">a name or partial name of the package(s) requested</param> /// <param name="requiredVersion">A specific version of the package. Null or empty if the user did not specify</param> /// <param name="minimumVersion">A minimum version of the package. Null or empty if the user did not specify</param> /// <param name="maximumVersion">A maximum version of the package. Null or empty if the user did not specify</param> /// <param name="id">if this is greater than zero (and the number should have been generated using <c>StartFind(...)</c>, the core is calling this multiple times to do a batch search request. The operation can be delayed until <c>CompleteFind(...)</c> is called</param> /// <param name="request">An object passed in from the CORE that contains functions that can be used to interact with the CORE and HOST</param> public void FindPackage(string name, string requiredVersion, string minimumVersion, string maximumVersion, int id, Request request) { request.Debug("Calling '{0}::FindPackage' '{1}','{2}','{3}','{4}'", PackageProviderName, requiredVersion, minimumVersion, maximumVersion, id); List<PackageSource> sources; var providerPackageSources = ProviderStorage.GetPackageSources(request); if (request.PackageSources != null && request.PackageSources.Any()) { sources = new List<PackageSource>(); foreach (var userRequestedSource in request.PackageSources) { if (providerPackageSources.ContainsKey(userRequestedSource)) { sources.Add(providerPackageSources[userRequestedSource]); } } } else { sources = providerPackageSources.Select(i => i.Value).ToList(); } if (request.IsCanceled) { return; } var packageItem = new PackageItem(sources.FirstOrDefault(), "notepad", "1.0"); // YieldPackage returns false when operation was cancelled if (!request.YieldPackage(packageItem, name)) { return; } }