Skip to content

Commit 4279c8c

Browse files
author
Kapil Borle
committed
Parse constants from settings hashtable ast
1 parent aee3f2b commit 4279c8c

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

Engine/Generic/Settings.cs

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ private List<string> GetData(object val, string key)
175175
else
176176
{
177177
var valueArr = val as object[];
178+
if (valueArr == null)
179+
{
180+
// check if it is an array of strings
181+
valueArr = val as string[];
182+
}
183+
178184
if (valueArr != null)
179185
{
180186
foreach (var item in valueArr)
@@ -347,15 +353,46 @@ private Hashtable GetHashtableFromHashTableAst(HashtableAst hashTableAst)
347353
if (pipeAst != null)
348354
{
349355
ExpressionAst pureExp = pipeAst.GetPureExpression();
350-
if (pureExp is StringConstantExpressionAst)
356+
var constExprAst = pureExp as ConstantExpressionAst;
357+
if (constExprAst != null)
351358
{
352-
rhsList.Add(((StringConstantExpressionAst)pureExp).Value);
359+
var strConstExprAst = constExprAst as StringConstantExpressionAst;
360+
if (strConstExprAst != null)
361+
{
362+
rhsList.Add(strConstExprAst.Value);
363+
}
364+
else
365+
{
366+
// it is either an integer or a float
367+
output[key] = constExprAst.Value;
368+
continue;
369+
}
353370
}
354371
else if (pureExp is HashtableAst)
355372
{
356373
output[key] = GetHashtableFromHashTableAst((HashtableAst)pureExp);
357374
continue;
358375
}
376+
else if (pureExp is VariableExpressionAst)
377+
{
378+
var varExprAst = (VariableExpressionAst)pureExp;
379+
switch (varExprAst.VariablePath.UserPath.ToLower())
380+
{
381+
case "true":
382+
output[key] = true;
383+
break;
384+
385+
case "false":
386+
output[key] = false;
387+
break;
388+
389+
default:
390+
ThrowInvalidDataException(varExprAst.Extent);
391+
break;
392+
}
393+
394+
continue;
395+
}
359396
else
360397
{
361398
rhsList = GetArrayFromAst(pureExp);
@@ -367,7 +404,7 @@ private Hashtable GetHashtableFromHashTableAst(HashtableAst hashTableAst)
367404
ThrowInvalidDataException(kvp.Item2);
368405
}
369406

370-
output[key] = rhsList;
407+
output[key] = rhsList.ToArray();
371408
}
372409

373410
return output;

0 commit comments

Comments
 (0)