Example #1
0
        public override MemoryBrowser CreateMemoryBrowser(string id, object root)
        {
            var mBrowser = new MemoryBrowser(root);

            browsers.Add(id, mBrowser);
            return(mBrowser);
        }
        public static void Traverse(object obj, Action <string, object, MemoryBrowser.ElementType, UIDBInclude> callback)
        {
            bool isManaged = IsManaged(obj);

            // process fields
            foreach (var field in obj.GetType().GetFields())
            {
                var val      = field.GetValue(obj);
                var elemType = MemoryBrowser.GetElementType(val);
                if (!isManaged)
                {
                    // not managed ==> all elements are part of the table
                    callback(field.Name, val, elemType, null);
                }
                else
                {
                    var attrib = GetAttribute(field);
                    if (attrib != null)
                    {
                        callback(field.Name, val, elemType, attrib);
                    }
                }
            }
            // process properties

            /*    foreach (var prop in obj.GetType().GetProperties()) {
             *      var val = prop.GetValue(obj);
             *      var elemType = MemoryBrowser.GetElementType(obj);
             *      if (!isManaged) {
             *          // not managed ==> all elements are part of the table
             *          callback(prop.Name, val, elemType, null);
             *      } else {
             *          var attrib = GetAttribute(prop);
             *          if (attrib != null) {
             *              callback(prop.Name, val, elemType, attrib);
             *          }
             *      }
             *  }*/
        }
Example #3
0
 public override bool IsSimpleType(object obj)
 {
     return(MemoryBrowser.IsSimple(obj.GetType()));
 }
Example #4
0
 public static void Traverse(object obj, Action <string, object, MemoryBrowser.ElementType, UIDBInclude> callback)
 {
     // process fields
     if (obj is IList)
     {
         // traverse list
         foreach (object val in ((IList)obj))
         {
             bool isManaged = IsManaged(val);
             MemoryBrowser.ElementType elemType = MemoryBrowser.GetElementType(val);
             callback(val.GetType().Name, val, elemType, null);
             //if (!isManaged) {
             //    // not managed ==> all elements are part of the table
             //    callback(obj.GetType().Name, val, elemType, null);
             //} else {
             //    var attrib = GetAttribute(val);
             //    if (attrib != null) {
             //        callback(field.Name, val, elemType, attrib);
             //    }
             //}
         }
     }
     else
     {
         bool isManaged = IsManaged(obj);
         // traverse object
         foreach (FieldInfo field in obj.GetType().GetFields())
         {
             object val = field.GetValue(obj);
             MemoryBrowser.ElementType elemType = MemoryBrowser.GetElementType(val);
             if (!isManaged)
             {
                 // not managed ==> all elements are part of the table
                 callback(field.Name, val, elemType, null);
             }
             else
             {
                 UIDBInclude attrib = GetAttribute(field);
                 if (attrib != null)
                 {
                     callback(field.Name, val, elemType, attrib);
                 }
             }
         }
         // process properties
         foreach (PropertyInfo prop in obj.GetType().GetProperties())
         {
             object val = prop.GetValue(obj);
             MemoryBrowser.ElementType elemType = MemoryBrowser.GetElementType(obj);
             if (!isManaged)
             {
                 // not managed ==> all elements are part of the table
                 callback(prop.Name, val, elemType, null);
             }
             else
             {
                 UIDBInclude attrib = GetAttribute(prop);
                 if (attrib != null)
                 {
                     callback(prop.Name, val, elemType, attrib);
                 }
             }
         }
     }
 }