summaryrefslogtreecommitdiff
path: root/src/SMAPI.Web/Framework
diff options
context:
space:
mode:
Diffstat (limited to 'src/SMAPI.Web/Framework')
-rw-r--r--src/SMAPI.Web/Framework/ConfigModels/MongoDbConfig.cs25
1 files changed, 3 insertions, 22 deletions
diff --git a/src/SMAPI.Web/Framework/ConfigModels/MongoDbConfig.cs b/src/SMAPI.Web/Framework/ConfigModels/MongoDbConfig.cs
index e2e18477..c7b6cb00 100644
--- a/src/SMAPI.Web/Framework/ConfigModels/MongoDbConfig.cs
+++ b/src/SMAPI.Web/Framework/ConfigModels/MongoDbConfig.cs
@@ -1,5 +1,3 @@
-using System;
-
namespace StardewModdingAPI.Web.Framework.ConfigModels
{
/// <summary>The config settings for mod compatibility list.</summary>
@@ -8,14 +6,8 @@ namespace StardewModdingAPI.Web.Framework.ConfigModels
/*********
** Accessors
*********/
- /// <summary>The MongoDB hostname.</summary>
- public string Host { get; set; }
-
- /// <summary>The MongoDB username (if any).</summary>
- public string Username { get; set; }
-
- /// <summary>The MongoDB password (if any).</summary>
- public string Password { get; set; }
+ /// <summary>The MongoDB connection string.</summary>
+ public string ConnectionString { get; set; }
/// <summary>The database name.</summary>
public string Database { get; set; }
@@ -27,18 +19,7 @@ namespace StardewModdingAPI.Web.Framework.ConfigModels
/// <summary>Get whether a MongoDB instance is configured.</summary>
public bool IsConfigured()
{
- return !string.IsNullOrWhiteSpace(this.Host);
- }
-
- /// <summary>Get the MongoDB connection string.</summary>
- public string GetConnectionString()
- {
- bool isLocal = this.Host == "localhost";
- bool hasLogin = !string.IsNullOrWhiteSpace(this.Username) && !string.IsNullOrWhiteSpace(this.Password);
-
- return $"mongodb{(isLocal ? "" : "+srv")}://"
- + (hasLogin ? $"{Uri.EscapeDataString(this.Username)}:{Uri.EscapeDataString(this.Password)}@" : "")
- + $"{this.Host}/{this.Database}?retryWrites=true&w=majority";
+ return !string.IsNullOrWhiteSpace(this.ConnectionString);
}
}
}