private void PopulateSchemaRecursive(System.Windows.Forms.TreeNodeCollection nodes, IDataSourceViewSchema viewSchema, int depth, IDictionary duplicates)
 {
     if (viewSchema != null)
     {
         SchemaTreeNode node = new SchemaTreeNode(viewSchema);
         nodes.Add(node);
         SchemaTreeNode node2 = (SchemaTreeNode)duplicates[viewSchema.Name];
         if (node2 != null)
         {
             node2.Duplicate = true;
             node.Duplicate  = true;
         }
         foreach (TreeNodeBinding binding in this._bindingsListView.Items)
         {
             if (string.Compare(binding.DataMember, viewSchema.Name, StringComparison.OrdinalIgnoreCase) == 0)
             {
                 IDataSourceViewSchemaAccessor accessor = binding;
                 if ((depth == binding.Depth) || (accessor.DataSourceViewSchema == null))
                 {
                     accessor.DataSourceViewSchema = viewSchema;
                 }
             }
         }
         IDataSourceViewSchema[] children = viewSchema.GetChildren();
         if (children != null)
         {
             for (int i = 0; i < children.Length; i++)
             {
                 this.PopulateSchemaRecursive(node.Nodes, children[i], depth + 1, duplicates);
             }
         }
     }
 }
        internal static IDataSourceViewSchema FindViewSchemaRecursive(object schema, int depth, string viewName, int level, IDataSourceViewSchema bestBet)
        {
            if (!(schema is IDataSourceSchema) && !(schema is IDataSourceViewSchema))
            {
                return(null);
            }
            IDataSourceViewSchema schema2 = schema as IDataSourceViewSchema;

            IDataSourceViewSchema[] schemaArray = (schema2 != null) ? schema2.GetChildren() : ((IDataSourceSchema)schema).GetViews();
            if (schemaArray != null)
            {
                if (depth == level)
                {
                    foreach (IDataSourceViewSchema schema3 in schemaArray)
                    {
                        if (string.Equals(schema3.Name, viewName, StringComparison.OrdinalIgnoreCase))
                        {
                            return(schema3);
                        }
                        if (string.IsNullOrEmpty(schema3.Name) && (bestBet == null))
                        {
                            bestBet = schema3;
                        }
                        bestBet = FindViewSchemaRecursive(schema3, depth + 1, viewName, level, bestBet);
                    }
                    return(bestBet);
                }
                foreach (IDataSourceViewSchema schema4 in schemaArray)
                {
                    if (((level == -1) && string.Equals(schema4.Name, viewName, StringComparison.OrdinalIgnoreCase)) && (bestBet == null))
                    {
                        return(schema4);
                    }
                    bestBet = FindViewSchemaRecursive(schema4, depth + 1, viewName, level, bestBet);
                }
            }
            return(bestBet);
        }
 private void PopulateSchemaRecursive(System.Windows.Forms.TreeNodeCollection nodes, IDataSourceViewSchema viewSchema, int depth, IDictionary duplicates)
 {
     if (viewSchema != null)
     {
         SchemaTreeNode node = new SchemaTreeNode(viewSchema);
         nodes.Add(node);
         SchemaTreeNode node2 = (SchemaTreeNode) duplicates[viewSchema.Name];
         if (node2 != null)
         {
             node2.Duplicate = true;
             node.Duplicate = true;
         }
         foreach (MenuItemBinding binding in this._bindingsListView.Items)
         {
             if (string.Compare(binding.DataMember, viewSchema.Name, StringComparison.OrdinalIgnoreCase) == 0)
             {
                 IDataSourceViewSchemaAccessor accessor = binding;
                 if ((depth == binding.Depth) || (accessor.DataSourceViewSchema == null))
                 {
                     accessor.DataSourceViewSchema = viewSchema;
                 }
             }
         }
         IDataSourceViewSchema[] children = viewSchema.GetChildren();
         if (children != null)
         {
             for (int i = 0; i < children.Length; i++)
             {
                 this.PopulateSchemaRecursive(node.Nodes, children[i], depth + 1, duplicates);
             }
         }
     }
 }