Tidied up docs and fixed several methods to be virtual

This commit is contained in:
tznind
2021-03-02 21:58:07 +00:00
parent 07899ec304
commit 62a997f4b3
3 changed files with 12 additions and 31 deletions

View File

@@ -35,35 +35,24 @@ Having to create a bunch of TreeNode objects can be a pain especially if you alr
```csharp
// Your data class
private class House : TreeNode {
// Your properties
public string Address {get;set;}
public List<Room> Rooms {get;set;}
// ITreeNode member:
public override IList<ITreeNode> Children => Rooms.Cast<ITreeNode>().ToList();
public IList<ITreeNode> Children => Rooms.Cast<ITreeNode>().ToList();
public override string ToString ()
{
return Address;
}
public override string Text { get => Address; set => Address = value; }
}
// Your other data class
private class Room : TreeNode{
public string Name {get;set;}
// Rooms have no sub objects
public IList<ITreeNode> Children => new List<ITreeNode>();
public override string ToString ()
{
return Name;
}
public override string Text{get=>Name;set{Name=value;}}
}
```