This repository has been archived by the owner on Sep 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
84 additions
and
117 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
MonikDesktopSolution/MonikDesktop/Common/Config/AppConfig.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
namespace MonikDesktop.Common.Config | ||
{ | ||
public class AppConfig | ||
{ | ||
public string Accent { get; set; } | ||
public bool IsDark { get; set; } | ||
public string ServerUrl { get; set; } | ||
public string AuthToken { get; set; } | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
MonikDesktopSolution/MonikDesktop/Common/Config/AppConfigStorage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using System; | ||
using System.IO; | ||
using System.Text; | ||
using Newtonsoft.Json; | ||
|
||
namespace MonikDesktop.Common.Config | ||
{ | ||
public class AppConfigStorage | ||
{ | ||
private readonly FileInfo _fileInfo; | ||
|
||
public AppConfigStorage() | ||
{ | ||
_fileInfo = new FileInfo(Path.Combine( | ||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), | ||
@"MonikDesktop\app.config")); | ||
_fileInfo.Directory?.Create(); | ||
} | ||
|
||
public void Save(AppConfig value) | ||
{ | ||
var data = JsonConvert.SerializeObject(value); | ||
File.WriteAllText(_fileInfo.ToString(), data, Encoding.UTF8); | ||
} | ||
|
||
public AppConfig Load() | ||
{ | ||
if (!_fileInfo.Exists) | ||
{ | ||
return new AppConfig(); | ||
} | ||
|
||
var data = File.ReadAllText(_fileInfo.ToString(), Encoding.UTF8); | ||
return JsonConvert.DeserializeObject<AppConfig>(data); | ||
} | ||
} | ||
} |
74 changes: 0 additions & 74 deletions
74
MonikDesktopSolution/MonikDesktop/Properties/Settings.Designer.cs
This file was deleted.
Oops, something went wrong.
18 changes: 0 additions & 18 deletions
18
MonikDesktopSolution/MonikDesktop/Properties/Settings.settings
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters