使用 Structuremap 解决 WebForms UserControls 中的依赖关系

发布于 2024-10-06 16:33:38 字数 364 浏览 0 评论 0原文

我目前正在使用 httpmodule 通过结构图使用 ObjectFactory.BuildUp() 方法注入页面级别权限。

我想对网络表单用户控件做同样的事情。我有一个基本用户控件,我的所有用户控件都继承它。在此我尝试这样做:

public abstract class BaseUserControl : System.Web.UI.UserControl
{
    public BaseUserControl()
    {
        ObjectFactory.BuildUp(this);   
    }
}

但是,我的依赖项没有注入到我的派生用户控件中。

关于我如何做到这一点有什么想法吗?

I'm currently using a httpmodule to inject my page level permissions using the ObjectFactory.BuildUp() method by structuremap.

I want to do the same thing with webforms user controls. I have a base usercontrol that all my usercontrols inherit. In this I tried to do:

public abstract class BaseUserControl : System.Web.UI.UserControl
{
    public BaseUserControl()
    {
        ObjectFactory.BuildUp(this);   
    }
}

However, my dependencies are not injected in my derived user controls.

Any ideas as to how I can do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文