public IEnumerable <IHardwareSupportModule> LoadHardwareSupportModules(string pathToScan, bool recursiveScan) { var toReturn = new List <IHardwareSupportModule>(); try { var moduleTypes = AssemblyTypeScanner <IHardwareSupportModule> .FindMatchingTypesInAssemblies(pathToScan, recursiveScan); foreach (var moduleType in moduleTypes.Distinct()) { try { var instances = moduleType.GetMethod("GetInstances").Invoke(null, null) as IHardwareSupportModule[]; if (instances != null) { toReturn.AddRange(instances); } } catch (Exception e) { _log.Error(e.Message, e); } } } catch (Exception e) { _log.Error(e.Message, e); } return(toReturn); }
public IEnumerable <SimSupportModule> LoadSimSupportModules(string pathToScan, bool recursiveScan) { var toReturn = new List <SimSupportModule>(); try { var moduleTypes = AssemblyTypeScanner <SimSupportModule> .FindMatchingTypesInAssemblies(pathToScan, recursiveScan); foreach (var moduleType in moduleTypes.Distinct()) { try { var module = Activator.CreateInstance(moduleType) as SimSupportModule; toReturn.Add(module); } catch (Exception e) { _log.Error(e.Message, e); } } } catch (Exception e) { _log.Error(e.Message, e); } return(toReturn); }