I am trying to create a class that contains a list of "items" within it. Which I have successfully done, however then I would like to create a list of items within the list of items. I have also been able to do this however I had to use a different name for the class within the item.
I would like to use the same class name as this will be used to generate some json where the class name is important. In addition I would like to be able to do this in a way where it could be recursive like a folder structure. All the properties would be the same for each. I hope I am explaining this well enough. I am essentially trying to create a folder / file structure where there can be x number of files in each folder that can also have x number of folders and so forth.
For example:
DocLib
-Item
--Item.Items
---Item.Items.Items
--Item.Items
-Item 2 etc...
Here is the existing code:
public class DocLib
{
public string Title { get; set; }
public string spriteCssClass { get { return "rootfolder"; } }
public List<item> items { get; set; }
public DocLib()
{
items = new List<item>();
}
public class item
{
public string Title { get; set; }
public string spriteCssClass { get; set; }
public List<document> documents { get; set; }
public item()
{
documents = new List<document>();
}
public class document
{
public string Title { get; set; }
public string spriteCssClass { get; set; }
}
}
}
I am sure there is probably a better way of implementing this.