Skip to content

Commit

Permalink
Merge branch 'develop/v2' into feature/remove-database-cache-client
Browse files Browse the repository at this point in the history
  • Loading branch information
truongtphat authored Sep 12, 2024
2 parents 7a81c78 + 221b5ba commit 1b70466
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/mix.heart/Enums/MixCacheMode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
public enum MixCacheMode
{
JSON,
DATABASE,
REDIS
}
}
11 changes: 7 additions & 4 deletions src/mix.heart/Services/ConfigurationServiceBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ public ConfigurationServiceBase(string filePath, bool isEncrypt)

public TValue GetConfig<TValue>(string name, TValue defaultValue = default)
{
var result = RawSettings[name];
return result != null ? result.Value<TValue>() : defaultValue;
if(RawSettings.TryGetValue(name, StringComparison.OrdinalIgnoreCase, out var result))
{
return result.Value<TValue>();
}
return defaultValue;
}

public TValue GetConfig<TValue>(string culture, string name, TValue defaultValue = default)
Expand All @@ -69,7 +72,7 @@ public TValue GetEnumConfig<TValue>(string name)

public void SetConfig<TValue>(string name, TValue value)
{
RawSettings[name] = value != null ? JToken.FromObject(value) : null;
RawSettings[RawSettings.Property(name, StringComparison.OrdinalIgnoreCase).Name] = value != null ? JToken.FromObject(value) : null;
AppSettings = RawSettings.ToObject<T>();
}

Expand Down Expand Up @@ -117,7 +120,7 @@ protected virtual void LoadAppSettings()
}

var rawSettings = JObject.Parse(content);
RawSettings = !string.IsNullOrEmpty(SectionName)
RawSettings = !string.IsNullOrEmpty(SectionName)
? rawSettings[SectionName] as JObject
: rawSettings;
AppSettings = RawSettings.ToObject<T>();
Expand Down

0 comments on commit 1b70466

Please sign in to comment.