c# - How far to go overriding methods, properties, ... of a base class e.g. .net TreeNode class -


I am working on some application, which uses a TreeView control to represent business objects The link between business objects and tree nodes is maintained through the tag property of the treeoid I am not very happy with this, because I think the link is not "tight", for example a TreeNo without a business object De object may be, I want to update the tree image on the basis of business object state. That's why I made my own special treeoid class from TreeNode:

ActionTreeNode class: TreeNode {Private Action Mction; Public action (public action) ... public workflow (action): base () {if (action == empty) throw new logic ("action", "paramour action should not be blank."); MAction = verb; } Public Zero UpdateState () {switch (mAction.ActionState) {Case ActionState.Passed: SelectedImageIndex = 3; Image index = 3; break; Case ActionState. Fail: selected image index = 2; IME Index = 2; break; ...} return; }}

With this minimal approach, I call every property or method of the base class when I give the tree node object in the "actiontire node. The solution will be to override / overwrite every method or property and will return an object of type ActionTreeNode. What do you think, is it more appropriate to take a minimal perspective or will you try to complete all the methods, properties to avoid molding? Thank you.

I like the least approach if you have clutter with loads of loaded statements in your code If you are worried about, just make a method to do this in one place:

  GetParent (ActionTreeNode node) {return node.Parent as ActionTreeNode; } // In some method: ActionTreeNode parent = GetParent (someNode); If (parents! = Void) {/ Parent an ActionTreeNode}  

Do not forget the empty check at the return value, however parents should not have actiontransm ...


Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -