This repository has been archived by the owner on Feb 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
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
1 parent
e63718b
commit 6ba753b
Showing
3 changed files
with
57 additions
and
57 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,56 +1,56 @@ | ||
using System.IO; | ||
using System.IO; | ||
using System.Reflection; | ||
using DeezerSync.Model; | ||
using Newtonsoft.Json; | ||
|
||
namespace DeezerSync | ||
{ | ||
public class Config | ||
{ | ||
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); | ||
public static string soundcloud_profile { get; private set; } | ||
public static string soundcloud_clientid { get; private set; } | ||
public static string deezer_secret { get; private set; } | ||
|
||
private string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.json"); | ||
|
||
public Config() | ||
{ | ||
|
||
} | ||
|
||
public Config(string path) | ||
{ | ||
this.path = path; | ||
} | ||
|
||
public void Read() | ||
{ | ||
try | ||
{ | ||
string config = File.ReadAllText(path); | ||
var result = JsonConvert.DeserializeObject<ConfigModel>(config); | ||
|
||
soundcloud_profile = result.SoundCloud_Username; | ||
soundcloud_clientid = result.SoundCloud_ClientID; | ||
deezer_secret = result.Deezer_Secret; | ||
|
||
} | ||
catch (FileNotFoundException) | ||
{ | ||
logger.Error("No Config File in " + path + " found."); | ||
throw new FileNotFoundException("No Config File in " + path + " found."); | ||
} | ||
catch (IOException e) | ||
{ | ||
logger.Error(e); | ||
throw new IOException(e.Message); | ||
} | ||
catch (JsonException ex) | ||
{ | ||
logger.Error(ex); | ||
throw new JsonException(ex.Message); | ||
} | ||
} | ||
} | ||
} | ||
using DeezerSync.Model; | ||
using Newtonsoft.Json; | ||
|
||
namespace DeezerSync | ||
{ | ||
public class Config | ||
{ | ||
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger(); | ||
public static string soundcloud_profile { get; private set; } | ||
public static string soundcloud_clientid { get; private set; } | ||
public static string deezer_secret { get; private set; } | ||
|
||
private string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "config.json"); | ||
|
||
public Config() | ||
{ | ||
|
||
} | ||
|
||
public Config(string path) | ||
{ | ||
this.path = path; | ||
} | ||
|
||
public void Read() | ||
{ | ||
try | ||
{ | ||
string config = File.ReadAllText(path); | ||
var result = JsonConvert.DeserializeObject<ConfigModel>(config); | ||
|
||
soundcloud_profile = result.SoundCloud_Username; | ||
soundcloud_clientid = result.SoundCloud_ClientID; | ||
deezer_secret = result.Deezer_Secret; | ||
|
||
} | ||
catch (FileNotFoundException) | ||
{ | ||
logger.Error("No Config File in " + path + " found."); | ||
throw new FileNotFoundException("No Config File in " + path + " found."); | ||
} | ||
catch (IOException e) | ||
{ | ||
logger.Error(e); | ||
throw new IOException(e.Message); | ||
} | ||
catch (JsonException ex) | ||
{ | ||
logger.Error(ex); | ||
throw new JsonException(ex.Message); | ||
} | ||
} | ||
} | ||
} |
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
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