OSDN Git Service

AppliStation,ハッシュが非整合の時に尋ねるようにした。(all-get.exeにも反映)
[applistation/AppliStation.git] / all-get / Util.cs
1 using System;\r
2 \r
3 namespace AllGet\r
4 {\r
5         \r
6         sealed class Util\r
7         {\r
8 //              public static char Query(string msg, string selections, char defaultSelection)\r
9 //              {\r
10 //                      Console.Write(msg);\r
11 //                      string response = Console.ReadLine();\r
12 //                      response.Trim();\r
13 //                      if (response.Length < 1) return defaultSelection;\r
14 //                      int resNum = selections.ToLower().IndexOf(response[0]);\r
15 //                      if (resNum < 0 || resNum >= selections.Length) {\r
16 //                              return Query(msg, selections, defaultSelection);\r
17 //                      } else {\r
18 //                              return selections[resNum];\r
19 //                      }\r
20 //              }\r
21                 \r
22                 public static bool Confirm(string msg, bool defaultSelection)\r
23                 {\r
24                         Console.Write(msg);\r
25                         string response = Console.ReadLine();\r
26                         \r
27                         switch (response.ToLower())\r
28                         {\r
29                                 case "y":\r
30                                         return true;\r
31                                 case "n":\r
32                                         return false;\r
33                                 default:\r
34                                         return defaultSelection;\r
35                         }\r
36                 }\r
37         }\r
38 }\r