private static string GetNestedPropertyValue(object item, Match m, IFormatProvider provider)
{
string[] properties = m.Groups[PROPERTY].Value.Split('.');
object current = item;
int index = 0;
try
{
while (index < properties.Length)
{
string prop = properties[index];
current = GetPropertyValue(current, prop);
index++;
}
}
catch (ArgumentOutOfRangeException ex)
{
var chain = GetFailedPropertyChain(properties, index);
throw new MissingFieldException(chain.Item1, chain.Item2);
}
if (m.Groups[FORMAT].Value != String.Empty)
{
string result = FormatProperty(current, m, provider);
return result;
}
else
{
return current.ToString();
}
}