/// <summary> /// Resolves a package from nuget using a specified name and version. /// </summary> /// <param name="name">Name of the package to find</param> /// <param name="version">Version of the package</param> /// <returns>File path if the nuget package is found</returns> protected string ResolvePackage(string name, Version version) { SemanticVersion vers = SemanticVersion.ParseOptionalVersion($"{version.Major}.{version.Minor}.*"); IPackage package = ResolvePackage(name, vers); if (package != null) { string installPath = packageManager.PathResolver.GetInstallPath(package); string libPath = Path.Combine(installPath, "lib", "net45", name + ".dll"); if (File.Exists(libPath)) { OnResolved?.Invoke(this, new NugetAssemblyResolvedEventArgs() { FilePath = libPath }); return(libPath); } else { var files = Directory.EnumerateFiles(installPath, "*.dll", SearchOption.AllDirectories); if (files.Count() == 1) { libPath = files.Single(); OnResolved?.Invoke(this, new NugetAssemblyResolvedEventArgs() { FilePath = libPath }); return(libPath); } } } return(null); }
/// <summary> /// Resolves a package from nuget using a specified name and version. /// </summary> /// <param name="name">Name of the package to find</param> /// <param name="version">Version of the package</param> /// <returns>File path if the nuget package is found</returns> protected string ResolvePackage(string name, Version version) { SemanticVersion vers = SemanticVersion.ParseOptionalVersion($"{version.Major}.{version.Minor}.*"); IPackage package = ResolvePackage(name, vers); if (package != null) { string installPath = packageManager.PathResolver.GetInstallPath(package); string libPath = Path.Combine(installPath, "lib", "net45", name + ".dll"); if (File.Exists(libPath)) { OnResolved?.Invoke(this, new NugetAssemblyResolvedEventArgs() { FilePath = libPath }); return(libPath); } else { var files = Directory.EnumerateFiles(installPath, "*.dll", SearchOption.AllDirectories); if (files.Count() == 1) { libPath = files.Single(); OnResolved?.Invoke(this, new NugetAssemblyResolvedEventArgs() { FilePath = libPath }); return(libPath); } } } else { foreach (var file in Directory.EnumerateFiles(Environment.CurrentDirectory, name + ".*")) { var extension = Path.GetExtension(file).ToLower(); if (new[] { ".exe", ".dll" }.Contains(extension)) { Console.WriteLine($" * Found {name} locally"); return(file); } } } return(null); }
/// <summary> /// Resolves the <see cref="Promise{T}"/>. The <see cref="Promise{T}"/> will stop awaiting and return the value. /// </summary> /// <param name="result">The value to return.</param> public void Resolve(T result) { OnResolved?.Invoke(result); actionFlow.Stop(); tcs.SetResult(result); }
protected virtual void Resolved(T obj) => OnResolved?.Invoke(obj);