/// <summary> /// Fill given list with components collected from assemblies specified by fullpath and pattern. /// </summary> /// <param name="result">Here are stored found components.</param> /// <param name="fullpath">Fullpath of directory where assemblies are searched.</param> /// <param name="pattern">Pattern for an assembly.</param> /// <returns>Error if any, null otherwise.</returns> private string fillWithComponents(List <Instance> result, string fullpath, string pattern) { var files = Services.GetFiles(fullpath); var filteredFiles = FindFiles.Filter(files, pattern).ToArray(); if (filteredFiles.Length == 0) { return("No files has been found"); } foreach (var file in filteredFiles) { try { var assembly = Services.LoadAssembly(file); if (assembly == null) { return("Assembly " + file + " hasn't been loaded"); } fillWithComponents(result, assembly); } catch (Exception) { return("Assembly " + file + " loading failed"); } } var uniqueIndex = new Dictionary <string, Instance>(); foreach (var instance in Components.Value) { uniqueIndex[instance.Info.TypeName] = instance; } Components.Value.Clear(); Components.Value.AddRange(uniqueIndex.Values); return(null); }