public void MatchesHigherVersionToHighestAssembly() { var matcher = new AssemblyMatcher(); var resources = new[] { $"Blah.{AssemblyPrefix}v9.2.dll", $"Blah.{AssemblyPrefix}v9.1.dll", }; var match = matcher.MatchResource(resources, "10.2.1"); Assert.Equal(resources[0], match.ResourceName); }
public void FindsExactMatch() { var matcher = new AssemblyMatcher(); var resources = new[] { $"Blah.{AssemblyPrefix}v9.1.dll", $"Blah.{AssemblyPrefix}v9.2.dll" }; var match = matcher.MatchResource(resources, "9.2.1"); Assert.Equal(resources[1], match.ResourceName); }
/// <summary> /// 解析Assembly /// </summary> /// <param name="aname"></param> /// <returns></returns> public Assembly Resolve(AssemblyName aname) { var results = new AssemblyMatcher(aname, IncludeVersion); Resolve(results, aname, FileDirectory); if (results.FullMatchedResult != null) { return(LoadFromFile(results.FullMatchedResult.AssemblyFile)); } return(null); }
private void Resolve(AssemblyMatcher results, AssemblyName aname, string assemblyPath) { var assemblyFile = Path.Combine(assemblyPath, aname.Name + ".dll"); if (File.Exists(assemblyFile)) { if (results.Match(assemblyFile)) { return; } } var files = Directory.GetFiles(assemblyPath, Filter); if (files != null && files.Length > 0) { foreach (string file in files) { if (results.Match(file)) { return; } } } if (!IncludeChildDirectory) { return; } var dirs = Directory.GetDirectories(assemblyPath); if (dirs != null && dirs.Length > 0) { foreach (var subDirectory in dirs) { Resolve(results, aname, subDirectory); } } }
private void Resolve(AssemblyMatcher results, AssemblyName aname, string assemblyPath) { var assemblyFile = Path.Combine(assemblyPath, aname.Name + ".dll"); if (File.Exists(assemblyFile)) { if (results.Match(assemblyFile)) return; } var files = Directory.GetFiles(assemblyPath, Filter); if (files != null && files.Length > 0) foreach (string file in files) if (results.Match(file)) return; if (!IncludeChildDirectory) return; var dirs = Directory.GetDirectories(assemblyPath); if (dirs != null && dirs.Length > 0) foreach (var subDirectory in dirs) { Resolve(results,aname, subDirectory); } }
/// <summary> /// 解析Assembly /// </summary> /// <param name="aname"></param> /// <returns></returns> public Assembly Resolve(AssemblyName aname) { var results = new AssemblyMatcher(aname,IncludeVersion); Resolve(results, aname, FileDirectory); if (results.FullMatchedResult != null) return LoadFromFile(results.FullMatchedResult.AssemblyFile); return null; }