mirror of
https://github.com/immense/Remotely.git
synced 2025-10-26 11:27:15 +00:00
36 lines
1.1 KiB
C#
36 lines
1.1 KiB
C#
using Remotely.Shared.Models;
|
|
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using System.Linq;
|
|
|
|
namespace Remotely.Agent.Services
|
|
{
|
|
public static class ConfigService
|
|
{
|
|
private static ConnectionInfo connectionInfo;
|
|
public static ConnectionInfo GetConnectionInfo()
|
|
{
|
|
if (connectionInfo == null)
|
|
{
|
|
if (!File.Exists("ConnectionInfo.json"))
|
|
{
|
|
Logger.Write(new Exception("No connection info available. Please create ConnectionInfo.json file with appropriate values."));
|
|
return null;
|
|
}
|
|
connectionInfo = JsonConvert.DeserializeObject<ConnectionInfo>(File.ReadAllText("ConnectionInfo.json"));
|
|
}
|
|
|
|
return connectionInfo;
|
|
}
|
|
|
|
|
|
public static void SaveConnectionInfo(ConnectionInfo connectionInfo)
|
|
{
|
|
File.WriteAllText("ConnectionInfo.json", JsonConvert.SerializeObject(connectionInfo));
|
|
}
|
|
}
|
|
}
|