internal static void DiscoverCommandFactories(ModuleAssembly In, CommandParser AddTo) { foreach (var type in In.Assembly.GetTypes()) { if (type.FullName.StartsWith(In.Info.BaseNameSpace) && type.IsSubclassOf(typeof(CommandFactory))) { CommandFactory.CreateCommandFactory(type).Create(AddTo); } } }
/// <summary> /// Integrate a module into the running game by calling every static AtStartup method found on any type /// in the module's base namespace. /// </summary> /// <param name="Module"></param> private static void IntegrateModule(ModuleAssembly Module) { if (Module == null) { throw new InvalidOperationException("Tried to load null module"); } if (Module.Assembly == null) { throw new InvalidOperationException("Tried to load invalid module assembly - " + Module.FileName); } if (Module.Info == null) { throw new InvalidOperationException("Tried to load invalid module assembly - " + Module.FileName); } foreach (var type in Module.Assembly.GetTypes()) { if (type.FullName.StartsWith(Module.Info.BaseNameSpace)) { foreach (var method in type.GetMethods()) { if (method.IsStatic && method.Name == "AtStartup") { try { method.Invoke(null, new Object[] { GlobalRules }); } catch (Exception e) { LogWarning("Error while loading module " + Module.FileName + " : " + e.Message); } } } } } }
/// <summary> /// Integrate a module into the running game by calling every static AtStartup method found on any type /// in the module's base namespace. /// </summary> /// <param name="Module"></param> private static void IntegrateModule(ModuleAssembly Module) { if (Module == null) throw new InvalidOperationException("Tried to load null module"); if (Module.Assembly == null) throw new InvalidOperationException("Tried to load invalid module assembly - " + Module.FileName); if (Module.Info == null) throw new InvalidOperationException("Tried to load invalid module assembly - " + Module.FileName); foreach (var type in Module.Assembly.GetTypes()) if (type.FullName.StartsWith(Module.Info.BaseNameSpace)) foreach (var method in type.GetMethods()) if (method.IsStatic && method.Name == "AtStartup") try { method.Invoke(null, new Object[] { GlobalRules }); } catch (Exception e) { LogWarning("Error while loading module " + Module.FileName + " : " + e.Message); } }
internal static void DiscoverCommandFactories(ModuleAssembly In, CommandParser AddTo) { foreach (var type in In.Assembly.GetTypes()) if (type.FullName.StartsWith(In.Info.BaseNameSpace) && type.IsSubclassOf(typeof(CommandFactory))) CommandFactory.CreateCommandFactory(type).Create(AddTo); }