Cache default values
This commit is contained in:
parent
ece93cb4d7
commit
10de241d53
@ -261,6 +261,10 @@ namespace AppScaffolding
|
||||
if (!Version.TryParse(latestVersionString, out var latestRelease))
|
||||
return null;
|
||||
|
||||
// we're up to date
|
||||
if (latestRelease <= BuildVersion)
|
||||
return null;
|
||||
|
||||
// we have an update
|
||||
|
||||
var zipUrl = zip?.BrowserDownloadUrl;
|
||||
@ -296,7 +300,6 @@ namespace AppScaffolding
|
||||
var repoName = "Libation";
|
||||
|
||||
var gitHubClient = new Octokit.GitHubClient(new Octokit.ProductHeaderValue(repoName));
|
||||
gitHubClient.Credentials = new("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");
|
||||
|
||||
//Download the release index
|
||||
var bts = await gitHubClient.Repository.Content.GetRawContent(ownerAccount, repoName, ".releaseindex.json");
|
||||
|
||||
@ -38,9 +38,10 @@ namespace FileManager
|
||||
if (!stringCache.ContainsKey(propertyName))
|
||||
{
|
||||
var jObject = readFile();
|
||||
if (!jObject.ContainsKey(propertyName))
|
||||
return defaultValue;
|
||||
stringCache[propertyName] = jObject[propertyName].Value<string>();
|
||||
if (jObject.ContainsKey(propertyName))
|
||||
stringCache[propertyName] = jObject[propertyName].Value<string>();
|
||||
else
|
||||
stringCache[propertyName] = defaultValue;
|
||||
}
|
||||
|
||||
return stringCache[propertyName];
|
||||
@ -50,12 +51,16 @@ namespace FileManager
|
||||
{
|
||||
var obj = GetObject(propertyName);
|
||||
|
||||
if (obj is null) return defaultValue;
|
||||
if (obj is null)
|
||||
{
|
||||
objectCache[propertyName] = defaultValue;
|
||||
return defaultValue;
|
||||
}
|
||||
if (obj.GetType().IsAssignableTo(typeof(T))) return (T)obj;
|
||||
if (obj is JObject jObject) return jObject.ToObject<T>();
|
||||
if (obj is JValue jValue)
|
||||
{
|
||||
if (jValue.Type == JTokenType.String && typeof(T).IsAssignableTo(typeof(Enum)))
|
||||
if (typeof(T).IsAssignableTo(typeof(Enum)))
|
||||
{
|
||||
return
|
||||
Enum.TryParse(typeof(T), jValue.Value<string>(), out var enumVal)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user