John Lokanis Posted March 30, 2016 Report Share Posted March 30, 2016 I have a project with a large number of classes that inherit from a common parent. The parent has a method that I want to override in all the child classes. The override method will be the same for all children. Instead of creating individual overrides in each child, I want to create a new class that inherits from the parent and only includes the common override method. I then want to change all the children that currently inherit from the parent to now inherit from this new class. That allows them all to get the new override method. What I don't want to do is manually change the inheritance on each of these child classes. Instead I want to 'insert' the new class between the parent and all the children. Does anyone know of an easy way to do this or maybe have a tool they scripted to solve this? thanks, -John Quote Link to comment
Popular Post Darren Posted March 30, 2016 Popular Post Report Share Posted March 30, 2016 Assuming you have an easy way to get all the child classes into memory, something like this should do the trick: 3 Quote Link to comment
John Lokanis Posted March 30, 2016 Author Report Share Posted March 30, 2016 Awesome! I will try that. (feel kinda dumb I didn't think of this myself...) Quote Link to comment
Chris_Collier Posted March 30, 2016 Report Share Posted March 30, 2016 I would think it should look something like this. I've not tried running this... You will need to ensure all children you want as children of the inserted class are in memory before running this, though I believe anything in an open project is in memory. I hope this helps! 2 Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.