summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Config.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2016-10-31 17:15:27 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2016-10-31 17:15:27 -0400
commitb6568f8d9dffca29b088b3840366ede623c142b4 (patch)
treee664482640ac48eae8b4af43517353494cbf0978 /src/StardewModdingAPI/Config.cs
parent7d0cd22f1ec0465c666cf0c69cbfa4da5fd3fe1a (diff)
downloadSMAPI-b6568f8d9dffca29b088b3840366ede623c142b4.tar.gz
SMAPI-b6568f8d9dffca29b088b3840366ede623c142b4.tar.bz2
SMAPI-b6568f8d9dffca29b088b3840366ede623c142b4.zip
remove unused deserialisation logic per discussion
Diffstat (limited to 'src/StardewModdingAPI/Config.cs')
-rw-r--r--src/StardewModdingAPI/Config.cs17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/StardewModdingAPI/Config.cs b/src/StardewModdingAPI/Config.cs
index c5b7beca..f3f4f22a 100644
--- a/src/StardewModdingAPI/Config.cs
+++ b/src/StardewModdingAPI/Config.cs
@@ -47,14 +47,11 @@ namespace StardewModdingAPI
try
{
//try to load the config from a json blob on disk
- var c = JsonConvert.DeserializeObject<T>(File.ReadAllText(ConfigLocation), new JsonSerializerSettings {ContractResolver = new JsonResolver()});
-
- c.ConfigLocation = ConfigLocation;
+ T config = JsonConvert.DeserializeObject<T>(File.ReadAllText(this.ConfigLocation));
+ config.ConfigLocation = this.ConfigLocation;
//update the config with default values if needed
- ret = c.UpdateConfig<T>();
-
- c = null;
+ ret = config.UpdateConfig<T>();
}
catch (Exception ex)
{
@@ -85,10 +82,10 @@ namespace StardewModdingAPI
try
{
//default config
- var b = JObject.FromObject(Instance<T>().GenerateDefaultConfig<T>(), new JsonSerializer {ContractResolver = new JsonResolver()});
+ var b = JObject.FromObject(this.Instance<T>().GenerateDefaultConfig<T>());
//user config
- var u = JObject.FromObject(this, new JsonSerializer {ContractResolver = new JsonResolver()});
+ var u = JObject.FromObject(this);
//overwrite default values with user values
b.Merge(u, new JsonMergeSettings {MergeArrayHandling = MergeArrayHandling.Replace});
@@ -97,7 +94,7 @@ namespace StardewModdingAPI
var c = b.ToObject<T>();
//re-write the location on disk to the object
- c.ConfigLocation = ConfigLocation;
+ c.ConfigLocation = this.ConfigLocation;
return c;
}
@@ -155,7 +152,7 @@ namespace StardewModdingAPI
return;
}
- var s = JsonConvert.SerializeObject(baseConfig, typeof(T), Formatting.Indented, new JsonSerializerSettings {ContractResolver = new JsonResolver()});
+ var s = JsonConvert.SerializeObject(baseConfig, Formatting.Indented);
if (!Directory.Exists(baseConfig.ConfigDir))
Directory.CreateDirectory(baseConfig.ConfigDir);