private static void RegisterPlugins() { IEnumerable <Type> pluginTypes = TypeFinder.FindFromAssemblies <IPlugin>(AppDomain.CurrentDomain.GetAssemblies()); if (pluginTypes != null) { foreach (Type pluginType in pluginTypes) { IPlugin plugin = Activator.CreateInstance(pluginType) as IPlugin; plugin.RegisterRoute(); } } }
static CommandFactory() { Activtor = new DefalutActivtor(); Commands = new ConcurrentDictionary <string, Type>(); IEnumerable <Type> types = TypeFinder.FindFromAssemblies <CommandBase>(AppDomain.CurrentDomain.GetAssemblies()); foreach (var type in types) { //ConstructorInfo constructor = type.GetConstructor(Type.EmptyTypes); if (type.Name.EndsWith("Command")) { Commands.TryAdd(type.Name.Substring(0, type.Name.Length - 7), type); } #if DEBUG else { Logger.ErrorFormat("{0} is a invalid commad.", type.FullName); } #endif } }