in src/PSRule.Rules.Azure/Data/Template/TemplateVisitor.cs [1805:1846]
private static void ResolveProperty(ITemplateContext context, JObject obj, string propertyName, TypePrimitive type = TypePrimitive.None)
{
if (!obj.ContainsKey(propertyName) || propertyName == null)
return;
// Replace property
if (propertyName.IsExpressionString())
{
var property = obj.Property(propertyName);
propertyName = ExpandString(context, propertyName);
property.Replace(new JProperty(propertyName, property.Value));
}
var value = obj[propertyName];
if (value is JObject jObject)
{
foreach (var copyIndex in GetPropertyIterator(context, jObject))
{
if (copyIndex.IsCopy())
{
context.CopyIndex.Push(copyIndex);
var jArray = new JArray();
while (copyIndex.Next())
{
var instance = copyIndex.CloneInput<JToken>();
jArray.Add(ResolveToken(context, instance));
}
jObject[copyIndex.Name] = jArray;
context.CopyIndex.Pop();
}
obj[propertyName] = ResolveToken(context, jObject);
}
}
else if (value is JArray jArray)
{
obj[propertyName] = ExpandArray(context, jArray);
}
else if (value is JToken jToken && jToken.Type == JTokenType.String)
{
obj[propertyName] = ExpandPropertyToken(context, type, jToken);
}
}