void Populate() { var codeBase = Assembly.GetExecutingAssembly().CodeBase; var uri = new Uri(codeBase); var path = Path.GetDirectoryName(uri.LocalPath); IEnumerable <FileInfo> files = new DirectoryInfo(path).GetFiles("*.dll"); files.Concat(new DirectoryInfo(path).GetFiles("*.exe")); files = files.Where(AssemblyDetails.IsAssembly); var currentAssemblies = _appDomain.GetAssemblies().Where(a => _assemblyFilters.ShouldInclude(a.GetName().Name)).ToList(); foreach (var file in files) { if (!_assemblyFilters.ShouldInclude(file.Name)) { continue; } var assemblyName = AssemblyName.GetAssemblyName(file.FullName); if (!currentAssemblies.Any(assembly => Matches(assemblyName, assembly.GetName()))) { currentAssemblies.Add(Assembly.Load(assemblyName)); } } var assemblies = currentAssemblies.Distinct(comparer); assemblies.ForEach(AddAssembly); }
public void LoadFromAppDomain(_AppDomain appDomain) { if (appDomain == null) { throw new ArgumentNullException("appDomain"); } _types.AddRange(appDomain .GetAssemblies() .SelectMany(item => item.GetTypes())); }