using Newtonsoft.Json; using ResevalnaScanner.Classes; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace InfosysPublisher.Classes { internal class Settings { public class Application { //SQL strežniki //Privatna polja [JsonProperty] private string _sftpUsername; [JsonProperty] private string _sftpPassword; //Javna polja public string SftpServerAddress { get; set; } public int SftpPort { get; set; } public int BuildSeconds { get; set; } public string LastFolder { get; set; } [JsonIgnore] public string SftpUsername { get => _sftpUsername.AesDecrypt(); set => _sftpUsername = value.AesEncrypt(); } [JsonIgnore] public string SftpPassword { get => _sftpPassword.AesDecrypt(); set => _sftpPassword = value.AesEncrypt(); } public void Save(string iPath) { var json = JsonConvert.SerializeObject(this); if (!Directory.Exists(Path.GetDirectoryName(iPath))) { Directory.CreateDirectory(Path.GetDirectoryName(iPath)); } File.WriteAllText(iPath, json); } } } }