private static void AddToLocalizedAssemblyCollection( Dictionary <string, LocalizedAssemblyResult> collection, string dllName, LocalizedAssemblyResult result) { lock (_localizedDllCollectionLock) { if (!collection.ContainsKey(dllName)) { collection[dllName] = result; } } }
private static void Execute(string lciCommentsDirPath, string[] englishDlls) { Console.WriteLine($"Total English Dlls: {englishDlls.Count()}"); ParallelOptions ops = new ParallelOptions { MaxDegreeOfParallelism = _numberOfThreads }; Parallel.ForEach(englishDlls, ops, englishDll => { var englishAssemblyMetadata = new EnglishAssemblyMetadata() { AssemblyPath = englishDll }; if (!File.Exists(englishDll)) { Console.WriteLine($"File Not Found: {englishDll}"); } else if (!englishDll.EndsWith(".dll") && !englishDll.EndsWith(".exe")) { Console.WriteLine($"File Not a dll/exe: {englishDll}\n"); } else { if (DoesDllContainResourceStrings(englishDll)) { var translatedDlls = GetTranslatedDlls(Path.GetDirectoryName(englishDll), englishDll); englishAssemblyMetadata.HasResources = true; englishAssemblyMetadata.TranslatedAssemblyCount = translatedDlls.Count(); Console.WriteLine($"Validating: {englishDll} " + Environment.NewLine + $"\t Contains resource strings: True" + Environment.NewLine + $"\t Translated assembly count: {translatedDlls.Count()}" + Environment.NewLine); var localizedAssemblyResult = new LocalizedAssemblyResult(englishDll, new HashSet <string>(translatedDlls.Select(s => s.ToLower()).ToList())); // Add english dll to allow filtering AddToLocalizedAssemblyCollection( _localizedDlls, englishDll, localizedAssemblyResult); foreach (var translatedDll in translatedDlls) { try { CompareAllStrings(englishDll, translatedDll, lciCommentsDirPath); } catch (Exception e) { Console.WriteLine(e); } } } else { englishAssemblyMetadata.HasResources = false; Console.WriteLine($"Validating: {englishDll} " + Environment.NewLine + $"\t Contains resource strings: False" + Environment.NewLine); } } lock (_resultSummaryLock) { _resultSummary.EnglishAssemblies.Add(englishAssemblyMetadata); } }); }