public static void OrderDeleted(int orderId) { foreach (var cls in AttachedModules.GetModules <IOrderChanged>()) { MethodInfo method = cls.GetMethod("DoOrderDeleted"); if (method != null) { var classInstance = (IOrderChanged)Activator.CreateInstance(cls, null); if (ModulesRepository.IsActiveModule(classInstance.ModuleStringId)) { method.Invoke(classInstance, new object[] { orderId }); } } } }
public static void RenderDetailsModulesToBottom() { foreach (var cls in AttachedModules.GetModules <IModuleDetails>()) { MethodInfo method = cls.GetMethod("RenderToBottom"); if (method != null) { var classInstance = (IModuleDetails)Activator.CreateInstance(cls, null); if (ModulesRepository.IsActiveModule(classInstance.ModuleStringId)) { method.Invoke(classInstance, null); } } } }
public static ModuleBox GetModules() { var modules = GetModulesFromRemoteServer() ?? new ModuleBox(); var isExistsOnlineModules = modules.Items.Count > 0; foreach (var type in AttachedModules.GetModules()) { var moduleInst = (IModule)Activator.CreateInstance(type, null); Module curModule; if (isExistsOnlineModules && (curModule = modules.Items.FirstOrDefault(item => item.StringId.ToLower() == moduleInst.ModuleStringId.ToLower())) != null) { curModule.IsInstall = moduleInst.CheckAlive() && ModulesRepository.IsInstallModule(moduleInst.ModuleStringId); curModule.HasSettings = moduleInst.HasSettings; curModule.Enabled = ModulesRepository.IsActiveModule(moduleInst.ModuleStringId); } else { modules.Items.Add(new Module() { Name = moduleInst.ModuleName, StringId = moduleInst.ModuleStringId, Version = Resources.Resource.ModulesService_ModuleInDebug, IsInstall = moduleInst.CheckAlive() && ModulesRepository.IsInstallModule(moduleInst.ModuleStringId), Price = 0, IsLocalVersion = true, Active = true, HasSettings = moduleInst.HasSettings, Enabled = ModulesRepository.IsActiveModule(moduleInst.ModuleStringId) }); } } var existModules = ModulesRepository.GetModulesFromDb(); foreach (var module in modules.Items) { Module currentModule; if (existModules.Count > 0 && (currentModule = existModules.FirstOrDefault(item => item.StringId == module.StringId)) != null) { module.CurrentVersion = currentModule.Version; } } return(modules); }
public static string RenderAfterBodyStart() { var builder = new StringBuilder(); foreach (var cls in AttachedModules.GetModules <IRenderIntoHtml>()) { MethodInfo method = cls.GetMethod("DoRenderAfterBodyStart"); if (method != null) { var classInstance = (IRenderIntoHtml)Activator.CreateInstance(cls, null); if (classInstance.CheckAlive() && ModulesRepository.IsActiveModule(classInstance.ModuleStringId)) { builder.Append(method.Invoke(classInstance, null)); } } } return(builder.ToString()); }
public static void OrderUpdated(int orderId) { IOrder order = null; var modules = AttachedModules.GetModules <IOrderChanged>(); if (modules.Count > 0) { order = OrderService.GetOrder(orderId); } foreach (var cls in modules) { MethodInfo method = cls.GetMethod("DoOrderUpdated"); if (method != null) { var classInstance = (IOrderChanged)Activator.CreateInstance(cls, null); if (ModulesRepository.IsActiveModule(classInstance.ModuleStringId)) { method.Invoke(classInstance, new object[] { order }); } } } }