Encapsulate

This commit is contained in:
HeshamTB 2018-12-08 20:52:26 +03:00
parent c279b98621
commit 0bbdf3eade
3 changed files with 12 additions and 8 deletions

View File

@ -86,7 +86,7 @@ namespace OWTrack
{ {
try try
{ {
using (StreamReader st = new StreamReader(Paths.SAVES)) using (StreamReader st = new StreamReader(Paths.GetSaves()))
{ {
string line = st.ReadLine(); string line = st.ReadLine();
if (line.Contains("Overwatch.exe")) if (line.Contains("Overwatch.exe"))

View File

@ -25,6 +25,7 @@ using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using System.Collections.Generic; using System.Collections.Generic;
namespace OWTrack namespace OWTrack
{ {
class Tracker class Tracker
@ -114,7 +115,7 @@ namespace OWTrack
} }
} }
} }
foreach (var file in paths) { MessageBox.Show(file); }
if (paths.Count > 1) if (paths.Count > 1)
{ {
//TODO: ask about correct path //TODO: ask about correct path

View File

@ -28,11 +28,14 @@ using System.Threading.Tasks;
namespace OWTrack namespace OWTrack
{ {
static class Paths public static class Paths
{ {
private static string curDir = Directory.GetCurrentDirectory(); private static string curDir = Directory.GetCurrentDirectory();
public static string SAVES = curDir + "/saves/data.json"; private static string SAVES = curDir + "/saves/data.json";
public static string JSON = curDir + "/data.json"; private static string JSON = curDir + "/data.json";
public static string GetJSON() { return JSON; }
public static string GetSaves() { return SAVES; }
public static string GetCurrentDir() { return curDir; }
} }
class saveManeger class saveManeger
@ -45,7 +48,7 @@ namespace OWTrack
{ {
try try
{ {
return JsonConvert.DeserializeObject<Tracker>(File.ReadAllText(Paths.SAVES)); return JsonConvert.DeserializeObject<Tracker>(File.ReadAllText(Paths.GetSaves()));
} }
catch (Exception e) catch (Exception e)
{ {
@ -74,7 +77,7 @@ namespace OWTrack
{ {
try try
{ {
File.WriteAllText(Paths.SAVES, JsonConvert.SerializeObject(tracker)); File.WriteAllText(Paths.GetSaves(), JsonConvert.SerializeObject(tracker));
return true; return true;
} }
catch (Exception) catch (Exception)
@ -91,7 +94,7 @@ namespace OWTrack
{ {
try try
{ {
if (File.Exists(Paths.SAVES)) if (File.Exists(Paths.GetSaves()))
{ {
return true; return true;
} }