Skip to content

Node-by-Node Tree Building #4

@VaslD

Description

@VaslD

Since there is no documentation or example/demo code, I'm having a hard time figuring out a particular use case just by looking at class and method names... 😭 I've seen the tutorial, it isn't exactly helping. I think it's for a different use case.

So what I wanted to do is using this library as a plug-and-play visualizer. I've polymorphic hierarchical data (entities) saved in non-hierarchical formats that will be loaded at runtime; I've written models (classes) covering polymorphism that abstractly each should be considered Nodes; and I've got independent pretty print logic that if given the root of the tree will do whatever it does. Now I'm missing the link on how to construct a ReadOnlyEntityTree(Node) or MutableEntityTree(Node) using this library.

I think the easiest way to fill the gap is constructing such a tree node-by-node starting from newing a node as tree root then adding children to it (and its children) as soon as new data comes in. But all these constructors that take either IEnumerable or IEntityDefinition confuses me. It seems I can only construct a tree when I have all the data and have their relationship mapped out?

I'm also not sure how to store different types in the same tree. Adding a common base class to all data models (or use object) will solve this problem but it's kinda a dirty trick. I don't want to use it if there's better solution available. Is the generic type parameter <TItem> strictly enforced on all nodes that can link to this particular node?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions