In my app, I'm working with Simfile and Notechart objects. A Simfile is essentially a Notechart container, with the following constraints:
1) Every Notechart must be contained in exactly one parent Simfile, at all times.
2) Given a Simfile object, I need to be able to obtain all of its contained Notecharts (should be easy).
3) Given a Notechart, I need to be able to obtain its parent Simfile (harder).
My current implementation is using a Dictionary as the Simfile base class, since each Notechart has a unique key, at least within a Simfile. The problem I'm facing is how to enforce that a Notechart always has a parent Simfile? Right now, I'm able to create a Notechart independently of a Simfile, and add it to the Simfile dictionary without making the needed reference from Notechart -> Simfile.
Ideally, the best resolution would be an Add() method in Simfile that only can be called from within Notechart's constructors, but I don't think that's possible.
I want to say that this is a common problem, but it's the first time in practice I've come across it, and I'm not sure what it's called.