mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 22:26:31 +00:00
add default api url in case of no config file
This commit is contained in:
@@ -12,7 +12,6 @@ using Azaion.Common.DTO;
|
||||
using Azaion.Common.DTO.Config;
|
||||
using Azaion.Common.Extensions;
|
||||
using Azaion.Common.Services;
|
||||
using Azaion.Suite.Services;
|
||||
using Azaion.Dataset;
|
||||
using Azaion.Suite.Services.DTO;
|
||||
using CommandLine;
|
||||
@@ -40,16 +39,31 @@ public partial class App
|
||||
"Azaion.Dataset.dll"
|
||||
];
|
||||
|
||||
private static readonly IResourceLoader? ResourceLoader;
|
||||
private static readonly IResourceLoader? ResourceLoader = new ResourceLoader("", "", null!, null!);
|
||||
|
||||
static App()
|
||||
{
|
||||
var result = Parser.Default.ParseArguments<SuiteCommandLineOptions>(Environment.GetCommandLineArgs());
|
||||
if (result.Errors.Any())
|
||||
return;
|
||||
|
||||
var configStr = File.ReadAllText(Constants.CONFIG_PATH);
|
||||
var apiConfig = JsonConvert.DeserializeObject<AppConfig>(configStr)!.ApiConfig;
|
||||
ApiConfig apiConfig;
|
||||
try
|
||||
{
|
||||
if (File.Exists(Constants.CONFIG_PATH))
|
||||
throw new FileNotFoundException(Constants.CONFIG_PATH);
|
||||
var configStr = File.ReadAllText(Constants.CONFIG_PATH);
|
||||
apiConfig = JsonConvert.DeserializeObject<AppConfig>(configStr)!.ApiConfig;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
apiConfig = new ApiConfig
|
||||
{
|
||||
Url = "https://api.azaion.com",
|
||||
RetryCount = 3,
|
||||
TimeoutSeconds = 40
|
||||
};
|
||||
}
|
||||
var api = new AzaionApiClient(new HttpClient
|
||||
{
|
||||
BaseAddress = new Uri(apiConfig.Url),
|
||||
|
||||
Reference in New Issue
Block a user