private void BuildCommandInvokers(ITypeFinder typeFinder) { if (commandInvokers == null) { lock (_lock) { if (commandInvokers == null) { commandInvokers = new Dictionary <Type, CommandHandlerInvoker>(); foreach (var commandHandlerType in typeFinder.GetInterfaceImplementations <IHandleCommands>()) { foreach (var commandType in GetCommandTypesForCommandHandler(commandHandlerType)) { if (commandInvokers.ContainsKey(commandType)) { throw new DuplicateCommandHandlersException(commandType); } commandInvokers.Add(commandType, new CommandHandlerInvoker(commandType, commandHandlerType)); } } } } } }