Exemple #1
0
 public MemberNode(ObjectNode parent, object item, int maxDepth, DataContextDriver dcDriver) : base(parent, item, maxDepth, dcDriver)
 {
     this.Members = new List <MemberData>();
     this.Summary = "";
 }
        public ClrMemberNode(ObjectNode parent, object item, int maxDepth, DataContextDriver dcDriver) : base(parent, item, maxDepth, dcDriver)
        {
            base.Name = item.GetType().FormatTypeName();
            Type type = item.GetType();

            if (!((base.CyclicReference != null) || base.IsAtNestingLimit()))
            {
                base.InitiallyHidden = ((((item is MemberInfo) || (item is RuntimeMethodHandle)) || ((item is CultureInfo) || (item is ProcessModule))) || (((item is Uri) || (item is Version)) || ((type.Namespace == "Microsoft.SqlServer.Types") || (type.FullName == "System.Data.EntityKey")))) || ((type.Namespace != null) && (type.Namespace.StartsWith("System.Reflection", StringComparison.Ordinal) || type.Namespace.StartsWith("System.IO", StringComparison.Ordinal)));
            }
            if (item is Type)
            {
                base.Name = "typeof(" + ((Type)item).Name + ")";
            }
            if (!base.Name.StartsWith("{", StringComparison.Ordinal))
            {
                if ((item is MethodBase) && (((MethodBase)item).DeclaringType != null))
                {
                    MethodBase base2    = (MethodBase)item;
                    string[]   strArray = new string[] { base2.DeclaringType.FormatTypeName(), ".", base2.Name, " (", string.Join(", ", (from p in base2.GetParameters() select p.ParameterType.FormatTypeName() + " " + p.Name).ToArray <string>()), ")" };
                    base.Summary = string.Concat(strArray);
                }
                else
                {
                    try
                    {
                        base.Summary = item.ToString();
                    }
                    catch
                    {
                    }
                }
            }
            if (base.Summary.Length > 150)
            {
                base.Summary = base.Summary.Substring(0, 150) + "...";
            }
            FieldInfo[]    fields     = type.GetFields(BindingFlags.Public | BindingFlags.Instance);
            PropertyInfo[] properties = type.GetProperties(BindingFlags.Public | BindingFlags.Instance);
            if (((fields.Length != 0) || (properties.Length != 0)) && (base.CyclicReference == null))
            {
                if (!((!base.IsAtNestingLimit() || Util.IsMetaGraphNode(item)) || (base.Parent is ListNode)))
                {
                    base.GraphTruncated = true;
                }
                else
                {
                    object        obj2;
                    bool          isAnonType = base.IsAnonType;
                    Func <object> getter     = null;
                    foreach (FieldInfo fi in fields)
                    {
                        if (isAnonType || (((fi.GetCustomAttributes(typeof(AssociationAttribute), true).Length == 0) && !fi.FieldType.FullName.StartsWith("System.Data.Objects.DataClasses.EntityReference")) && !IsUnloadedEntityAssociation(item, fi)))
                        {
                            if (getter == null)
                            {
                                getter = () => fi.GetValue(item);
                            }
                            obj2 = this.GetValue(fi, getter, isAnonType);
                            base.Members.Add(new MemberData(fi.Name, fi.FieldType, ObjectNode.Create(this, obj2, item is Exception, maxDepth, dcDriver)));
                        }
                    }
                    foreach (PropertyInfo pi in properties)
                    {
                        if ((pi.GetIndexParameters().Length == 0) && (isAnonType || ((((pi.GetCustomAttributes(typeof(AssociationAttribute), true).Length == 0) && !pi.PropertyType.FullName.StartsWith("System.Data.Objects.DataClasses.EntityReference")) && ((pi.PropertyType.FullName != "System.Data.EntityKey") && (pi.PropertyType.FullName != "System.Data.EntityState"))) && !IsUnloadedEntityAssociation(item, pi))))
                        {
                            bool exceptionThrown = false;
                            obj2 = this.GetValue(pi, () => this.GetPropValue(pi, item, out exceptionThrown), isAnonType);
                            bool flag2 = exceptionThrown && ((item is Exception) || ((parent != null) && (parent.ObjectValue is Exception)));
                            base.Members.Add(new MemberData(pi.Name, pi.PropertyType, ObjectNode.Create(this, obj2, item is Exception, flag2 ? 1 : maxDepth, dcDriver)));
                        }
                    }
                    if ((base.Members.Count > 50) && (base.NestingDepth > 1))
                    {
                        base.InitiallyHidden = true;
                    }
                }
            }
        }
