Add project files.
This commit is contained in:
52
ModVersionChecker/managers/filesystem/AppStatusManager.cs
Normal file
52
ModVersionChecker/managers/filesystem/AppStatusManager.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using ModVersionChecker.data.model;
|
||||
using ModVersionChecker.managers.interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ModVersionChecker.managers.filesystem
|
||||
{
|
||||
|
||||
public class AppStatusManager : IAppStatusManager
|
||||
{
|
||||
private Dictionary<string, AppStatus> _statuses = new Dictionary<string, AppStatus>();
|
||||
|
||||
public AppStatusManager() { }
|
||||
public AppStatus? GetAppStatus(string appId)
|
||||
{
|
||||
if (!_statuses.ContainsKey(appId))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return _statuses[appId];
|
||||
}
|
||||
public List<AppStatus> Load()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void Save(List<AppStatus> appStatuses)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public void UpdateAppStatus(string appId, AppStatus appStatus)
|
||||
{
|
||||
if (_statuses.ContainsKey(appId))
|
||||
{
|
||||
_statuses[appId] = appStatus;
|
||||
} else
|
||||
{
|
||||
_statuses.Add(appId, appStatus);
|
||||
}
|
||||
}
|
||||
public bool DeleteAppStatus(string appId) {
|
||||
return _statuses.Remove(appId);
|
||||
}
|
||||
public void ClearAll()
|
||||
{
|
||||
_statuses.Clear();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
42
ModVersionChecker/managers/filesystem/AppsManager.cs
Normal file
42
ModVersionChecker/managers/filesystem/AppsManager.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using ModVersionChecker.managers.interfaces;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace ModVersionChecker.managers.filesystem
|
||||
{
|
||||
public class AppsManager
|
||||
{
|
||||
private readonly string FilePath = Path.Combine(AppContext.BaseDirectory, "data", "apps.json");
|
||||
|
||||
public List<AppConfig> Load()
|
||||
{
|
||||
if (!File.Exists(FilePath))
|
||||
return new List<AppConfig>();
|
||||
var json = File.ReadAllText(FilePath);
|
||||
return JsonSerializer.Deserialize<List<AppConfig>>(json) ?? new();
|
||||
}
|
||||
|
||||
public void Save(List<AppConfig> apps)
|
||||
{
|
||||
var options = new JsonSerializerOptions { WriteIndented = true };
|
||||
var json = JsonSerializer.Serialize(apps, options);
|
||||
File.WriteAllText(FilePath, json);
|
||||
}
|
||||
|
||||
public void Upsert(AppConfig app)
|
||||
{
|
||||
var apps = Load();
|
||||
var index = apps.FindIndex(a => a.Id == app.Id);
|
||||
if (index >= 0)
|
||||
{
|
||||
apps[index] = app;
|
||||
}
|
||||
else
|
||||
{
|
||||
apps.Add(app);
|
||||
}
|
||||
Save(apps);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
using ModVersionChecker.data.model;
|
||||
using ModVersionChecker.managers.interfaces;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace ModVersionChecker.managers.filesystem
|
||||
{
|
||||
public class CheckerTypesDefManager : ICheckerTypesDefManager
|
||||
{
|
||||
private readonly string FilePath = Path.Combine(AppContext.BaseDirectory, "data", "checkerTypesDef.json");
|
||||
|
||||
public List<CheckerTypeDef> Load()
|
||||
{
|
||||
if (!File.Exists(FilePath))
|
||||
return new List<CheckerTypeDef>();
|
||||
var json = File.ReadAllText(FilePath);
|
||||
return JsonSerializer.Deserialize<List<CheckerTypeDef>>(json) ?? new();
|
||||
}
|
||||
|
||||
public void Save(List<CheckerTypeDef> checkerTypesDef)
|
||||
{
|
||||
var options = new JsonSerializerOptions { WriteIndented = true };
|
||||
var json = JsonSerializer.Serialize(checkerTypesDef, options);
|
||||
File.WriteAllText(FilePath, json);
|
||||
}
|
||||
}
|
||||
}
|
40
ModVersionChecker/managers/filesystem/ConfigManager.cs
Normal file
40
ModVersionChecker/managers/filesystem/ConfigManager.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using ModVersionChecker.data.model;
|
||||
using ModVersionChecker.managers.interfaces;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace ModVersionChecker.managers.filesystem
|
||||
{
|
||||
public class ConfigManager : IConfigManager
|
||||
{
|
||||
|
||||
private static readonly string _filePath = Path.Combine(AppContext.BaseDirectory, "data", "config.json");
|
||||
private GlobalConfig _config;
|
||||
|
||||
public ConfigManager()
|
||||
{
|
||||
_config = Load();
|
||||
}
|
||||
|
||||
public GlobalConfig Load()
|
||||
{
|
||||
if (!File.Exists(_filePath))
|
||||
return new GlobalConfig();
|
||||
var json = File.ReadAllText(_filePath);
|
||||
return JsonSerializer.Deserialize<GlobalConfig>(json) ?? new GlobalConfig();
|
||||
}
|
||||
|
||||
public GlobalConfig GetConfig()
|
||||
{
|
||||
return _config;
|
||||
}
|
||||
|
||||
public void Save(GlobalConfig config)
|
||||
{
|
||||
var options = new JsonSerializerOptions { WriteIndented = true };
|
||||
var json = JsonSerializer.Serialize(config, options);
|
||||
File.WriteAllText(_filePath, json);
|
||||
}
|
||||
}
|
||||
}
|
22
ModVersionChecker/managers/filesystem/NotifyIconService.cs
Normal file
22
ModVersionChecker/managers/filesystem/NotifyIconService.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using ModVersionChecker.managers.interfaces;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ModVersionChecker.managers.filesystem
|
||||
{
|
||||
public class NotifyIconService : INotifyIconService
|
||||
{
|
||||
private NotifyIcon? _notifyIcon;
|
||||
public void SetNotifyIcon(NotifyIcon icon)
|
||||
{
|
||||
_notifyIcon = icon;
|
||||
}
|
||||
public void ShowBalloonTip(int millis, string title, string message, ToolTipIcon icon)
|
||||
{
|
||||
_notifyIcon?.ShowBalloonTip(millis, title, message, icon);
|
||||
}
|
||||
}
|
||||
}
|
52
ModVersionChecker/managers/filesystem/SourcesDefManager.cs
Normal file
52
ModVersionChecker/managers/filesystem/SourcesDefManager.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using ModVersionChecker.data.model;
|
||||
using ModVersionChecker.managers.interfaces;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace ModVersionChecker.managers.filesystem
|
||||
{
|
||||
public class SourcesDefManager
|
||||
{
|
||||
private readonly string _filePath = Path.Combine(AppContext.BaseDirectory, "data", "sourcesDef.json");
|
||||
private List<SourceDef> _sourcesDef = new List<SourceDef>();
|
||||
|
||||
public SourcesDefManager()
|
||||
{
|
||||
_sourcesDef = Load();
|
||||
}
|
||||
|
||||
private List<SourceDef> Load()
|
||||
{
|
||||
if (!File.Exists(_filePath))
|
||||
return new List<SourceDef>();
|
||||
var json = File.ReadAllText(_filePath);
|
||||
return JsonSerializer.Deserialize<List<SourceDef>>(json) ?? new();
|
||||
}
|
||||
|
||||
public List<SourceDef> GetSourcesDef()
|
||||
{
|
||||
return _sourcesDef;
|
||||
}
|
||||
|
||||
public void AddSourceDef(SourceDef sourceDef)
|
||||
{
|
||||
_sourcesDef.Add(sourceDef);
|
||||
Save(_sourcesDef);
|
||||
}
|
||||
|
||||
public void RemoveSourceDef(string id)
|
||||
{
|
||||
_sourcesDef.RemoveAll(s => s.Id == id);
|
||||
Save(_sourcesDef);
|
||||
}
|
||||
|
||||
|
||||
public void Save(List<SourceDef> sourcesDef)
|
||||
{
|
||||
var options = new JsonSerializerOptions { WriteIndented = true };
|
||||
var json = JsonSerializer.Serialize(sourcesDef, options);
|
||||
File.WriteAllText(_filePath, json);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user