@@ -18,7 +18,7 @@ public class MainViewModel : ViewModeBase
1818 #region Private Members
1919
2020 private string sourcePath , targetPath , patchPath , infoMessage , url , packetName ;
21- private List < string > _formats , _encodings , _appTypes ;
21+ private List < string > _formats , _encodings , _appTypes ;
2222 private string _currentFormat , _currentEncoding , _currnetAppType , _currentVersion , _currentClientAppKey ;
2323 private bool isPublish ;
2424 private AsyncRelayCommand buildCommand ;
@@ -28,11 +28,11 @@ public class MainViewModel : ViewModeBase
2828 private MainService _mainService ;
2929 private const string _jsonTemplateFileName = "version.json" ;
3030
31- #endregion
31+ #endregion Private Members
3232
3333 #region Constructors
3434
35- public MainViewModel ( IFolderPickerService folderPickerService )
35+ public MainViewModel ( IFolderPickerService folderPickerService )
3636 {
3737 _folderPickerService = folderPickerService ;
3838 _mainService = new MainService ( ) ;
@@ -42,7 +42,7 @@ public MainViewModel(IFolderPickerService folderPickerService)
4242 CurrnetAppType = AppTypes . First ( ) ;
4343 }
4444
45- #endregion
45+ #endregion Constructors
4646
4747 #region Public Properties
4848
@@ -64,14 +64,14 @@ public AsyncRelayCommand BuildCommand
6464 get => buildCommand ?? ( buildCommand = new AsyncRelayCommand ( BuildPacketCallback ) ) ;
6565 }
6666
67- public AsyncRelayCommand BuildJsonCommand
67+ public AsyncRelayCommand BuildJsonCommand
6868 {
69- get => buildJsonCommand ?? ( buildJsonCommand = new AsyncRelayCommand ( BuildJsonCallback ) ) ;
69+ get => buildJsonCommand ?? ( buildJsonCommand = new AsyncRelayCommand ( BuildJsonCallback ) ) ;
7070 }
7171
7272 public List < string > AppTypes
7373 {
74- get
74+ get
7575 {
7676 if ( _appTypes == null )
7777 {
@@ -100,11 +100,11 @@ public List<string> Formats
100100 }
101101 }
102102
103- public List < string > Encodings
103+ public List < string > Encodings
104104 {
105- get
105+ get
106106 {
107- if ( _currentEncoding == null )
107+ if ( _currentEncoding == null )
108108 {
109109 _encodings = new List < string >
110110 {
@@ -122,28 +122,29 @@ public List<string> Encodings
122122 }
123123 }
124124
125- public string CurrentFormat {
125+ public string CurrentFormat
126+ {
126127 get => _currentFormat ;
127- set => SetProperty ( ref _currentFormat , value ) ;
128+ set => SetProperty ( ref _currentFormat , value ) ;
128129 }
129130
130131 public string CurrentEncoding
131132 {
132- get => _currentEncoding ;
133+ get => _currentEncoding ;
133134 set => SetProperty ( ref _currentEncoding , value ) ;
134135 }
135136
136- public string CurrnetAppType
137- {
138- get => _currnetAppType ;
139- set => SetProperty ( ref _currnetAppType , value ) ;
137+ public string CurrnetAppType
138+ {
139+ get => _currnetAppType ;
140+ set => SetProperty ( ref _currnetAppType , value ) ;
140141 }
141142
142143 public string CurrentVersion { get => _currentVersion ; set => SetProperty ( ref _currentVersion , value ) ; }
143144
144145 public string CurrentClientAppKey { get => _currentClientAppKey ; set => SetProperty ( ref _currentClientAppKey , value ) ; }
145-
146- #endregion
146+
147+ #endregion Public Properties
147148
148149 #region Private Methods
149150
@@ -164,9 +165,11 @@ private async Task SelectFolderAction(string value)
164165 case "Source" :
165166 SourcePath = pickerResult ;
166167 break ;
168+
167169 case "Target" :
168170 TargetPath = pickerResult ;
169171 break ;
172+
170173 case "Patch" :
171174 PatchPath = pickerResult ;
172175 break ;
@@ -192,20 +195,20 @@ private async Task BuildPacketCallback()
192195
193196 try
194197 {
195- await DifferentialCore . Instance . Clean ( SourcePath , TargetPath , PatchPath , ( sender , args ) => { } ,
196- String2OperationType ( CurrentFormat ) , String2Encoding ( CurrentEncoding ) , PacketName ) ;
198+ await DifferentialCore . Instance . Clean ( SourcePath , TargetPath , PatchPath , ( sender , args ) => { } ,
199+ String2OperationType ( CurrentFormat ) , String2Encoding ( CurrentEncoding ) , PacketName ) ;
197200 if ( IsPublish )
198201 {
199- var packetPath = Path . Combine ( TargetPath , $ "{ PacketName } { CurrentFormat } ") ;
200- if ( ! File . Exists ( packetPath ) )
202+ var packetPath = Path . Combine ( TargetPath , $ "{ PacketName } { CurrentFormat } ") ;
203+ if ( ! File . Exists ( packetPath ) )
201204 {
202205 await Shell . Current . DisplayAlert ( "Build options" , $ "The package was not found in the following path { packetPath } !", "cancel" ) ;
203206 return ;
204207 }
205208 var md5 = FileUtil . GetFileMD5 ( packetPath ) ;
206- await _mainService . PostUpgradPakcet < UploadReapDTO > ( Url , packetPath , String2AppType ( CurrnetAppType ) , CurrentVersion , CurrentClientAppKey , md5 , async ( resp ) =>
209+ await _mainService . PostUpgradPakcet < UploadReapDTO > ( Url , packetPath , String2AppType ( CurrnetAppType ) , CurrentVersion , CurrentClientAppKey , md5 , async ( resp ) =>
207210 {
208- if ( resp == null )
211+ if ( resp == null )
209212 {
210213 await Shell . Current . DisplayAlert ( "Build options" , "Upload failed !" , "cancel" ) ;
211214 return ;
@@ -270,7 +273,7 @@ private async Task BuildVersionTemplate<T>(string path, T content) where T : cla
270273 if ( File . Exists ( path ) ) await Shell . Current . DisplayAlert ( "Build options" , "Generated successfully !" , "ok" ) ;
271274 }
272275
273- private bool ValidationParameters ( ) => ( string . IsNullOrEmpty ( SourcePath ) || string . IsNullOrEmpty ( TargetPath ) || string . IsNullOrEmpty ( PatchPath ) ||
276+ private bool ValidationParameters ( ) => ( string . IsNullOrEmpty ( SourcePath ) || string . IsNullOrEmpty ( TargetPath ) || string . IsNullOrEmpty ( PatchPath ) ||
274277 string . IsNullOrEmpty ( PacketName ) || string . IsNullOrEmpty ( CurrentFormat ) || string . IsNullOrEmpty ( CurrentEncoding ) ) ;
275278
276279 private bool ValidationFolder ( ) => ( ! Directory . Exists ( SourcePath ) || ! Directory . Exists ( TargetPath ) || ! Directory . Exists ( PatchPath ) ) ;
@@ -283,24 +286,31 @@ private Encoding String2Encoding(string encoding)
283286 case "Default" :
284287 result = Encoding . Default ;
285288 break ;
289+
286290 case "UTF8" :
287291 result = Encoding . UTF8 ;
288292 break ;
293+
289294 case "UTF7" :
290295 result = Encoding . UTF7 ;
291296 break ;
297+
292298 case "Unicode" :
293299 result = Encoding . Unicode ;
294300 break ;
301+
295302 case "UTF32" :
296303 result = Encoding . UTF32 ;
297304 break ;
305+
298306 case "BigEndianUnicode" :
299307 result = Encoding . BigEndianUnicode ;
300308 break ;
309+
301310 case "Latin1" :
302311 result = Encoding . Latin1 ;
303312 break ;
313+
304314 case "ASCII" :
305315 result = Encoding . ASCII ;
306316 break ;
@@ -316,6 +326,7 @@ private OperationType String2OperationType(string type)
316326 case "ZIP" :
317327 result = Zip . Factory . OperationType . GZip ;
318328 break ;
329+
319330 case "7Z" :
320331 result = Zip . Factory . OperationType . G7z ;
321332 break ;
@@ -331,13 +342,14 @@ private int String2AppType(string appType)
331342 case "Client" :
332343 result = 1 ;
333344 break ;
345+
334346 case "UTF8" :
335347 result = 2 ;
336348 break ;
337349 }
338350 return result ;
339351 }
340352
341- #endregion
353+ #endregion Private Methods
342354 }
343- }
355+ }
0 commit comments