I've created a factory assembly that can process any type of transaction (that supports ITransactionType
). I can add more transaction types in separate assemblies, all of which will work with the factory without it needing to be recompiled (which is one of the benefits of a factory).
There is an actual list of transaction types that can be handled, so I've defined a static class with const strings, which is kept in a separate assembly. This is referenced by other assemblies to ensure consistent transaction type names. This assembly is not referenced by the factory, as it doesn't need to know, and it would result in unnecessary compilations of that project.
All this works just fine. I'll never reference the master list assembly in the factory project, because it know it doesn't make sense.
However, I'm concerned that if the project is being maintained by someone who doesn't understand all this, they may mistakenly add the reference to the master list assembly. Is there some way to prevent this reference from being added? IOW, if someone (perhaps even myself in the future) adds the reference, is there some way for me to force a compile error pointing to an explanation of why the behavior is unacceptable?