This project is read-only.

Scribd.Net.Category.GetCategories method

Retrieves category information from Scribd.

Signature(s)

  • public static GetCategories(bool includeSubcategories)
  • public static GetCategories(int parentCategoryId)

Parameter(s)

  • bool includeSubcategories: Include subcategory information when fetching the list of categories.
  • int parentCategoryId: The Id of the category. This category's subcategories will be returned.

Return Value

  • System.Collection.Generic.ICollection<Category> : A list of categories

Usage Example

            // fetch all the top level categories
            System.Collections.Generic.ICollection<Scribd.Net.Category> topLevelNoKids = Scribd.Net.Category.GetCategories(false);

            foreach (Scribd.Net.Category cat in topLevelNoKids)
            {
                // fetch any subcategories of 'cat'
                System.Collections.Generic.ICollection<Scribd.Net.Category> subCats = Scribd.Net.Category.GetCategories(cat.ID);
                if (subCats != null)
                {
                    doSomeWork(subCats);
                }
            }

            // in the real world the above is more efficiently accomplished using:
            System.Collections.Generic.ICollection<Scribd.Net.Category> topLevelWithKids = Scribd.Net.Category.GetCategories(false);
            foreach (Scribd.Net.Category cat in topLevelWithKids)
            {
                if (cat.SubCategories != null)
                {
                    doSomeWork(cat.SubCategories);
                }
            }


See Also

Last edited Aug 11, 2010 at 4:19 AM by peterjp, version 7

Comments

No comments yet.