I'm a bit fuzzy on the best way to solve the problem of needing a list for each of my business objects that implements some overridden functions.
Here's the setup:
I have a baseObject that sets up database, and has its proper Dispose() method
All my other business objects inherit from it, and if necessary, override Dispose()
Some of these classes also contain arrays (lists) of other objects. So I create a class that holds a List of these. I'm aware I could just use the generic List, but that doesn't let me add extra features like Dispose() so it will loop through and clean up.
So if I had objects called User, Project and Schedule, I would create UserList, ProjectList, ScheduleList.
In the past, I have simply had these inherit from List< with the appropriate class named and then written the pile of common functions I wanted it to have, like Dispose().
this meant I would verify by hand, that each of these List classes had the same set of methods. Some of these classes had pretty simple versions of these methods that could have been inherited from a base list class.
I could write an interface, to force me to ensure that each of my List classes has the same functions, but interfaces don't let me write common base functions that SOME of the lists might override.
I had tried to write a baseObjectList that inherited from List, and then make my other Lists inherit from that, but there are issues with that (which is really why I came here). One of which was trying to use the Find() method with a predicate.
I've simplified the problem down to just a discussion of Dispose() method on the list that loops through and disposes its contents, but in reality, I have several other common functions that I want all my lists to have.
What's the best practice to solve this organizational matter?