diff options
author | crupest <crupest@outlook.com> | 2020-02-21 15:10:37 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2020-02-21 15:10:37 +0800 |
commit | 1d5d0c85e24fe9f30d587dc714f1cd7a233c8073 (patch) | |
tree | 57a8579bc8b6d2be2831c8e55d5b5b0f552def35 /Timeline/Services/PathProvider.cs | |
parent | 6cf3c7891fe8a810b20bb799db9f3fb97414c4de (diff) | |
download | timeline-1d5d0c85e24fe9f30d587dc714f1cd7a233c8073.tar.gz timeline-1d5d0c85e24fe9f30d587dc714f1cd7a233c8073.tar.bz2 timeline-1d5d0c85e24fe9f30d587dc714f1cd7a233c8073.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.cs | 41 |
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);
+ }
+ }
+}
|