WPF、WCF、PRISM 更好的使用方法是什么
我正在开发一个 EMR 应用程序作为我的项目。我使用 WCF 从中央服务器传输所有数据,使用 WPF 用于 UI,使用 PRISM 构建模块。
我的 WPF/PRISM 应用程序解决方案中有 3 个项目
- 主项目(mainApplication),其中 shell 和 bootsrapper 所在。
- 类库(modulesLib)保存所有模块
- 类库(基础设施)与wcf服务通信(在Visual Studio 2008中用scvutil.exe添加的服务引用)
项目引用添加如下
- mainApplication具有'modulesLib'和'infrastruction'的引用
- moduleLib 引用了“基础设施”,
我当前的程序如下
- 有 6 个 wcf 服务(6 个主机)使用 Windows 服务公开
- 硬编码数据库详细信息 在 wcf 服务实现(查询、字段、表)中
- 直接使用 viewmodels/presenters 调用 WCF 服务对于模块(通过基础设施库)。
- 创建了名为抽象 ViewModelBase 的类(它实现 INotifyPropertyChanged ,还具有 IUnityContainer、IRegionManager、IEventAggregator 引用)、抽象 ModuleBase (它实现 IModule),每当我添加视图模型或
- 放置所有数据绑定属性的 模块时,我都会使用这两个类进行继承进入 viewmodel 并使用 viewmodel 的构造函数来实例化给定视图,设置其数据上下文并将其添加到 shell
- 列表项
中的区域中,每当我想在模块之间进行通信时,我都会使用 CompositePresentationEvents
我想知道
- 我是否可以使用 CompositePresentationEvents已经做了一些事情,对你们来说似乎还可以。
- 仍然存在大量错误、崩溃错误等......我可以有一个地方来处理这些异常,这样应用程序就不会中断(日志记录或类似的东西)
- 使用 WPF、WCF、MSSQL 处理项目的方式是什么和棱镜
谢谢你, 纳敦
I'm developing an EMR Application as my project. there Im using WCF to transfer all the data from the centralized server , WPF for the UI and PRISM to build modules.
I have 3 projects in my solution for WPF/PRISM application
- The Main project(mainApplication) where the shell and bootsrapper are.
- Class library(modulesLib) to hold all the modules
- Class library(infrastructure) to communicate with wcf service ( service reference added with scvutil.exe in visual studio 2008)
project references are added as below
- mainApplication have references of 'modulesLib' and 'infrastructure'
- modulesLib have refence to 'infrastructure'
my current procedure is below
- There are 6 wcf services (6 hosts) exposed using a windows service
- hard coded database details inside wcf service implementations (queries, fields, tables)
- calling the WCF services directly withing viewmodels/ presenters for modules (through infrastructure library).
- Created classes called abstract ViewModelBase (which implements INotifyPropertyChanged , also having IUnityContainer,IRegionManager,IEventAggregator references) , abstract ModuleBase (which implements IModule) and I use these 2 classes to inherit from whenever I add a viewmodel or a module
- I put all the databinding properties in to viewmodel and use the viewmodel's constructor to instantiate a given view, set its data context and add it to a region in the shell
- List item
whenever I want to communicate between modules, I use CompositePresentationEvents
what I would like to know
- whether the way i have done things, is it seems OK for you guys .
- Still there are loads of errors, crashing bugs etc.. can I have a single place to handle these exceptions so the application wont break (logging or something like that)
- what would be your way to working on a project using WPF,WCF,MSSQL and PRISM
thank you,
Nadun
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你所做的大部分事情都很好。
但对于日志记录模块:在您的基础设施中创建一个单独的项目,并将其注册为 Unity 的单例对象。
2-为了更好地对项目进行单元测试,请充分使用 Unity 作为类的依赖项创建者,就像依赖于合同而不是实际实现一样。
3- 对于模块之间的通信,请使用 EventAgreegator
4- 对于全局命令,请使用 CompositeCommand。
5-如果您的 UI 具有 Combobox、ListBox 等选择器控件,请尝试扩展 Attached 属性,如按钮库的复合应用程序中所做的那样,这样,您就不会在后面的代码中挂钩选择更改事件,而是可以调用命令。
Most of the things you have done is fine.
But for logging module : Create a seprate project in your Infrastructure and register this as a singleton object with Unity.
2- For better unit testing of your project , use unity at it's full as a dependency creator of your classe like depend on the contract rather than actual implementation.
3- For Communication between your modules use EventAgreegator
4- For Global commands use CompositeCommand.
5- If your UI is having selector controls like Combobox, ListBox, try to extend Attached property as done in Composite Application for Button base , so that , you don't hook selection changed event in your code behind rather you will be able to call commands.