problem implementing IHierarchyData

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

hi

asp.net 2.0

I have a class named Category in which I want to implement the
iHierarchyData interface:

**********************************
This is the original Category class:
public class Category
{
private int _id;
public int Id { get { return _id; } }

private string _name;
public string Name { get { return _name; } }

private int _parentid;
public int parent { get { return _parent; } }

public Category(int id, string name, int parent)
{
this.Id = id;
this.Name = name;
this.Parent = parent;
}

public static List<Category> GetCategories() {}

**************************************
the original class has a GetCategories method, my problem is that I don't
know where that method should fit in after the iHierarchyData interface is
implemented together with this class:
public class CategoryCollection : List<Category>, IHierarchicalEnumerable

I've studied this example without fully undestanding what I need to do:
http://www.codeproject.com/KB/custo...ise=3&sort=Position&view=Quick&select=2520602
that's why I post my question here in the hope of someone could guide me on
this problem

Jeff
 
Did you work through the Folder/File example at msdn?


The best thing is to work through the example, but HAND CREATE all of their
code line by line.

Its not trivai to work through.
 
I've seen that example, but I don't fully understand it.

Take this code for example, taken from the example I posted a link to
previous post:
public IHierarchyData GetParent() {
foreach (Category category in Common.GetCategoryData()) {
if (category.CategoryId == this.ParentId)
return category;
}
return null;
}

When I implement IHierarchyData interface into my Category class, then I see
it as bad to all the time call BLL method to get the collection of
categories, in the code above GetCategoryData is called for each iteration
in the loop... I want to implement it so that I can choose between
retrieving the full tree (all categories), or just a branch.. So I need
somehow to send in that parameter....

any suggestions
 
Back
Top