@@ -41,16 +41,18 @@ namespace GameFrameX.Foundation.Options
4141 /// </summary>
4242 public static class OptionsDebugger
4343 {
44- const string OptionHeader = "选项 (Option)" ;
45- const string ValueHeader = "值 (Value)" ;
46- const string RequiredHeader = "必需 (Required)" ;
47- const string TypeNameHeader = "类型 (Type)" ;
48- const string DescriptionHeader = "描述 (Description)" ;
49- const string DefaultValueHeader = "默认值 (Default)" ;
50- const string RequiredYesLabel = "是 (Yes)" ;
51- const string RequiredNoLabel = "否 (No)" ;
52- const string NoDescriptionLabel = "无描述 (No Description)" ;
53- const string NoOptionAttributeLabel = "无选项特性 (No Option Attribute)" ;
44+ private const string OptionHeader = "选项 (Option)" ;
45+ private const string ValueHeader = "值 (Value)" ;
46+ private const string RequiredHeader = "必需 (Required)" ;
47+ private const string TypeNameHeader = "类型 (Type)" ;
48+ private const string DescriptionHeader = "描述 (Description)" ;
49+ private const string DefaultValueHeader = "默认值 (Default)" ;
50+ private const string RequiredYesLabel = "是 (Yes)" ;
51+ private const string RequiredNoLabel = "否 (No)" ;
52+ private const string NoDescriptionLabel = "无描述 (No Description)" ;
53+ private const string NoOptionAttributeLabel = "无选项特性 (No Option Attribute)" ;
54+ private const int MaxDisplayElements = 5 ;
55+ private const int DefaultConsoleWidth = 120 ;
5456
5557 /// <summary>
5658 /// 打印解析完成后的选项对象
@@ -174,7 +176,7 @@ public static void PrintParsedOptions<T>(T options) where T : class
174176 }
175177 catch
176178 {
177- consoleWidth = 120 ;
179+ consoleWidth = DefaultConsoleWidth ;
178180 }
179181
180182 int maxTableWidth = Math . Max ( 60 , consoleWidth - 1 ) ;
@@ -452,13 +454,13 @@ private static string FormatPropertyValue(object value)
452454 {
453455 var array = ( Array ) value ;
454456 var elements = new List < string > ( ) ;
455- for ( int i = 0 ; i < Math . Min ( array . Length , 5 ) ; i ++ )
457+ for ( int i = 0 ; i < Math . Min ( array . Length , MaxDisplayElements ) ; i ++ )
456458 {
457459 elements . Add ( array . GetValue ( i ) ? . ToString ( ) ?? "null" ) ;
458460 }
459461
460462 var result = $ "[{ string . Join ( ", " , elements ) } ]";
461- if ( array . Length > 5 )
463+ if ( array . Length > MaxDisplayElements )
462464 {
463465 result += $ " (Total { array . Length } elements / 共{ array . Length } 个元素)";
464466 }
@@ -470,13 +472,13 @@ private static string FormatPropertyValue(object value)
470472 {
471473 var list = ( System . Collections . IList ) value ;
472474 var elements = new List < string > ( ) ;
473- for ( int i = 0 ; i < Math . Min ( list . Count , 5 ) ; i ++ )
475+ for ( int i = 0 ; i < Math . Min ( list . Count , MaxDisplayElements ) ; i ++ )
474476 {
475477 elements . Add ( list [ i ] ? . ToString ( ) ?? "null" ) ;
476478 }
477479
478480 var result = $ "[{ string . Join ( ", " , elements ) } ]";
479- if ( list . Count > 5 )
481+ if ( list . Count > MaxDisplayElements )
480482 {
481483 result += $ " (Total { list . Count } elements / 共{ list . Count } 个元素)";
482484 }
@@ -539,7 +541,7 @@ private static string GetFriendlyTypeName(Type type)
539541
540542 if ( type . IsArray )
541543 {
542- return $ "Array of { GetFriendlyTypeName ( type . GetElementType ( ) ) } ";
544+ return $ "Array of { GetFriendlyTypeName ( type . GetElementType ( ) ) } ";
543545 }
544546
545547 if ( type . IsGenericType && type . GetGenericTypeDefinition ( ) == typeof ( List < > ) )
0 commit comments