Orchard模块加载事件
我对 Orchard CMS 非常陌生,我已经开始编写我的第一个模块。我一直在寻找一种方法来检测我的模块何时从根网站初始化,但没有运气!
一位同事建议使用 WebActivator 和 PreApplicationStartMethod 属性来配置启动时调用的方法,但这不起作用。
有没有人设法做到这一点,果园是否提供像 IModule 这样的接口,可以让我挂钩模块初始化?
I'm very new to Orchard CMS and I have started writing my first module. I've been looking for a way to detect when my module has been initialized from the root website but have had no luck!
A colleague suggested using WebActivator and the PreApplicationStartMethod attribute to configure a method to be called on start up but this did not work.
Has anybody managed to accomplish this, is there an interface provided by orchard like IModule that will allow me to hook into module initialization?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
解决了!实现 Autofac.Module 并重写 Load(ContainerBuilder) 方法!
Solved! Implement an Autofac.Module and override the Load(ContainerBuilder) method!
您可能会对两个事件处理程序感兴趣。
IFeatureEventHandler
和IOchardShellEvents
。IFeatureEventHandler
接口为您提供模块启用、禁用、安装和卸载的挂钩。IOrchardShellEvents
接口提供了用于激活和终止 Orchard Shell 的钩子。里面的东西应该能帮到你!There are two event handlers that might interest you.
IFeatureEventHandler
andIOrchardShellEvents
. TheIFeatureEventHandler
interface gives you hooks for modules enabling, disabling, installing, and uninstalling. TheIOrchardShellEvents
interface provides hooks for the activation and termination of the Orchard Shell. Something in there should do the trick for you!您不应该混淆 Autofac 和 Orchard 的模块。
要在 Orchard 模块启动时执行一些代码,您需要实现 IOrchardShellEvents 接口(Activated 方法)。另外不要忘记在 Autofac 中注册您的实现:
You shouldn't mix up Autofac's and Orchard's modules.
To execute some code when Orchard's module starts you need to implement IOrchardShellEvents interface (Activated method). Also don't forget to register your implementation in Autofac: