Skip to content

Commit

Permalink
Merge pull request #5 from WireJunky-Solutions/develop
Browse files Browse the repository at this point in the history
Changed how the path of the appsetting settings file is determined.
  • Loading branch information
WireJunky42 authored Apr 16, 2020
2 parents 50d5c55 + 7bd702f commit 367be6d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ obj/

*.sqlite-journal
*.v2
*.pubxml
*.user
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.IO;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
Expand All @@ -26,18 +27,28 @@ public class ExtraLifeStreamLabelService : BackgroundService
private static ParticipantDataModel _previousParticipantData;
private static IConfigurationRoot _config;

private static string GetAssemblyDirectory
{
get
{
string codeBase = Assembly.GetExecutingAssembly().CodeBase;
UriBuilder uri = new UriBuilder(codeBase);
string path = Uri.UnescapeDataString(uri.Path);
return Path.GetDirectoryName(path);
}
}

public ExtraLifeStreamLabelService(ILogger<ExtraLifeStreamLabelService> logger)
{
_logger = logger;
var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");
var builder = new ConfigurationBuilder().SetBasePath(GetAssemblyDirectory).AddJsonFile("appsettings.json");
_config = builder.Build();
_participantEndpoint =
$"participants/{_config.GetSection("ExtraLifeData").Get<ExtraLifeData>().ParticipantId}";

_donationsEndpoint = $"{_participantEndpoint}/donations";
_teamEndpoint = $"teams/{_config.GetSection("ExtraLifeData").Get<ExtraLifeData>().TeamId}";
_previousParticipantData = new ParticipantDataModel();

}

protected override async Task ExecuteAsync(CancellationToken stoppingToken)
Expand Down

0 comments on commit 367be6d

Please sign in to comment.