Skip to content

Commit 873529c

Browse files
author
Juan Segura
committed
v1.0.0-beta10
List of tools from embedded resource
1 parent 6a9121a commit 873529c

5 files changed

Lines changed: 37 additions & 13 deletions

File tree

ZXBSInstaller.Log/ServiceLayer.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,19 +302,21 @@ public static void OpenUrlInBrowser(string url)
302302
/// <summary>
303303
/// Retrieves all external tools configured for use with the application.
304304
/// </summary>
305+
/// <param name="json">Json string with the external tools information</param>
305306
/// <returns>An array of <see cref="ExternalTool"/> objects representing the available external tools. The array is empty
306307
/// if no external tools are configured or can download the config file.</returns>
307-
public static ExternalTool[] GetExternalTools()
308+
public static ExternalTool[] SetExternalTools(string json)
308309
{
309310
try
310311
{
311312
UpdateStatus?.Invoke("Retrieving external tools information...", 5);
312313

313-
var json = File.ReadAllText("ExternalTools.json");
314-
//// Download the external tools list from the configured URL
315-
//using var httpClient = new HttpClient();
316-
//string json = httpClient.GetStringAsync(GeneralConfig.ToolsListURL).GetAwaiter().GetResult();
317314
var tools = JsonSerializer.Deserialize<ExternalTool[]>(json);
315+
if (tools == null)
316+
{
317+
ShowMessage("ERROR, unable to obtain the list of external tools. Download and install a new version of ZXBSInstaller.");
318+
return null;
319+
}
318320

319321
int max = tools.Length;
320322
int prg = 10;

ZXBSInstaller/Controls/MainControl.axaml.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,14 @@ private void GetExternalTools()
109109
});
110110

111111
// Get tools
112-
var tools = ServiceLayer.GetExternalTools();
112+
var json = UITools.GetTextResource("ExternalTools.json");
113+
var tools = ServiceLayer.SetExternalTools(json);
113114

114115
HideStatusPanel();
115116
if (tools == null)
116117
{
117-
// Error!
118-
ShowMessage("Error retrieving the list of tools, please check your Internet connection.\r\nIt may be a temporary server error, report the error to duefectucorp@gmail.com and try again later.");
118+
// No tools, no way!
119+
ExitApp();
119120
}
120121
else
121122
{

ZXBSInstaller/UITools.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,26 @@ public static void ShowImage(string fileName, Image imgControl)
3131
{
3232
}
3333
}
34+
35+
36+
/// <summary>
37+
/// Read a text file from embedded resource and return the content as string
38+
/// </summary>
39+
/// <param name="fileName">FileName</param>
40+
/// <returns></returns>
41+
public static string GetTextResource(string fileName)
42+
{
43+
try
44+
{
45+
var uri = new Uri($"avares://ZXBSInstaller/{fileName}");
46+
var asset = AssetLoader.Open(uri);
47+
var txt= new StreamReader(asset).ReadToEnd();
48+
return txt;
49+
}
50+
catch (Exception ex)
51+
{
52+
return null;
53+
}
54+
}
3455
}
3556
}

ZXBSInstaller/ZXBSInstaller.csproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<ApplicationManifest>app.manifest</ApplicationManifest>
77
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
88
<ApplicationIcon>zxbs.ico</ApplicationIcon>
9-
<Version>1.0.0.9</Version>
9+
<Version>1.0.0.10</Version>
1010
</PropertyGroup>
1111
<ItemGroup>
1212
<None Remove="Assets\cancel.svg" />
@@ -33,9 +33,9 @@
3333
<AvaloniaResource Include="Assets\zxbsinstaller.png">
3434
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
3535
</AvaloniaResource>
36-
<Content Include="ExternalTools.json">
37-
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
38-
</Content>
36+
<AvaloniaResource Include="ExternalTools.json">
37+
<CopyToOutputDirectory></CopyToOutputDirectory>
38+
</AvaloniaResource>
3939
<Content Include="zxbs.ico" />
4040
</ItemGroup>
4141

ZXBSInstaller/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.0.0.9
1+
1.0.0.10

0 commit comments

Comments
 (0)