Skip to content

Commit c311357

Browse files
committed
refactor(OptionsDebugger): 将类型名称从中文改为使用nameof关键字
替换中文类型名称为使用C#的nameof关键字获取类型名称,提高代码的可维护性和一致性
1 parent 977e502 commit c311357

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

GameFrameX.Foundation.Options/OptionsDebugger.cs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -175,65 +175,65 @@ private static string GetFriendlyTypeName(Type type)
175175
{
176176
if (type == typeof(string))
177177
{
178-
return "字符串";
178+
return nameof(String);
179179
}
180180

181181
if (type == typeof(byte))
182182
{
183-
return "字节";
183+
return nameof(Byte);
184184
}
185185

186186
if (type == typeof(short) || type == typeof(ushort))
187187
{
188-
return "短整数";
188+
return nameof(Int16);
189189
}
190190

191191
if (type == typeof(int) || type == typeof(uint))
192192
{
193-
return "整数";
193+
return nameof(Int32);
194194
}
195195

196196
if (type == typeof(bool))
197197
{
198-
return "布尔值";
198+
return nameof(Boolean);
199199
}
200200

201201
if (type == typeof(double))
202202
{
203-
return "浮点数";
203+
return nameof(Double);
204204
}
205205

206206
if (type == typeof(float))
207207
{
208-
return "单精度浮点数";
208+
return nameof(Single);
209209
}
210210

211211
if (type == typeof(long) || type == typeof(ulong))
212212
{
213-
return "长整数";
213+
return nameof(Int64);
214214
}
215215

216216
if (type == typeof(DateTime))
217217
{
218-
return "日期时间";
218+
return nameof(DateTime);
219219
}
220220

221221
if (type.IsArray)
222222
{
223-
return $"{GetFriendlyTypeName(type.GetElementType())}数组";
223+
return $"Array of {GetFriendlyTypeName(type.GetElementType())} ";
224224
}
225225

226226
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(List<>))
227227
{
228-
return $"{GetFriendlyTypeName(type.GetGenericArguments()[0])}列表";
228+
return $"{GetFriendlyTypeName(type.GetGenericArguments()[0])} list";
229229
}
230230

231231
if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>))
232232
{
233-
return $"可空{GetFriendlyTypeName(type.GetGenericArguments()[0])}";
233+
return $"Nullable<{GetFriendlyTypeName(type.GetGenericArguments()[0])}>";
234234
}
235235

236236
return type.Name;
237237
}
238238
}
239-
}
239+
}

0 commit comments

Comments
 (0)