aboutsummaryrefslogtreecommitdiff
path: root/Timeline/Services/PathProvider.cs
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-02-21 15:10:37 +0800
committercrupest <crupest@outlook.com>2020-02-21 15:10:37 +0800
commitf389661667a510d6accfb412482578b66527e6e4 (patch)
tree57a8579bc8b6d2be2831c8e55d5b5b0f552def35 /Timeline/Services/PathProvider.cs
parent3fa9899e17df4b1012e8b645915ac15022b84f9b (diff)
downloadtimeline-f389661667a510d6accfb412482578b66527e6e4.tar.gz
timeline-f389661667a510d6accfb412482578b66527e6e4.tar.bz2
timeline-f389661667a510d6accfb412482578b66527e6e4.zip
Move jwt token key from configuration to database and auto generatable.
Diffstat (limited to 'Timeline/Services/PathProvider.cs')
-rw-r--r--Timeline/Services/PathProvider.cs41
1 files changed, 41 insertions, 0 deletions
diff --git a/Timeline/Services/PathProvider.cs b/Timeline/Services/PathProvider.cs
new file mode 100644
index 00000000..15e66972
--- /dev/null
+++ b/Timeline/Services/PathProvider.cs
@@ -0,0 +1,41 @@
+using Microsoft.Extensions.Configuration;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Threading.Tasks;
+
+namespace Timeline.Services
+{
+ public interface IPathProvider
+ {
+ public string GetWorkingDirectory();
+ public string GetDatabaseFilePath();
+ }
+
+ public class PathProvider : IPathProvider
+ {
+ const string DatabaseFileName = "timeline.db";
+
+ private readonly IConfiguration _configuration;
+
+ private readonly string _workingDirectory;
+
+
+ public PathProvider(IConfiguration configuration)
+ {
+ _configuration = configuration;
+ _workingDirectory = configuration.GetValue<string>("WorkDir");
+ }
+
+ public string GetWorkingDirectory()
+ {
+ return _workingDirectory;
+ }
+
+ public string GetDatabaseFilePath()
+ {
+ return Path.Combine(_workingDirectory, DatabaseFileName);
+ }
+ }
+}