protected void _Add(Assembly assembly, SelectorFunc selector, bool long_naming) { Type basetype = typeof(_LookupType); string ass_name = assembly.GetName().Name; if (_verbose) { Log.Debug("Discovering types:\n" + "\t-> assembly : {0}\n" + "\t-> base type: {1}, {2}", assembly.FullName, basetype.Name, basetype.FullName ); } //TODO: Could use Linq here to reduce set? _LookupType result; IEnumerable <TypeInfo> types = assembly.DefinedTypes; foreach (TypeInfo ti in types) { //if (ti.IsSubclassOf(basetype)) { result = selector(ti); if (result != null) { string name; if (long_naming) { name = ass_name + "\\" + ti.Name; } else { name = ti.Name; } _lookup.Add(name, result); if (_verbose) { Log.Debug("- {0} ({1}) => {2}", name, ti.FullName, result); } } } } if (_verbose) { Log.Debug("... discovered a total of {0} matches", _lookup.Count); } }
public void _Create(Assembly assembly, SelectorFunc selector) { Type basetype = typeof(_LookupType); if (_verbose) { Log.Debug("Discovering types:\n" + "\t-> assembly : {0}\n" + "\t-> base type: {1}, {2}", assembly.FullName, basetype.Name, basetype.FullName ); } _lookup = new Dictionary <string, _LookupType>(); //TODO: Could use Linq here to reduce set? _LookupType result; IEnumerable <TypeInfo> types = assembly.DefinedTypes; foreach (TypeInfo ti in types) { //if (ti.IsSubclassOf(basetype)) { result = selector(ti); if (result != null) { _lookup.Add(ti.Name, result); if (_verbose) { Log.Debug("- {0} ({1}) => {2}", ti.Name, ti.FullName, result); } } } } if (_verbose) { Log.Debug("... discovered a total of {0} matches", _lookup.Count); } }
protected void _Create(Assembly assembly, SelectorFunc selector) { _lookup = new Dictionary <string, _LookupType>(); _Add(assembly, selector, false); }