Does the container need to know about the type of content? If not, generics can avoid this - i.e. Container<T> where you use Container<Entity> . Besides; pushing the necessary details into an interface (or base class) in an assembly that can reference is a general approach.
Personally, I would just try to avoid the need to know the child about the parent.
Also; note that if you are following the route of abstraction (interface, etc.); this can make a big difference if you use (for example) XML serialization.
(edit comments) OK; firstly: what problem is the circular link (inside the assembly); if not, leave him alone. If there is a problem, you will need an additional type; presumably some interfaces for representing specific types - i.e. where Entity : IEntity , and EntityContainer knows only about IEntity (or vv with IEntityContainer or both)
Marc gravell
source share