Skip to content
This repository has been archived by the owner on Feb 5, 2021. It is now read-only.

Commit

Permalink
Moved to dotNET 3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BackInBash committed May 10, 2019
1 parent e63718b commit 6ba753b
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 57 deletions.
110 changes: 55 additions & 55 deletions DeezerSync/DeezerSync/Config.cs
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);
}
}
}
}
2 changes: 1 addition & 1 deletion DeezerSync/DeezerSync/DeezerSync.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<TargetFramework>netcoreapp3.0</TargetFramework>
<Version>0.0.1</Version>
<Authors>Markus</Authors>
<Company>[OmG] Network</Company>
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Application to Sync Playlists to Deezer
+ [Newtonsoft.Json](https://github.com/JamesNK/Newtonsoft.Json)
+ [SoundCloud.Api](https://github.com/prayzzz/SoundCloud.Api)

### Build with dotNET Core 2.2 & VS 2019
### Build with dotNET Core 3 Preview 5 & VS 2019

## Getting Started
To run this Program a `config.json` config file is needed in the working directory.
Expand Down

0 comments on commit 6ba753b

Please sign in to comment.