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框架的。希望各路朋友们多多指教。

  • 相关阅读:
    C#和JAVA的RSA密钥、公钥转换
    JAVA RSA私钥 加密(签名) 对应 C# RSA私钥 加密(签名)
    Senparc.Weixin.MP SDK 微信公众平台开发教程(九):自定义菜单接口说明
    微信资料
    OAuth2.0实战之微信授权篇
    URL中出现了%E2%80%8E(Zero-Width Space)
    AntDesign vue学习笔记(六)Table 显示图片
    NPOI导出 The maximum column width for an individual cell is 255 characters
    AntDesign vue学习笔记(五)导航菜单动态加载
    AntDesign vue学习笔记(四)使用组件切换
  • 原文地址:https://www.cnblogs.com/prolove2/p/prism_1.html
Copyright © 2011-2022 走看看