public DynamicObjectMemberNode(ObjectNode parent, DynamicObject item, int maxDepth, DataContextDriver dcDriver) : base(parent, item, maxDepth, dcDriver)
 {
     base.Name = "DynamicObject";
     base.Summary = item.ToString();
     if (base.Summary.Length > 150)
     {
         base.Summary = base.Summary.Substring(0, 150) + "...";
     }
     IEnumerable<string> dynamicMemberNames = item.GetDynamicMemberNames();
     if (dynamicMemberNames.Any<string>() && (base.CyclicReference == null))
     {
         if (!(!base.IsAtNestingLimit() || (base.Parent is ListNode)))
         {
             base.GraphTruncated = true;
         }
         else
         {
             foreach (string str in dynamicMemberNames)
             {
                 object propValue = this.GetPropValue(item, str);
                 base.Members.Add(new MemberData(str, null, ObjectNode.Create(this, propValue, false, maxDepth, dcDriver)));
             }
         }
     }
 }
 public DataRecordMemberNode(ObjectNode parent, Type[] types, IDataRecord r, int maxDepth, DataContextDriver dcDriver) : base(parent, r, maxDepth, dcDriver)
 {
     if (base.IsAtNestingLimit())
     {
         base.GraphTruncated = true;
     }
     else
     {
         for (int i = 0; i < r.FieldCount; i++)
         {
             object item = r.GetValue(i);
             Type type = null;
             if (types != null)
             {
                 type = types[i];
             }
             else if (item != null)
             {
                 type = item.GetType();
             }
             if (!(item is IDataRecord))
             {
             }
             base.Members.Add(new MemberData(r.GetName(i), type, ObjectNode.Create(this, item, maxDepth, base.DCDriver)));
         }
         if ((base.Members.Count > 50) && (base.NestingDepth > 1))
         {
             base.InitiallyHidden = true;
         }
     }
 }
 public DCDriverInfo(DataContextDriver driver)
 {
     this.Loader = driver.Loader;
     this.Name = driver.Name;
     this.Author = driver.Author;
     this.Version = driver.Version.ToString();
     this.IsAuto = driver is DynamicDataContextDriver;
 }
 public DCDriverInfo(DataContextDriver driver)
 {
     this.Loader  = driver.Loader;
     this.Name    = driver.Name;
     this.Author  = driver.Author;
     this.Version = driver.Version.ToString();
     this.IsAuto  = driver is DynamicDataContextDriver;
 }
 public CustomMemberProviderNode(ObjectNode parent, object item, int maxDepth, DataContextDriver dcDriver, bool useDataContextDriver) : base(parent, item, maxDepth, dcDriver)
 {
     base.Name = item.GetType().FormatTypeName();
     if (base.IsAtNestingLimit())
     {
         base.GraphTruncated = true;
     }
     else
     {
         IEnumerable<string> names;
         IEnumerable<Type> types;
         IEnumerable<object> values;
         if (useDataContextDriver)
         {
             ICustomMemberProvider customDisplayMemberProvider = dcDriver.GetCustomDisplayMemberProvider(item);
             names = customDisplayMemberProvider.GetNames();
             types = customDisplayMemberProvider.GetTypes();
             values = customDisplayMemberProvider.GetValues();
         }
         else
         {
             Type type2 = item.GetType().GetInterfaces().First<Type>(t => t.FullName == typeof(ICustomMemberProvider).FullName);
             MethodInfo method = type2.GetMethod("GetNames");
             MethodInfo info2 = type2.GetMethod("GetTypes");
             MethodInfo info3 = type2.GetMethod("GetValues");
             names = (IEnumerable<string>) method.Invoke(item, null);
             types = (IEnumerable<Type>) info2.Invoke(item, null);
             values = (IEnumerable<object>) info3.Invoke(item, null);
         }
         IEnumerator<Type> enumerator = types.GetEnumerator();
         enumerator.MoveNext();
         IEnumerator<object> enumerator2 = values.GetEnumerator();
         enumerator2.MoveNext();
         foreach (string str in names)
         {
             object current;
             try
             {
                 current = enumerator2.Current;
             }
             catch (Exception innerException)
             {
                 if ((innerException is TargetInvocationException) && (innerException.InnerException != null))
                 {
                     innerException = innerException.InnerException;
                 }
                 current = innerException;
             }
             base.Members.Add(new MemberData(str, enumerator.Current, ObjectNode.Create(this, current, maxDepth, dcDriver)));
             enumerator.MoveNext();
             enumerator2.MoveNext();
         }
         if ((base.Members.Count > 50) && (base.NestingDepth > 1))
         {
             base.InitiallyHidden = true;
         }
     }
 }
 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 #7
