Jump to content
John Lokanis

Insert class in hierarchy

Recommended Posts

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

Share this post


Link to post
Share on other sites

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!

post-45390-0-39540400-1459374409.png

  • Like 2

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.