mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
49 lines
1.4 KiB
C#
49 lines
1.4 KiB
C#
using Remotely.Desktop.Core.Interfaces;
|
|
using Remotely.Shared.Models;
|
|
using Remotely.Shared.Utilities;
|
|
using System;
|
|
using System.IO;
|
|
using System.Text.Json;
|
|
|
|
namespace Remotely.Desktop.Linux.Services
|
|
{
|
|
public class ConfigServiceLinux : IConfigService
|
|
{
|
|
private static string _configFile => Path.Combine(_configFolder, "Config.json");
|
|
private static string _configFolder => Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "remotely.json");
|
|
|
|
public DesktopAppConfig GetConfig()
|
|
{
|
|
var config = new DesktopAppConfig();
|
|
|
|
if (string.IsNullOrWhiteSpace(config.Host) &&
|
|
File.Exists(_configFile))
|
|
{
|
|
try
|
|
{
|
|
config = JsonSerializer.Deserialize<DesktopAppConfig>(File.ReadAllText(_configFile));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Logger.Write(ex);
|
|
}
|
|
}
|
|
|
|
return config;
|
|
}
|
|
|
|
public void Save(DesktopAppConfig config)
|
|
{
|
|
try
|
|
{
|
|
Directory.CreateDirectory(_configFolder);
|
|
File.WriteAllText(_configFile, JsonSerializer.Serialize(config));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
Logger.Write(ex);
|
|
}
|
|
}
|
|
}
|
|
}
|