Exemple #3
0
        public ExceptionNode(ObjectNode parent, Exception ex, int maxDepth) : base(parent, ex, maxDepth, null)
        {
            List <MemberData> list = new List <MemberData>();

            foreach (MemberData data in base.Members)
            {
                string objectValue;
                if (data.Name == "StackTrace")
                {
                    objectValue = data.Value.ObjectValue as string;
                    if (objectValue != null)
                    {
                        StringBuilder builder = new StringBuilder();
                        foreach (string str2 in objectValue.Split(new char[] { '\n' }))
                        {
                            string str3 = str2.Trim();
                            if (!str3.StartsWith("at UserQuery.", StringComparison.Ordinal) && !str3.StartsWith("at LINQPad.", StringComparison.Ordinal))
                            {
                                if (builder.Length > 0)
                                {
                                    builder.AppendLine();
                                }
                                builder.Append(_binaryKiller.Replace(str2, ""));
                            }
                        }
                        data.Value = new SimpleNode(this, builder.ToString());
                    }
                }
                else if (data.Name == "Source")
                {
                    objectValue = data.Value.ObjectValue as string;
                    if (objectValue != null)
                    {
                        if (objectValue.StartsWith("query_", StringComparison.Ordinal))
                        {
                            list.Add(data);
                        }
                        else
                        {
                            data.Value = new SimpleNode(this, _binaryKiller.Replace(objectValue, ""));
                        }
                    }
                }
                else if (data.Name == "TargetSite")
                {
                    MethodInfo info = data.Value.ObjectValue as MethodInfo;
                    if ((info != null) && !(((info.DeclaringType == null) || !(info.DeclaringType.Name == "UserQuery")) ? !_binaryKiller.IsMatch(info.ToString()) : false))
                    {
                        list.Add(data);
                    }
                }
            }
            foreach (MemberData data in list)
            {
                base.Members.Remove(data);
            }
            base.Summary = _binaryKiller.Replace(ex.Message, "");
            if (base.Summary.Length > 150)
            {
                base.Summary = base.Summary.Substring(0, 150) + "...";
            }
            base.InitiallyHidden = ex.InnerException == null;
        }
 public MultiDimArrayNode(ObjectNode parent, Array array) : this(parent, array, null)
 {
 }
 public DataReaderNode(ObjectNode parent, IDataReader r, int maxDepth, DataContextDriver dcDriver) : base(parent, GetResults(parent, r, maxDepth, dcDriver), maxDepth, dcDriver, "Result Sets")
 {
 }
 private static IEnumerable GetResults(ObjectNode parent, IDataReader reader, int maxDepth, DataContextDriver dcDriver)
 {
     return(new < GetResults > d__8(-2)
     {
Exemple #7
0
        internal static ObjectNode Create(ObjectNode parent, object item, int maxDepth, DataContextDriver dcDriver)
        {
            if (item is ObjectNode)
            {
                ObjectNode node = (ObjectNode)item;
                node.Parent = parent;
                return(node);
            }
            if (item == null)
            {
                return(new SimpleNode(parent, null));
            }
            if (((!(item is string) && !(item is int)) && !(item is decimal)) && !(item is DateTime))
            {
                Type type = item.GetType();
                if (type.IsGenericType && (type.GetGenericTypeDefinition() == typeof(Nullable <>)))
                {
                    type = type.GetGenericArguments()[0];
                }
                if (Type.GetTypeCode(type) == TypeCode.Object)
                {
                    HandleObjectProxies(ref item, parent, dcDriver);
                }
                if (item == ObjectGraphInfo.GetDisplayNothingToken())
                {
                    return(new EmptyNode());
                }
                if (item == null)
                {
                    return(new SimpleNode(parent, null));
                }
            }
            Type type2 = item.GetType();

            if ((((item is byte[]) || (item is Binary)) && (parent != null)) && !(parent.ObjectValue is HeadingPresenter))
            {
                string str;
                byte[] buffer = item as byte[];
                if (buffer == null)
                {
                    buffer = ((Binary)item).ToArray();
                }
                if (buffer.Length <= 20)
                {
                    StringBuilder builder = new StringBuilder();
                    foreach (byte num2 in buffer)
                    {
                        if (builder.Length > 0)
                        {
                            builder.Append(" ");
                        }
                        builder.AppendFormat("{0:X2}", num2);
                    }
                    str = builder.ToString();
                }
                else
                {
                    str = "byte[]";
                }
                return(new SimpleNode(parent, str, "(binary data)", SimpleNodeKind.Metadata));
            }
            if (((((((item is string) || (item is bool)) || ((item is char) || (item is TimeSpan))) || (((item is IFormattable) || (item is XObject)) || ((item is XName) || (item is XNamespace)))) || ((((item is SqlBoolean) || (item is SqlByte)) || ((item is SqlDateTime) || (item is SqlDecimal))) || (((item is SqlDouble) || (item is SqlGuid)) || ((item is SqlInt16) || (item is SqlInt32))))) || (((item is SqlInt64) || (item is SqlMoney)) || (item is SqlSingle))) || (item is SqlString))
            {
                return(new SimpleNode(parent, item.ToString()));
            }
            if (item is XmlNode)
            {
                return(new SimpleNode(parent, XmlHelper.ToFormattedString((XmlNode)item)));
            }
            Type type3 = type2.IsGenericType ? type2.GetGenericTypeDefinition() : null;

            if (!(((!(type3 == typeof(EntitySet <>)) || (parent == null)) || (parent.IsAnonType || (parent is ListNode))) || (parent.ObjectValue is HeadingPresenter)))
            {
                return(new SimpleNode(parent, "EntitySet", type2.FormatTypeName(), SimpleNodeKind.Metadata));
            }
            for (ObjectNode node3 = parent; node3 == null; node3 = node3.Parent)
            {
Label_0305:
                if (0 == 0)
                {
                    if ((type3 == typeof(Table <>)) && (node3 != null))
                    {
                        return(new SimpleNode(parent, "Table", type2.FormatTypeName(), SimpleNodeKind.Metadata));
                    }
                    if (item is DBNull)
                    {
                        return(new SimpleNode(parent, "null", "DbNull", SimpleNodeKind.Metadata));
                    }
                    string        text    = null;
                    ObjectNode    payload = null;
                    ReturnDataSet set     = item as ReturnDataSet;
                    if (set != null)
                    {
                        text = set.ReturnValue.ToString();
                        if (set.OutputParameters != null)
                        {
                            foreach (KeyValuePair <string, object> pair in set.OutputParameters)
                            {
                                if (pair.Value != null)
                                {
                                    string str3 = text;
                                    text = str3 + ", " + pair.Key + "=" + pair.Value.ToString();
                                }
                            }
                        }
                        payload = new SimpleNode(null, text);
                    }
                    if ((item is DataSet) && (((DataSet)item).Tables.Count == 1))
                    {
                        item = ((DataSet)item).Tables[0];
                    }
                    if (item is DataSet)
                    {
                        return(new ListPayloadNode(parent, ((DataSet)item).Tables, maxDepth, dcDriver, "Result Sets", payload, "ReturnValue"));
                    }
                    if (item is DataTable)
                    {
                        return(new ListPayloadNode(parent, ((DataTable)item).Rows, maxDepth, dcDriver, "Result Set", payload, "ReturnValue"));
                    }
                    if (item is DataRow)
                    {
                        return(new DataRowNode(parent, (DataRow)item, maxDepth, dcDriver));
                    }
                    if (item is IDataReader)
                    {
                        DataReaderNode node5 = new DataReaderNode(parent, (IDataReader)item, maxDepth, dcDriver);
                        if (node5.Items.Count == 1)
                        {
                            return(node5.Items[0]);
                        }
                        return(node5);
                    }
                    if (item is IDataRecord)
                    {
                        return(new DataRecordMemberNode(parent, null, (IDataRecord)item, maxDepth, dcDriver));
                    }
                    if (type2.GetInterfaces().Any <Type>(t => t.FullName == typeof(ICustomMemberProvider).FullName))
                    {
                        try
                        {
                            return(new CustomMemberProviderNode(parent, item, maxDepth, dcDriver, false));
                        }
                        catch (Exception exception)
                        {
                            Log.Write(exception, "CustomMemberProvider");
                        }
                    }
                    if ((dcDriver != null) && (dcDriver.GetCustomDisplayMemberProvider(item) != null))
                    {
                        return(new CustomMemberProviderNode(parent, item, maxDepth, dcDriver, true));
                    }
                    if (item is Type)
                    {
                        for (ObjectNode node6 = parent; node6 != null; node6 = node6.Parent)
                        {
                            node6.HasTypeReferences = true;
                        }
                    }
                    if (!(ExpandTypes || !(item is Type)))
                    {
                        return(new SimpleNode(parent, "typeof (" + ((Type)item).FormatTypeName() + ")", ((Type)item).FormatTypeName(true), SimpleNodeKind.Metadata)
                        {
                            HasTypeReferences = true
                        });
                    }
                    if (item is Image)
                    {
                        Image        image  = (Image)item;
                        MemoryStream stream = new MemoryStream();
                        image.Save(stream, ImageFormat.Png);
                        item = Util.Image(stream.ToArray());
                    }
                    if (((!type2.IsArray && (item is IList)) && (((IList)item).Count == 1)) && (((IList)item)[0] == item))
                    {
                        return(new ClrMemberNode(parent, item, maxDepth, dcDriver));
                    }
                    if (type2.IsArray && (type2.GetArrayRank() == 2))
                    {
                        Type elementType = type2.GetElementType();
                        if (elementType.IsGenericType && (elementType.GetGenericTypeDefinition() == typeof(Nullable <>)))
                        {
                            elementType = elementType.GetGenericArguments()[0];
                        }
                        if (((typeof(IFormattable).IsAssignableFrom(elementType) || (elementType == typeof(bool))) || ((elementType == typeof(char)) || (elementType == typeof(TimeSpan)))) || (elementType == typeof(string)))
                        {
                            return(new MultiDimArrayNode(parent, (Array)item));
                        }
                    }
                    if (item is IEnumerable)
                    {
                        return(new ListNode(parent, (IEnumerable)item, maxDepth, dcDriver));
                    }
                    if (item is Exception)
                    {
                        return(new ExceptionNode(parent, (Exception)item, maxDepth));
                    }
                    if (item is DynamicObject)
                    {
                        return(new DynamicObjectMemberNode(parent, (DynamicObject)item, maxDepth, dcDriver));
                    }
                    return(new ClrMemberNode(parent, item, maxDepth, dcDriver));
                }
            }
            goto Label_0305;
        }
Exemple #8
0
 public DataRowNode(ObjectNode parent, DataRow item, int maxDepth, DataContextDriver dcDriver) : base(parent, item, maxDepth, dcDriver)
 {
     base.Name = "DataRow";
     if (base.IsAtNestingLimit())
     {
         base.GraphTruncated = true;
     }
     else
     {
         foreach (DataColumn column in item.Table.Columns)
         {
             object obj2 = item[column];
             base.Members.Add(new MemberData(column.ColumnName, column.DataType, ObjectNode.Create(this, obj2, maxDepth, dcDriver)));
         }
         if ((base.Members.Count > 50) && (base.NestingDepth > 1))
         {
             base.InitiallyHidden = true;
         }
     }
 }
Exemple #9
0
 public SimpleNode(ObjectNode parent, string text, string tip) : this(parent, text, tip, SimpleNodeKind.Data)
 {
 }
Exemple #10
0
 private static IEnumerable <object> GetParentHierarchy(ObjectNode parent)
 {
     return(new < GetParentHierarchy > d__2(-2)
     {
Exemple #11
0
 public SimpleNode(ObjectNode parent, string text) : this(parent, text, null)
 {
 }
Exemple #12
0
 public MemberData(string name, System.Type type, ObjectNode value)
 {
     this.Name  = name;
     this.Type  = type;
     this.Value = value;
 }
Exemple #13
0
        public ListNode(ObjectNode parent, IEnumerable list, int maxDepth, DataContextDriver dcDriver, string name) : base(parent, list, maxDepth, dcDriver)
        {
            this.Items  = new List <ObjectNode>();
            this.Totals = new Dictionary <string, decimal>();
            this.Counts = new Dictionary <string, decimal>();
            if (name == null)
            {
                this.Name = list.GetType().FormatTypeName();
            }
            else
            {
                this.Name = name;
            }
            this.ElementType = (from itype in list.GetType().GetInterfaces()
                                where itype.IsGenericType && (itype.GetGenericTypeDefinition() == typeof(IEnumerable <>))
                                select itype.GetGenericArguments().First <Type>()).OrderByDescending <Type, Type>(itype => itype, new SubTypeComparer()).FirstOrDefault <Type>();
            if (base.CyclicReference == null)
            {
                if (base.IsAtNestingLimit() || ((parent != null) && ((parent.ObjectValue is Type) || (parent.ObjectValue is Assembly))))
                {
                    base.GraphTruncated = true;
                }
                else
                {
                    IEnumerator enumerator = list.GetEnumerator();
                    try
                    {
                        int?       nullable;
                        ObjectNode node;
                        MemberNode node2;
                        if (!((enumerator != null) && enumerator.MoveNext()))
                        {
                            return;
                        }
                        Type type = (from t in list.GetType().GetInterfaces()
                                     where t.IsGenericType && (t.GetGenericTypeDefinition() == typeof(IGrouping <,>))
                                     select t).FirstOrDefault <Type>();
                        if (type != null)
                        {
                            PropertyInfo property = type.GetProperty("Key");
                            if (property != null)
                            {
                                this.GroupKey     = ObjectNode.Create(this, property.GetValue(list, null), maxDepth, dcDriver);
                                this.GroupKeyText = "Key";
                            }
                        }
                        int num = 0x3e8;
                        if (((UserOptions.Instance != null) && UserOptions.Instance.MaxQueryRows.HasValue) && (((nullable = UserOptions.Instance.MaxQueryRows).GetValueOrDefault() > 0x3e8) && nullable.HasValue))
                        {
                            num = UserOptions.Instance.MaxQueryRows.Value;
                        }
                        int num2 = 0;
                        goto Label_033B;
Label_0215:
                        this.Items.Add(node);
                        if (++num2 == num)
                        {
                            goto Label_0364;
                        }
                        if (enumerator.MoveNext())
                        {
                            goto Label_033B;
                        }
                        return;

Label_0244:
                        foreach (MemberData data in node2.Members)
                        {
                            if (((data.Type.IsNumeric() && !ObjectNode.IsKey(data.Name, data.Type)) && (data.Value != null)) && (data.Value.ObjectValue != null))
                            {
                                decimal num3;
                                decimal num4;
                                decimal num5;
                                this.Totals.TryGetValue(data.Name, out num3);
                                this.Counts.TryGetValue(data.Name, out num4);
                                if (decimal.TryParse(data.Value.ObjectValue.ToString(), out num5))
                                {
                                    this.Totals[data.Name] = num3 + num5;
                                    this.Counts[data.Name] = decimal.op_Increment(num4);
                                }
                            }
                        }
                        goto Label_0215;
Label_033B:
                        node  = ObjectNode.Create(this, enumerator.Current, maxDepth, dcDriver);
                        node2 = node as MemberNode;
                        if (node2 == null)
                        {
                            goto Label_0215;
                        }
                        goto Label_0244;
Label_0364:
                        this.ItemsTruncated = true;
                    }
                    finally
                    {
                        IDisposable disposable = enumerator as IDisposable;
                        if (disposable != null)
                        {
                            try
                            {
                                disposable.Dispose();
                            }
                            catch
                            {
                            }
                        }
                    }
                }
            }
        }
Exemple #14
0
 public ListNode(ObjectNode parent, IEnumerable list, int maxDepth, DataContextDriver dcDriver) : this(parent, list, maxDepth, dcDriver, null)
 {
 }
 public ListPayloadNode(ObjectNode parent, IEnumerable list, int maxDepth, DataContextDriver dcDriver, string name, ObjectNode payload, string payLoadName) : base(parent, list, maxDepth, dcDriver, name)
 {
     base.GroupKey     = payload;
     base.GroupKeyText = payLoadName;
 }