使用 Prism 将 InitParams 读取到服务中

发布于 2024-08-19 02:49:50 字数 138 浏览 1 评论 0原文

我正在构建一个 Silverlight 应用程序,它采用单个 InitParam,该 InitParam 将在整个应用程序中使用(至少在许多服务中)。我们正在考虑使用 Prism 构建应用程序,我想知道的是 - 我们如何实例化一个接受此参数并使其全局可用的服务?

I am building a Silverlight application that takes a single InitParam that will be used throughout an application (at least in a number of services). We are looking at building the app using Prism and what I would like to know is - how do we instantiate a service that takes this parameter and makes it globally available?

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

沉默的熊 2024-08-26 02:49:50

您是在问如何读取 InitParams 或者读完后应该用它做什么?要读取它,您可以在 Application.Startup 事件的 StartupEventArgs 中访问它。

private void Application_Startup(object sender, StartupEventArgs e) {
    string blah;
    if (e.InitParams.TryGetValue("ID", out blah)) {
        ...
    }
}

一旦你把它拿出来,我想你可以将它作为命名字符串添加到你的容器中。或者您可以将 StartupEventArgs 粘贴到容器中并根据需要访问它。

Are you asking how to read the InitParams or what you should do with it once you've read it? To read it, you access it in the StartupEventArgs in the Application.Startup event.

private void Application_Startup(object sender, StartupEventArgs e) {
    string blah;
    if (e.InitParams.TryGetValue("ID", out blah)) {
        ...
    }
}

Once you get it out, I suppose you could add it to your container as a named string. Or you could just stick the StartupEventArgs in the container and access it as needed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文