Modifica per traduzioni
This commit is contained in:
@@ -2,8 +2,7 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using System.Diagnostics;
|
||||
using System.Text.Json;
|
||||
using System.Reflection;
|
||||
using WebWindowComplex.Compo;
|
||||
using WebWindowComplex.DTO;
|
||||
using WebWindowComplex.Json;
|
||||
@@ -161,23 +160,29 @@ namespace WebWindowComplex
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"Data", "Lemmi.json");
|
||||
|
||||
if (File.Exists(filePath))
|
||||
var assembly = Assembly.GetExecutingAssembly();
|
||||
string? resourceName = assembly.GetManifestResourceNames()
|
||||
.FirstOrDefault(r => r.EndsWith("Lemmi.json", StringComparison.OrdinalIgnoreCase));
|
||||
using Stream? stream = assembly.GetManifestResourceStream(resourceName);
|
||||
if (stream == null)
|
||||
{
|
||||
string jsonText = await File.ReadAllTextAsync(filePath);
|
||||
List<string>? tradList = JsonConvert.DeserializeObject<List<string>>(jsonText);
|
||||
if(tradList != null)
|
||||
Log.Info("File Json non trovato");
|
||||
}
|
||||
else
|
||||
{
|
||||
using StreamReader reader = new StreamReader(stream);
|
||||
string jsonContent = await reader.ReadToEndAsync();
|
||||
|
||||
List<string>? tradList = JsonConvert.DeserializeObject<List<string>>(jsonContent);
|
||||
|
||||
if (tradList != null)
|
||||
{
|
||||
Log.Info("Richiesta Traduzione");
|
||||
prevReqTrad = true;
|
||||
await EC_ReqTraduzione.InvokeAsync(tradList);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.Info("File Json non trovato");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user