private void DumpElement(object element, PropertyModel dump)
        {
            if (element == null || element is ValueType || element is string)
            {
                FormatValue(element, dump);
            }
            else
            {
                var objectType = element.GetType();
                if (!typeof(IEnumerable).IsAssignableFrom(objectType))
                {
                    dump.Type = objectType.FullName;
                    _hashListOfFoundElements.Add(element.GetHashCode());
                }

                var enumerableElement = element as IEnumerable;
                if (enumerableElement != null)
                {
                    foreach (object item in enumerableElement)
                    {
                        if (item is IEnumerable && !(item is string))
                        {
                            PropertyModel elem = new PropertyModel();
                            dump.Properties.Add(elem);
                            DumpElement(item, elem);
                        }
                        else
                        {
                            if (!AlreadyTouched(item))
                                DumpElement(item, dump);
                            else
                                dump.Value = string.Format("{{{0}}} <-- bidirectional reference found", item.GetType().FullName);
                        }
                    }
                }
                else
                {
                    MemberInfo[] members = element.GetType().GetMembers(BindingFlags.Public | BindingFlags.Instance);
                    foreach (var memberInfo in members)
                    {
                        var fieldInfo = memberInfo as FieldInfo;
                        var propertyInfo = memberInfo as PropertyInfo;

                        if (fieldInfo == null && propertyInfo == null)
                            continue;

                        if (propertyInfo != null && propertyInfo.GetIndexParameters().Length > 0)
                            continue;

                        if (propertyInfo != null && propertyInfo.DeclaringType.FullName == "DotLiquid.DropBase")
                            continue;

                        var type = fieldInfo != null ? fieldInfo.FieldType : propertyInfo.PropertyType;
                        object value = fieldInfo != null
                                           ? fieldInfo.GetValue(element)
                                           : propertyInfo.GetValue(element, null);

                        if (type.IsValueType || type == typeof(string) || value == null)
                        {
                            dump.Name = memberInfo.Name;
                            FormatValue(value, dump);
                        }
                        else
                        {
                            var isEnumerable = typeof(IEnumerable).IsAssignableFrom(type);
                            dump.Name = memberInfo.Name;
                            dump.Value = isEnumerable ? "..." : "{ }";

                            var alreadyTouched = !isEnumerable && AlreadyTouched(value);
                            if (!alreadyTouched)
                                DumpElement(value, dump);
                            else
                                dump.Value = string.Format("{{{0}}} <-- bidirectional reference found", value.GetType().FullName);
                        }
                    }
                }

                if (!typeof(IEnumerable).IsAssignableFrom(objectType))
                {

                }
            }
        }
        private void DumpElement(object element, PropertyModel dump)
        {
            if (element == null || element is ValueType || element is string)
            {
                FormatValue(element, dump);
            }
            else
            {
                var objectType = element.GetType();
                if (!typeof(IEnumerable).IsAssignableFrom(objectType))
                {
                    dump.Type = objectType.FullName;
                    _hashListOfFoundElements.Add(element.GetHashCode());
                }

                var enumerableElement = element as IEnumerable;
                if (enumerableElement != null)
                {
                    foreach (object item in enumerableElement)
                    {
                        if (item is IEnumerable && !(item is string))
                        {
                            PropertyModel elem = new PropertyModel();
                            dump.Properties.Add(elem);
                            DumpElement(item, elem);
                        }
                        else
                        {
                            if (!AlreadyTouched(item))
                            {
                                DumpElement(item, dump);
                            }
                            else
                            {
                                dump.Value = string.Format("{{{0}}} <-- bidirectional reference found", item.GetType().FullName);
                            }
                        }
                    }
                }
                else
                {
                    MemberInfo[] members = element.GetType().GetMembers(BindingFlags.Public | BindingFlags.Instance);
                    foreach (var memberInfo in members)
                    {
                        var fieldInfo    = memberInfo as FieldInfo;
                        var propertyInfo = memberInfo as PropertyInfo;

                        if (fieldInfo == null && propertyInfo == null)
                        {
                            continue;
                        }

                        if (propertyInfo != null && propertyInfo.GetIndexParameters().Length > 0)
                        {
                            continue;
                        }

                        if (propertyInfo != null && propertyInfo.DeclaringType.FullName == "DotLiquid.DropBase")
                        {
                            continue;
                        }

                        var    type  = fieldInfo != null ? fieldInfo.FieldType : propertyInfo.PropertyType;
                        object value = fieldInfo != null
                                           ? fieldInfo.GetValue(element)
                                           : propertyInfo.GetValue(element, null);

                        if (type.IsValueType || type == typeof(string) || value == null)
                        {
                            dump.Name = memberInfo.Name;
                            FormatValue(value, dump);
                        }
                        else
                        {
                            var isEnumerable = typeof(IEnumerable).IsAssignableFrom(type);
                            dump.Name  = memberInfo.Name;
                            dump.Value = isEnumerable ? "..." : "{ }";

                            var alreadyTouched = !isEnumerable && AlreadyTouched(value);
                            if (!alreadyTouched)
                            {
                                DumpElement(value, dump);
                            }
                            else
                            {
                                dump.Value = string.Format("{{{0}}} <-- bidirectional reference found", value.GetType().FullName);
                            }
                        }
                    }
                }

                if (!typeof(IEnumerable).IsAssignableFrom(objectType))
                {
                }
            }
        }
        private void FormatValue(object o, PropertyModel dump)
        {
            if (o == null)
                dump.Value = "null";

            if (o is DateTime)
                dump.Value = ((DateTime)o).ToShortDateString();

            if (o is string)
                dump.Value = string.Format("\"{0}\"", o);

            if (o is ValueType)
                dump.Value = o.ToString();

            if (o is IEnumerable)
                dump.Value = "...";

            dump.Value = "{ }";
        }