zoukankan      html  css  js  c++  java
  • 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框架的。希望各路朋友们多多指教。

  • 相关阅读:
    【PostgreSQL-9.6.3】触发器概述(普通触发器)
    【MySQL】二进制分发安装
    【MySQL】RPM包安装
    【PostgreSQL-9.6.3】分区表
    【PL/SQL】用星号拼出金字塔
    【PostgreSQL-9.6.3】临时表
    【PL/SQL】触发器示例:记录加薪
    【PL/SQL】九九乘法口诀表
    数据结构和算法
    类元编程
  • 原文地址:https://www.cnblogs.com/prolove2/p/prism_1.html
Copyright © 2011-2022 走看看