NBear Presenter需要多个Service时的处理方法
来源:互联网 发布:非洲有没有帅哥知乎 编辑:程序博客网 时间:2024/04/29 16:59
第一种是在范型参数中定义两个以上service,注意此时你的Presentor要实现IPresentor2接口,是IPresentor2不是IPresentor。
地而种更通用和推荐的方法是,使用让Presentor继承不带IModel的Presentor<IView>(注意该方法也要实现IPresentor2接口),
在Presentor中可以直接使用NBear.IoC.Service.ServiceFactory.Create
().GetService<IServiceType>()取得任意数量service(Create().返回的是一个ServiceFactory的Singleton)。这样service的数量没有限制,而且view和presentor对具体的service也没有任何依赖,因此这种方法就更通用。
Teddy
On 2/7/07, homer <home...@gmail.com> wrote:
> 以下是IPresenter接口的定义:
> // Summary:
> // Interface of all presenters
> public interface IPresenter
> {
> // Summary:
> // Gets the type of model.
> Type TypeOfModel { get; }
> //
> // Summary:
> // Gets the type of view.
> Type TypeOfView { get; }
> // Summary:
> // Binds the model.
> //
> // Parameters:
> // model:
> // The model.
> void BindModel(object model);
> //
> // Summary:
> // Binds the view.
> //
> // Parameters:
> // view:
> // The view.
> void BindView(object view);
> }
> 但是当我使用Presenter<IDefaultView, INoticeService, ICollegeService,
> ICourseService, IApplyService, IUserService>作为基类继承时,编译器提示没有完全实现
> IPresenter接口。查看Presenter,发现其定义如下:
> // Summary:
> // Base class of all presenters
> //
> // Type parameters:
> // ViewType:
> //
> // IModelType1:
> //
> // IModelType2:
> //
> // IModelType3:
> //
> // IModelType4:
> //
> // IModelType5:
> public abstract class Presenter<ViewType, IModelType1,
> IModelType2, IModelType3, IModelType4, IModelType5> : IPresenter2
> where IModelType1 : NBear.IoC.Service.IServiceInterface
> where IModelType2 : NBear.IoC.Service.IServiceInterface
> where IModelType3 : NBear.IoC.Service.IServiceInterface
> where IModelType4 : NBear.IoC.Service.IServiceInterface
> where IModelType5 : NBear.IoC.Service.IServiceInterface
> {
> // Summary:
> // The model 1
> protected IModelType1 model1;
> //
> // Summary:
> // The model 2
> protected IModelType2 model2;
> //
> // Summary:
> // The model 3
> protected IModelType3 model3;
> //
> // Summary:
> // The model 4
> protected IModelType4 model4;
> //
> // Summary:
> // The model 5
> protected IModelType5 model5;
> //
> // Summary:
> // The view
> protected ViewType view;
> protected Presenter();
> // Summary:
> // Gets a value indicating whether this
> NBear.MVP.Presenter
> <ViewType,IModelType1,IModelType2,IModelType3,IModelType4,IModelType5>
> // is initialized.
> public bool Initialized { get; }
> //
> // Summary:
> // Gets the types of the model.
> public Type[] TypeOfModels { get; }
> //
> // Summary:
> // Gets the type of the view.
> public Type TypeOfView { get; }
> // Summary:
> // Binds the models.
> //
> // Parameters:
> // model:
> // The models.
> public void BindModels(object[] models);
> //
> // Summary:
> // Binds the view.
> //
> // Parameters:
> // view:
> // The view.
> public void BindView(object view);
> }
> 在Presenter中实现了TypeOfModels和BindModels,却没有实现IPresenter接口中定义的TypeOfModel和
> BindModel。
> 对于这个问题,不知道是否属于设计疏漏,还是有其他的使用方法我不知道?
> 另外对于Presenter的设计,感觉需要改进,现在对于多Service的支持有些丑陋,也没有很好的扩展性。假设需要支持8个或以上的
> Service,这种设计就不支持了。总不至于我们再写一个支持8个Service的范型吧?
> 现在的项目正在使用NBear,感觉很多功能很方便,也改变了我以前的设计习惯(以前是table->modle,现在是model->table),
> 感觉更OO了。但是NBear还不成熟,特别是文档稀缺,SDK文档给予的信息相当少(基本上只能查到类和函数的定义,不能看出使用方法和注意事项)。
> 所有能够参考的只能是teddy写的教程,稍高级的用法只能看源码分析,学习和使用都不方便,需要改进。
> 总的来说,谢谢teddy和其他NBear开发者,谢谢你们带给我们这么好的工具。
转自:http://groups.google.com/group/nbeargroup/msg/86875e4511bcf831
- NBear Presenter需要多个Service时的处理方法
- 当Web服务需要传递多个参数时的处理方法
- 使用NBear设计一个新的实体类时需要进行的操作
- 关于Selector方法需要多个参数的问题解决方法
- Android Service 一般需要用到的4个类
- WPF的Presenter(ContentPresenter)
- gouwuche的presenter
- 当在一个方法中需要返回多个参数时的做法
- IO操作中关闭流的注意点(多个关闭时的异常需要单独处理)
- Presenter
- Presenter
- presenter
- 明细合计回写总表的处理,应在Presenter的DoBeforePost中处理,如
- service相关方法处理
- NBear.Mapping教程(2):NBear.Mapping的配置系统
- 关于NBear的一点问题
- NBear的优缺点粗略分析
- 有关于NBear的简介
- 浅谈.NET中的数据绑定表达式(一)(转)
- 取汉字首字母的类, 支持多音字
- Microsoft类库开发的设计准则
- 两种利用内存流存取图片的经典例子
- linux操作系统下的域名解析系统设置
- NBear Presenter需要多个Service时的处理方法
- ASP.NET数据绑定与面页的嵌入式代码
- 嵌入式GUI与Qt/Embedded
- 用C#读取GPS数据的基类,适用于wince操作系统。 适合自带GPS模块的PDA或智能手机的设备
- Oracle/PLSQL: Foreign Keys
- classmethod,staticmethod,还有类里面一般的的method有什么区别
- 浅谈.NET中的数据绑定表达式(二)
- NCR5887 ATM机出钞时卡钞解决方法-NCR5887常见故障系列二
- Succes in speech