Hi,
I decompiled an assembly that uses a service locator pattern. The results were somewhat lacking and I wonder if this is a consequence of the SL pattern being loosely coupled?
So for example
I get :
I decompiled an assembly that uses a service locator pattern. The results were somewhat lacking and I wonder if this is a consequence of the SL pattern being loosely coupled?
So for example
I get :
[ServiceConsumer]
internal static class ServiceLocator
{
[ServiceDependency]
public static IService1 Service1;
[ServiceDependency]
public static IService2 Service2;
[ServiceDependency]
public static IService3 Service3;
[ServiceDependency]
public static IService4 Service4;
}
Which doesn't actually show the code that would instantiate Service1, 2, 3 or 4 so if you use this example, Service 1 will always be null if you try to use the class.
Being relatively new to the service locator pattern, would anyone care to hazard a guess as to how it should look?
For example in code where this class is used I can see things like :
ServiceLocator.Service1.SomeMethod();