Skip to content

Commit

Permalink
Changed how the path of the appseting settings file is determined.
Browse files Browse the repository at this point in the history
  • Loading branch information
mkniller committed Apr 16, 2020
1 parent 50d5c55 commit 7bd702f
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 7bd702f

Please sign in to comment.