Service locator for optional dependencies

time to read 1 min | 61 words

I just found myself doing an optional dependency service location, which got on my nerve the second that I had to deal with it. I added this tiny tidbit to make it easier:

ILogger logger = IoC.TryResolve<ILogger>(new NullLogger());
logger.WarnFormat("Could not find a enities group for entity: {0}",
          typeof(TEntity).FullName);