private void AddByNamespace(Assembly asm, MagicalTreeViewItem item)
 {
     /*if (ns.Split('.').Length == 1)
      *  item.Items.Add(new TreeViewItem() { Header = ns, Foreground = System.Windows.Media.Brushes.White });
      * else
      *  foreach (string f in ns.Split('.'))
      *  {
      *      if (item.Items.GetItemByName(f) == null)
      *      {
      *          foreach (Type t in asm.GetTypes())
      *          {
      *              MagicalTreeViewItem i = null;
      *              if (t.Name == f)
      *                  if (t.IsClass || t.IsInterface || t.IsEnum || t.IsAbstract)
      *                  {
      *                      i = new TreeItemClass(t) { Header = f, Foreground = System.Windows.Media.Brushes.White };
      *                      //this.AddFieldsToClass(i);
      *                  }
      *              this.AddByNamespace(asm, i, ns.Substring(ns.Split('.')[0].Length + 1));
      *              item.Items.Add(i);
      *          }
      *      }
      *      else
      *          this.AddByNamespace(asm, item.Items.GetItemByName(f), ns.Substring(ns.Split('.')[0].Length + 1));
      *      break;
      *  }*/
     //Namespaces
     foreach (Type type in asm.GetTypes())
     {
         this.RecursiveAddResource(type, item);
     }
 }
        private void RecursiveAddResource(Type t, MagicalTreeViewItem item)
        {
            foreach (string pkg in t.Namespace.Split('.'))
            {
                if (item.Items.GetItemByName(pkg) == null)
                {
                    MagicalTreeViewItem newItem = new TreeItemPackage(pkg);
                    item.Items.Add(newItem);
                    item = newItem;
                }
                foreach (Type type in t.Assembly.GetTypes())
                {
                    if (item.Header.GetText() == type.Namespace.Split('.').Last())
                    {
                        if (item.Items.GetItemByName(type.Name) == null)
                        {
                            MagicalTreeViewItem itemClass = new TreeItemClass(type);
                            item.Items.Add(itemClass);

                            /*foreach (FieldInfo fi in type.GetFields())
                             *  itemClass.Items.Add(new TreeItemField(fi));
                             * foreach (MethodInfo mi in type.GetMethods())
                             *  try
                             *  {
                             *      itemClass.Items.Add(new TreeItemMethod(mi));
                             *  }
                             *  catch { }*/
                        }
                    }
                }
            }
        }