public virtual void VisitMembers(IEnumerable <string> names, Func <string, Type> typeSelector, Func <string, object> valueSelector, int depth)
        {
            foreach (string name in names)
            {
                Type   type  = null;
                object value = null;
                try
                {
                    // Get the type and value
                    type  = typeSelector(name);
                    value = valueSelector(name);

                    // If the type is null try using the runtime type
                    if (value != null && type == null)
                    {
                        type = value.GetType();
                    }
                }
                catch (Exception ex)
                {
                    // Set the value as an exception we know about
                    value = new ObjectVisitorException(null, ex);
                }
                finally
                {
                    VisitMember(name, type, value, depth);
                }
            }
        }
Esempio n. 2
0
        private static HtmlElement CreateExceptionSpan(ObjectVisitorException exception)
        {
            HtmlElement span = new HtmlElement("span");

            span.AppendChild(HelpersResources.ObjectInfo_PropertyThrewException);
            span.AppendChild(HtmlElement.CreateSpan(exception.InnerException.Message, "exception"));
            return(span);
        }
Esempio n. 3
0
 public override void VisitObjectVisitorException(ObjectVisitorException exception)
 {
     Values.Add(exception.InnerException.Message);
 }
Esempio n. 4
0
 public override void VisitObjectVisitorException(ObjectVisitorException exception)
 {
     Values.Add(exception.InnerException.Message);
 }
Esempio n. 5
0
 private static HtmlElement CreateExceptionSpan(ObjectVisitorException exception) {
     HtmlElement span = new HtmlElement("span");
     span.AppendChild(HelpersResources.ObjectInfo_PropertyThrewException);
     span.AppendChild(HtmlElement.CreateSpan(exception.InnerException.Message, "exception"));
     return span;
 }
Esempio n. 6
0
 public override void VisitObjectVisitorException(ObjectVisitorException exception) {
     Current.AppendChild(CreateExceptionSpan(exception));
 }
        public virtual void VisitMembers(IEnumerable<string> names, Func<string, Type> typeSelector, Func<string, object> valueSelector, int depth)
        {
            foreach (string name in names)
            {
                Type type = null;
                object value = null;
                try
                {
                    // Get the type and value
                    type = typeSelector(name);
                    value = valueSelector(name);

                    // If the type is null try using the runtime type
                    if (value != null && type == null)
                    {
                        type = value.GetType();
                    }
                }
                catch (Exception ex)
                {
                    // Set the value as an exception we know about
                    value = new ObjectVisitorException(null, ex);
                }
                finally
                {
                    VisitMember(name, type, value, depth);
                }
            }
        }
 public virtual void VisitObjectVisitorException(ObjectVisitorException exception)
 {
 }
        public virtual void Visit(object value, int depth)
        {
            if (value == null || DBNull.Value.Equals(value))
            {
                VisitNull();
                return;
            }

            // Check to see if the we've already visited this object
            string id;

            if (_visited.TryGetValue(value, out id))
            {
                VisitVisitedObject(id, value);
                return;
            }

            string stringValue = value as string;

            if (stringValue != null)
            {
                VisitStringValue(stringValue);
                return;
            }

            if (TryConvertToString(value, out stringValue))
            {
                VisitConvertedValue(value, stringValue);
                return;
            }

            // This exceptin occurs when we try to access the property and it fails
            // for some reason. The actual exception is wrapped in the ObjectVisitorException
            ObjectVisitorException exception = value as ObjectVisitorException;

            if (exception != null)
            {
                VisitObjectVisitorException(exception);
                return;
            }

            // Mark the object as visited
            id = CreateObjectId(value);
            _visited.Add(value, id);

            NameValueCollection nameValueCollection = value as NameValueCollection;

            if (nameValueCollection != null)
            {
                VisitNameValueCollection(nameValueCollection, depth);
                return;
            }

            IDictionary dictionary = value as IDictionary;

            if (dictionary != null)
            {
                VisitDictionary(dictionary, depth);
                return;
            }

            IEnumerable enumerable = value as IEnumerable;

            if (enumerable != null)
            {
                VisitEnumerable(enumerable, depth);
                return;
            }

            VisitComplexObject(value, depth + 1);
        }
 public virtual void VisitObjectVisitorException(ObjectVisitorException exception)
 {
 }
Esempio n. 11
0
 public override void VisitObjectVisitorException(ObjectVisitorException exception)
 {
     Current.AppendChild(CreateExceptionSpan(exception));
 }