我想把逻辑跟UI 分开, 所以我就用Interface来Call UI的 Getter/Setter 得到 Form Input, Return 回来的可能就是个 Object/Class
我想做个共用的Interface来 让各个class Implement, 碰到的问题就是, 一样的Interface 我从开了很多次就因为要Return 不同的Class/Object。 有什么方法能够解决的??
例子
- //IView.cs
- User UserInput{get; set;}
- //
- //UI.cs
- public static class UserForm :UserControl, IView
- {
- public User UserInput
- {
- ...
- set
- {
- this.tbUsername.Text = value.UserName;
- this.tbPassword.Text = value.Password
- ....
- }
- get
- {
- return new User(){UserName = this.tbUsername.Text , Password = this.tbPassword.Text};
- }
- }
- ...
- }
- }
- //ViewLogic.cs
- public class ViewLogic()
- {
- private IView __view;
- public IView View{....}//Get Set
- public void InsertToDataBase()
- {
- User user = this.View.UserInput;
- ....
- }
- }
- //



