Fixed the EXISTS condition when using dictionaries.

This commit is contained in:
ruri
2019-04-13 18:27:31 +02:00
parent a6a4d1fe89
commit 3167186e4f
2 changed files with 6 additions and 5 deletions
+2 -2
View File
@@ -221,12 +221,12 @@ namespace RuriLib
if (args.Contains("(") && args.Contains(")"))
{
var dicKey = ParseArguments(args, '(', ')')[0];
output = output.Replace(full, v.GetDictValue(dicKey));
try { output = output.Replace(full, v.GetDictValue(dicKey)); } catch { }
}
else if (args.Contains("{") && args.Contains("}"))
{
var dicVal = ParseArguments(args, '{', '}')[0];
output = output.Replace(full, v.GetDictKey(dicVal));
try { output = output.Replace(full, v.GetDictKey(dicVal)); } catch { }
}
break;
}
+4 -3
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
namespace RuriLib.Models
@@ -153,7 +154,7 @@ namespace RuriLib.Models
{
var dict = Value as Dictionary<string, string>;
if (dict.ContainsKey(key)) return dict.First(d => d.Key == key).Value;
else return dict.FirstOrDefault(d => d.Key.Contains(key)).Value;
else throw new Exception("Key not in dictionary");
}
/// <summary>
@@ -165,7 +166,7 @@ namespace RuriLib.Models
{
var dict = Value as Dictionary<string, string>;
if (dict.ContainsValue(value)) return dict.First(d => d.Value == value).Key;
else return dict.FirstOrDefault(d => d.Value.Contains(value)).Key;
else throw new Exception("Value not in dictionary");
}
}
}