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);
|
|
}
|
|
}
|
|
}
|
|
}
|