public Type GetPracticeInterfaceType(IAlgorithmInfo algo) { var ass = algo.GetType().Assembly; var ps = ass.GetTypes().Where(t => { var isI = t.IsInterface; if (isI && t.GetInterface(nameof(IAlgorithm)) != null) { return(true); } return(false); }); if (ps != null && ps.Count() > 0) { return(ps.First()); } return(null); }
public IAlgoTester GetTester(IAlgorithmInfo algo) { var path = algo.GetType().Assembly.Location; var dir = Path.GetDirectoryName(path); dir = Path.Combine(dir, TopicsPath, algo.Dir); var pracs = CreateInstances(dir, "Algo.*.dll", t => { var refed = !t.IsAbstract && t.IsPublic; var type = t.GetInterface(nameof(IAlgoTester)); return(type != null && refed); }, t => Activator.CreateInstance(t) as IAlgoTester, null); if (pracs != null && pracs.Count() > 0) { return(pracs.First()); } return(null); }
public IEnumerable <IAlgorithm> GetAllAlgos(IAlgorithmInfo algo, Action <int> pr) { var inter = GetPracticeInterfaceType(algo); if (inter != null) { var path = algo.GetType().Assembly.Location; var dir = Path.GetDirectoryName(path); dir = Path.Combine(dir, TopicsPath, algo.Dir); var pracs = CreateInstances(dir, "*.dll", t => { var refed = !t.IsAbstract && t.IsPublic; var type = t.GetInterface(inter.Name); return(type != null && refed); }, t => Activator.CreateInstance(t) as IAlgorithm, pr); return(pracs); } return(null); }
public TopicItem(IAlgorithmInfo algo) { _topic = algo; }