質問編集履歴

1

ソースコードを全部貼る

2017/05/07 04:22

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -12,30 +12,130 @@
12
12
 
13
13
  ###該当のソースコード
14
14
 
15
+ 呼び出し元
16
+
15
17
  ```C#
16
18
 
17
- public void Load()
19
+ public partial class App : Application
18
-
19
- {
20
-
21
-
22
-
23
- using (StreamReader reader = new StreamReader(file_name, Encoding.UTF8))
24
20
 
25
21
  {
26
22
 
27
23
 
28
24
 
29
- //ここで自分自身に代入したいけど、thisは読み取り専用なので出来ない。
25
+ public static Config config = new Config();
30
26
 
27
+
28
+
29
+ #region Mainメソッド
30
+
31
+ [STAThread]
32
+
33
+ static void Main()
34
+
35
+ {
36
+
37
+
38
+
39
+ config.Load();
40
+
41
+
42
+
43
+ App app = new App();
44
+
31
- this = JsonConvert.DeserializeObject<Config>(reader.ReadToEnd());
45
+ app.InitializeComponent();
46
+
47
+ app.Run();
48
+
49
+
50
+
51
+ }
52
+
53
+ #endregion
32
54
 
33
55
 
34
56
 
35
57
  }
36
58
 
59
+ ```
37
60
 
38
61
 
62
+
63
+ Configクラス
64
+
65
+ ```C#
66
+
67
+ [JsonObject]
68
+
69
+ public class Config
70
+
71
+ {
72
+
73
+
74
+
75
+ private string file_name = "./config.json";
76
+
77
+
78
+
79
+ [JsonProperty("debugMode")]
80
+
81
+ public bool DebugMode { get; set; }
82
+
83
+
84
+
85
+ [JsonProperty("clientToken")]
86
+
87
+ public string ClientToken { get; set; }
88
+
89
+
90
+
91
+ #region コンストラクター
92
+
93
+ public Config()
94
+
95
+ {
96
+
97
+
98
+
99
+ this.DebugMode = false;
100
+
101
+ this.ClientToken = Guid.NewGuid().ToString("N").Substring(0, 32);
102
+
103
+
104
+
39
- }
105
+ }
106
+
107
+ #endregion
108
+
109
+
110
+
111
+ #region Loadメソッド
112
+
113
+ public void Load()
114
+
115
+ {
116
+
117
+
118
+
119
+ using (StreamReader reader = new StreamReader(file_name, Encoding.UTF8))
120
+
121
+ {
122
+
123
+
124
+
125
+ this = JsonConvert.DeserializeObject<Config>(reader.ReadToEnd());
126
+
127
+
128
+
129
+ }
130
+
131
+
132
+
133
+ }
134
+
135
+ #endregion
136
+
137
+
138
+
139
+ }
40
140
 
41
141
  ```