@@ -11,15 +11,30 @@ namespace GeneralUpdate.Core
1111{
1212 public sealed class GeneralUpdateOSS
1313 {
14+ private static Func < string , bool > ? _beforeFunc ;
15+ private static Action < string > ? _afterFunc ;
16+
1417 private GeneralUpdateOSS ( ) { }
1518
1619 #region Public Methods
1720
21+ /// <summary>
22+ /// Starting an OSS update for windows,Linux,mac platform.
23+ /// </summary>
24+ /// <param name="beforeFunc">Inject a custom pre-processing method, which will be executed before updating. whose parameters use the Extend.</param>
25+ /// <param name="afterFunc">Injects a post-processing method whose parameters use the Extend2</param>
26+ public static async Task Start ( Func < string , bool > beforeFunc , Action < string > afterFunc )
27+ {
28+ _beforeFunc = beforeFunc ;
29+ _afterFunc = afterFunc ;
30+ await BaseStart ( ) ;
31+ }
32+
1833 /// <summary>
1934 /// Starting an OSS update for windows,Linux,mac platform.
2035 /// </summary>
2136 /// <returns></returns>
22- public static async Task Start ( ) => await BaseStart ( ) ;
37+ public static async Task Start ( ) => await BaseStart ( ) ;
2338
2439 #endregion Public Methods
2540
@@ -37,9 +52,17 @@ private static async Task BaseStart()
3752 return ;
3853
3954 var parameter = JsonSerializer . Deserialize < GlobalConfigInfoOSS > ( json , GlobalConfigInfoOSSJsonContext . Default . GlobalConfigInfoOSS ) ;
55+ var result = _beforeFunc ? . Invoke ( parameter ? . Extend ) ;
56+ if ( _beforeFunc is not null )
57+ {
58+ if ( result == false )
59+ return ;
60+ }
61+
4062 var strategy = new OSSStrategy ( ) ;
4163 strategy . Create ( parameter ) ;
4264 await strategy . ExecuteAsync ( ) ;
65+ _afterFunc ? . Invoke ( parameter ? . Extend2 ) ;
4366 }
4467 catch ( Exception exception )
4568 {
0 commit comments