public IEnumerable<object> GetValues(string path)
{
object value = GetValue(path);
if (value == null)
{
if (_renderContextBehaviour.RaiseExceptionOnDataContextMiss)
{
throw new NustacheDataContextMissException(string.Format("Path : {0} is undefined, RaiseExceptionOnDataContextMiss : true.", path));
}
yield break;
}
else if (value is bool)
{
if ((bool)value)
{
yield return value;
}
}
else if (value is string)
{
if (!string.IsNullOrEmpty((string)value))
{
yield return value;
}
}
else if (value.GetType().ToString().Equals("Newtonsoft.Json.Linq.JValue"))
{
yield return value;
}
else if (GenericIDictionaryUtil.IsInstanceOfGenericIDictionary(value))
{
if ((value as IEnumerable).GetEnumerator().MoveNext())
{
yield return value;
}
}
else if (value is IDictionary) // Dictionaries also implement IEnumerable
// so this has to be checked before it.
{
if (((IDictionary)value).Count > 0)
{
yield return value;
}
}
else if (value is IEnumerable)
{
foreach (var item in ((IEnumerable)value))
{
yield return item;
}
}
else if (value is DataTable)
{
foreach (var item in ((DataTable)value).Rows)
{
yield return item;
}
}
else
{
yield return value;
}
}