GlobalCache is declared in a website and I am creating another object in the business layer which needs to call a method on GlobalCache. Since both reference a “Contract” assembly of interfaces, my first thought was to define IGlobalCache in “Contract” and use Ninject to instantiate IGlobalCache in the business layer to call the method.
The problem is that the method is static and you can’t declare static methods in an interface. How else can you call a static method from an assembly that has no knowledge of the type the method belongs to?
You could create an interface with that method (non-static obviously) and create an implementation of this interface in an assembly that knows of the class with the static method. This implementation simply delegates to the class with the static method.
In Assembly A (Contracts):
In Assembly B (Business):
In Assembly C: