Prism学习(1)---前期准备

在学习Prism框架之前,我预先写了一个非常简单的计算器解决方案。代码如下:

 

复制代码
 1          static  void Main( string[] args)
 2         {
 3              while ( true)
 4             {
 5                  string input = Console.ReadLine();
 6 
 7                  if (CommandTypes.Contains(input))
 8                 {
 9                      int index = Array.IndexOf(CommandTypes, input);
10 
11                      int x =  int.Parse(Console.ReadLine());
12                      int y =  int.Parse(Console.ReadLine());
13 
14                      int result = funs[index](x, y);
15 
16                     Console.WriteLine(result);
17                 }
18                  else
19                 {
20                     Console.WriteLine( " Mistake! ");
21                 }
22             }
23         }
24          static  int Add( int x,  int y)
25         {
26              return x + y;
27         }
28          static  int Sub( int x,  int y)
29         {
30              return x - y;
31         }
32          static  int Mul( int x,  int y)
33         {
34              return x * y;
35         }
36          static  int Div( int x,  int y)
37         {
38              return x / y;
39         }
40 
41          static  string[] CommandTypes = { " add "" sub "" mul "" div " };
42          static Func< intintint>[] funs = { Add, Sub, Mul, Div };
43     }
复制代码

 

在这里,主要是以学习Prism框架为目的。以上的功能,使用如上的,面向过程的方法来实现,很清晰易懂。不过,既然是面向对象的编程。而且在之后的章节中将要应用到Prism框架及其设计思想和模式。所以在本节中,我们还需要先对上面的代码重构一下。 感兴趣的朋友们,可以点击下载

 

我先说明一下,各位下载下去的代码,并没有使用到Prism框架中的任何东西。它只是我为了学习Prism框架而写的一解决方案,算是前期的准备工作。我将在下一章中开始详细记录我是如何学习Prism框架的。希望各路朋友们多多指教。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值