Imagine I have two sites that share basic code. Most of their code matches exactly, but a couple functions don't match. For example, what if these two sites differed in the method they used for determining if the current user was using an acceptably new Web browser. So isGoodBrowser() returns true or false, but the sites have a different version of this function. How can I make this one function interchangeable while keeping the rest of the code the same? I'd like to contain such a function in a file of its own. Thanks.
Make three assemblies:
Reference the common assembly from both web site projects.
You can even specify an interface for isGoodBrowser()
in the shared assembly and implement it differently in site-specific assemblies. Then inject the appropriate implementation either manually, or via an IoC container, such as Unity.