in SharpGen/Config/ConfigFile.cs [206:233]
private object ExpandVariables(object objectToExpand, bool expandDynamicVariable, Logger logger)
{
if (objectToExpand == null)
return null;
if (objectToExpand is string str)
return ExpandString(str, expandDynamicVariable, logger);
if (objectToExpand.GetType().GetTypeInfo().IsPrimitive)
return objectToExpand;
if (objectToExpand is IList list)
{
for (int i = 0; i < list.Count; i++)
list[i] = ExpandVariables(list[i], expandDynamicVariable, logger);
return list;
}
foreach (var propertyInfo in objectToExpand.GetType().GetRuntimeProperties())
{
if (!propertyInfo.GetCustomAttributes<XmlIgnoreAttribute>(false).Any())
{
// Check that this field is "ShouldSerializable"
var method = objectToExpand.GetType().GetRuntimeMethod("ShouldSerialize" + propertyInfo.Name, Type.EmptyTypes);
if (method != null && !((bool)method.Invoke(objectToExpand, null)))
continue;
propertyInfo.SetValue(objectToExpand, ExpandVariables(propertyInfo.GetValue(objectToExpand, null), expandDynamicVariable, logger), null);
}
}
return objectToExpand;
}