[英]How do I access Silverlight App.current.resources[“x”] from a class library?
I am new to Silverlight. 我是Silverlight的新手。 Arriving just in time to hear MS pronounce it dead on it's legs.
刚到时听到MS宣告它死在腿上。 :)
:)
In our projected, we have a silverlight app hosted in a aspx page. 在我们的项目中,我们在aspx页面中托管了silverlight应用程序。 There are configuration settings in the web.config (that is being transformed) contaning an environment variable to drive Webservice URLs in the View-Model classes.
web.config中有一些配置设置(正在转换),其中包含一个环境变量来驱动View-Model类中的Web服务URL。
All the view models are making use of a Common class library to establish the WS connection and wrap some often used WS calls. 所有视图模型都使用Common类库来建立WS连接并包装一些经常使用的WS调用。 So when we build the WS, we need to know the environment value so we can divine the correct Service binding.
因此,当我们构建WS时,我们需要知道环境值,以便我们能够确定正确的Service绑定。 Pretty much every part of this solution is in it's own project file.
该解决方案的几乎每个部分都在其自己的项目文件中。
Please exclude the crudeness of my illustraion. 请排除我的幻想的粗野。 web.config -> default.aspx -|-> app.xaml -> Xview.xaml -|-> XViewModel.cs -|-> ClassLib -|-> WCF Service.
web.config-> default.aspx-|-> app.xaml-> Xview.xaml-|-> XViewModel.cs-|-> ClassLib-|-> WCF服务。
-|-> is a project boundary. -|->是项目边界。
Any help would be great. 任何帮助都会很棒。 Even if it's just a vocabulary lesson.
即使只是词汇课程。
Thanks in advance. 提前致谢。
As i don't know the full architecture and how the library is used i don't know if this would work for you but possibly you can inject the instance. 因为我不知道完整的体系结构以及库的使用方式,所以我不知道这是否对您有用,但是您可以注入实例。 eg have a static property in you library which is used internally and set from the outside:
例如,您的库中有一个静态属性,可在内部使用并从外部进行设置:
public static IApp CurrentApp { get; set; }
You probably you will want to declare an IApp
interface in your class library which defines the needed functionality to not make it dependent on one specific application class. 您可能需要在类库中声明一个
IApp
接口,该接口定义了所需的功能,以使其不依赖于一个特定的应用程序类。 This interface then can be implemented by the application and the App
instance can be assigned to the property. 然后可以由应用程序实现此接口,并且可以将
App
实例分配给属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.