0
        private static Assembly GetEfAssembly(IConnectionInfo cxInfo)
        {
            if (_efAssembly != null)
            {
                return(_efAssembly);
            }
            _efAssembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault <Assembly>(a => a.FullName.StartsWith("entityframework,", StringComparison.InvariantCultureIgnoreCase));
            if (_efAssembly != null)
            {
                return(_efAssembly);
            }
            string efPath = GetEfPath(cxInfo, false);

            if (efPath == null)
            {
                return(null);
            }
            if (efPath.Contains <char>(','))
            {
                return(_efAssembly = Assembly.Load(efPath));
            }
            return(_efAssembly = DataContextDriver.LoadAssemblySafely(efPath));
        }
Exemple #8
0
 private void StartQuery(QueryRunner runner)
 {
     object obj2;
     lock ((obj2 = this._statusLocker))
     {
         if (this._cancelRequest)
         {
             return;
         }
     }
     _currentServer = this;
     this.ServerThread = Thread.CurrentThread;
     if ((this._repository != null) && this._repository.DriverLoader.IsValid)
     {
         this._dataContextDriver = this._repository.DriverLoader.Driver;
     }
     if ((this._dataContextDriver is EntityFrameworkDriver) || (this._dataContextDriver is EntityFrameworkDbContextDriver))
     {
         this.InstallDbProviders(this._repository);
     }
     lock ((obj2 = this._statusLocker))
     {
         if (this._cancelRequest)
         {
             return;
         }
     }
     if (_domainExceptionHandler != null)
     {
         System.AppDomain.CurrentDomain.UnhandledException -= _domainExceptionHandler;
     }
     System.AppDomain.CurrentDomain.UnhandledException += (_domainExceptionHandler = new UnhandledExceptionEventHandler(this.CurrentDomain_UnhandledException));
     try
     {
         this.RunQuery(runner);
     }
     catch (ThreadAbortException)
     {
     }
     catch (Exception exception)
     {
         this.MessageLoopEnded = true;
         this.PostStatus(this.GetStatusArgs(exception, true, true));
         this.PerformCompletionCleanup(true, false);
         this.PerformFinalCleanup();
     }
 }
 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;
             }
         }
     }
 }
 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;
 }
 protected ParameterDescriptor[] GetContextConstructorParams(DataContextDriver driver, Repository r)
 {
     ParameterDescriptor[] descriptorArray2;
     try
     {
         descriptorArray2 = driver.GetContextConstructorParameters(r) ?? new ParameterDescriptor[0];
     }
     catch (Exception exception)
     {
         if (driver.IsBuiltIn)
         {
             throw;
         }
         Log.Write(exception, "GetContextConstructorParameters");
         throw new DisplayToUserException(exception.Message);
     }
     return descriptorArray2;
 }
Exemple #12
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 #13
0
 public ListNode(ObjectNode parent, IEnumerable list, int maxDepth, DataContextDriver dcDriver) : this(parent, list, maxDepth, dcDriver, null)
 {
 }
 public MemberNode(ObjectNode parent, object item, int maxDepth, DataContextDriver dcDriver) : base(parent, item, maxDepth, dcDriver)
 {
     this.Members = new List<MemberData>();
     this.Summary = "";
 }
Exemple #15
0
 protected internal object InstantiateBaseContext(IConnectionInfo cxInfo)
 {
     return(Activator.CreateInstance(DataContextDriver.LoadAssemblySafely(cxInfo.CustomTypeInfo.CustomAssemblyPath).GetType(cxInfo.CustomTypeInfo.CustomTypeName, true), this.GetContextConstructorArguments(cxInfo)));
 }