我对Castle Windsor for Winforms场景的正确实现感到困惑,我找到的所有文档都是关于WCF和Windows的,所以我请求帮助在ASP.NET窗体中正确实现Castle Windsor。下面是我的代码..。我从MVP http://dotnetchris.wordpress.com/2009/02/16/creating-a-generic-model-view-presenter-framework/的这个方法开始。
为了传递给Winforms,我做了这样的事情
public interface IPresenter<TViewModel>
{
TViewModel View { get; set; }
event EventHandler ViewInitialized;
void OnViewInitialized(EventArgs e);
event EventHandler ViewLoaded;
void OnViewLoaded(EventArgs e);
}
基本形式是
public partial class MvpForm<TPresenter, TViewModel> : Form
where TPresenter : IPresenter<TViewModel>
where TViewModel : class
在第一部分之后,我的演示者是
public class PatientSearchCreatePresenter: IPresenter<IPatientFilterViewModel>
{
IPatientBusinessService patient;
/// <summary>
/// Initializes a new instance of the <see cref="PatientFilterPresenter" /> class.
/// </summary>
public PatientSearchCreatePresenter(IPatientBusinessService Patient)
{
patient = Patient;
}
我用来搜索和创建患者的表单是这样的
public partial class FormSearchCreatePatient : MvpForm<PatientSearchCreatePresenter,IPatientSearchCreateViewModel> , IPatientSearchCreateViewModel
{
应该在何处以及如何执行视图和presenter服务属性的Castle组件的安装和注册
非常感谢
发布于 2013-02-14 16:52:15
这是我以前是怎么做的:
public class BusinessContainer : WindsorContainer
{
public BusinessContainer()
{
RegisterComponents();
}
private void RegisterComponents()
{
// Presenters
AddComponentWithLifestyle("HelloWorld.presenter", typeof(HelloWorldPresenter), LifestyleType.Transient);
}
}
}
由于包含IoC容器有点复杂,要获得完整的一步一步的内容,请查看here。
https://stackoverflow.com/questions/14858860
复制相似问题