File tree Expand file tree Collapse file tree
GameFrameX.Utility/Setting Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11using GameFrameX . Foundation . Json ;
2+ using GameFrameX . Utility . Extensions ;
23
34namespace GameFrameX . Utility . Setting ;
45
@@ -71,15 +72,27 @@ public static void Load(string path)
7172 /// <remarks>
7273 /// 此方法用于更新全局的当前设置。
7374 /// 通常在应用程序启动时或需要切换配置时调用。
75+ /// 该方法具有以下特点:
76+ /// 1. 只能设置一次,重复设置会抛出异常
77+ /// 2. 不允许传入null值
78+ /// 3. 会自动校正SaveDataInterval的值,如果小于5000毫秒则使用默认值
7479 /// </remarks>
80+ /// <exception cref="InvalidOperationException">当CurrentSetting已存在时抛出此异常</exception>
81+ /// <exception cref="ArgumentNullException">当传入的setting参数为null时抛出此异常</exception>
7582 public static void SetCurrentSetting ( AppSetting setting )
7683 {
84+ if ( CurrentSetting . IsNotNull ( ) )
85+ {
86+ throw new InvalidOperationException ( "当前设置已经存在,不能再次设置" ) ;
87+ }
88+
7789 ArgumentNullException . ThrowIfNull ( setting , nameof ( setting ) ) ;
78- CurrentSetting = setting ;
79- if ( setting . SaveDataInterval < 1000 )
90+ if ( setting . SaveDataInterval < 5000 )
8091 {
8192 setting . SaveDataInterval = GlobalConst . SaveIntervalInMilliSeconds ;
8293 }
94+
95+ CurrentSetting = setting ;
8396 }
8497
8598 /// <summary>
You can’t perform that action at this time.
0 commit comments