Facebook Sharer
选择您要替换的背景颜色:
【农历新年】背景图片:
个性化设定
 注册  找回密码
查看: 1057|回复: 0
打印 上一主题 下一主题

[C#] .net Interface(OO的Interface,不是UI) 的问题[问题解决]

[复制链接]

46

主题

6

好友

6456

积分

百变名嘴

Rank: 13Rank: 13Rank: 13Rank: 13

跳转到指定楼层
1#
发表于 2010-5-16 03:12 AM |只看该作者 |倒序浏览
本帖最后由 宅男-兜着走 于 2010-5-16 12:22 PM 编辑

我想把逻辑跟UI 分开, 所以我就用Interface来Call UI的 Getter/Setter 得到 Form Input, Return 回来的可能就是个 Object/Class

我想做个共用的Interface来 让各个class Implement, 碰到的问题就是, 一样的Interface 我从开了很多次就因为要Return 不同的Class/Object。 有什么方法能够解决的??

例子

  1. //IView.cs
  2. User UserInput{get; set;}
  3. //

  4. //UI.cs
  5. public static class UserForm :UserControl,  IView
  6. {
  7. public User UserInput
  8. {
  9. ...
  10. set
  11.       {
  12.           this.tbUsername.Text = value.UserName;
  13.           this.tbPassword.Text = value.Password
  14.           ....
  15.       }
  16. get
  17. {
  18.        return new User(){UserName = this.tbUsername.Text , Password = this.tbPassword.Text};
  19. }
  20. }
  21. ...
  22. }
  23. }


  24. //ViewLogic.cs
  25. public class ViewLogic()
  26. {
  27.    private IView __view;
  28.    public IView View{....}//Get Set   

  29.     public void InsertToDataBase()
  30.     {
  31.        User user = this.View.UserInput;
  32.        ....
  33.     }
  34. }


  35. //
复制代码
希望大家能明白我的意思。。。




收藏收藏0
您需要登录后才可以回帖 登录 | 注册

JBTALKS.CC |联系我们 |隐私政策 |Share

GMT+8, 2024-10-25 08:20 PM , Processed in 0.119910 second(s), 27 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

Ultra High-performance Dedicated Server powered by iCore Technology Sdn. Bhd.
Domain Registration | Web Hosting | Email Hosting | Forum Hosting | ECShop Hosting | Dedicated Server | Colocation Services
本论坛言论纯属发表者个人意见,与本论坛立场无关
Copyright © 2003-2012 JBTALKS.CC All Rights Reserved
合作联盟网站:
JBTALKS 马来西亚中文论坛 | JBTALKS我的空间 | ICORE TECHNOLOGY SDN. BHD.
回顶部