Skip to content

Commit 0098729

Browse files
committed
Code simplification, comments
1 parent 7eba6b8 commit 0098729

File tree

4 files changed

+29
-15
lines changed

4 files changed

+29
-15
lines changed
265 Bytes
Binary file not shown.
3.14 MB
Binary file not shown.

src/c#/GeneralUpdate.PacketTool/Services/MainService.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,13 @@ public class MainService
77
public async Task PostUpgradPakcet<T>(string remoteUrl, string filePath, int clientType, string version, string clientAppKey,string md5,Action<T> reponseCallback) where T : class
88
{
99
if(string.IsNullOrEmpty(remoteUrl)) remoteUrl = "http://127.0.0.1:5001/upload";
10-
var parameters = new Dictionary<string, string>();
11-
parameters.Add("clientType", clientType.ToString());
12-
parameters.Add("version", version);
13-
parameters.Add("clientAppKey", clientAppKey);
14-
parameters.Add("md5", md5);
10+
var parameters = new Dictionary<string, string>
11+
{
12+
{ "clientType", clientType.ToString() },
13+
{ "version", version },
14+
{ "clientAppKey", clientAppKey },
15+
{ "md5", md5 }
16+
};
1517
await HttpService.Instance.PostFileRequest<T>(remoteUrl,parameters, filePath, reponseCallback);
1618
}
1719
}

src/c#/GeneralUpdate.PacketTool/ViewModels/MainViewModel.cs

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using GeneralUpdate.PacketTool.Services;
1010
using GeneralUpdate.Zip.Factory;
1111
using Newtonsoft.Json;
12-
using System.Net.Http.Json;
1312
using System.Text;
1413

1514
namespace GeneralUpdate.PacketTool.ViewModels
@@ -76,9 +75,11 @@ public List<string> AppTypes
7675
{
7776
if (_appTypes == null)
7877
{
79-
_appTypes = new List<string>();
80-
_appTypes.Add("Client");
81-
_appTypes.Add("Upgrade");
78+
_appTypes = new List<string>
79+
{
80+
"Client",
81+
"Upgrade"
82+
};
8283
}
8384
return _appTypes;
8485
}
@@ -90,8 +91,10 @@ public List<string> Formats
9091
{
9192
if (_formats == null)
9293
{
93-
_formats = new List<string>();
94-
_formats.Add(".zip");
94+
_formats = new List<string>
95+
{
96+
".zip"
97+
};
9598
//_formats.Add(".7z");
9699
}
97100
return _formats;
@@ -244,13 +247,22 @@ private async Task BuildJsonCallback()
244247
}
245248
string path = Path.Combine(pickerResult, _jsonTemplateFileName);
246249
if (File.Exists(path)) await Shell.Current.DisplayAlert("Build options", "File already exists !", "check");
247-
var jsonObj = new List<VersionTmplateModel>();
248-
jsonObj.Add(new VersionTmplateModel() { });
249-
jsonObj.Add(new VersionTmplateModel() { });
250-
jsonObj.Add(new VersionTmplateModel() { });
250+
var jsonObj = new List<VersionTmplateModel>
251+
{
252+
new VersionTmplateModel(),
253+
new VersionTmplateModel(),
254+
new VersionTmplateModel()
255+
};
251256
await BuildVersionTemplate(path, jsonObj);
252257
}
253258

259+
/// <summary>
260+
/// Generate a version information file template.
261+
/// </summary>
262+
/// <typeparam name="T"></typeparam>
263+
/// <param name="path">Generate file path.</param>
264+
/// <param name="content">Generate file content.</param>
265+
/// <returns></returns>
254266
private async Task BuildVersionTemplate<T>(string path, T content) where T : class
255267
{
256268
string json = JsonConvert.SerializeObject(content);

0 commit comments

Comments
 (0)