private IEnumerable <Type> GetValidatorsForCommand(Type command) { Type ValidatorInterface = typeof(ICommandValidator <>); var validatorType = ValidatorInterface.MakeGenericType(command); return(this.Validators.Where(FN.ClassImplements(validatorType))); }
private IEnumerable <Type> GetListenersForNotification(Type notification) { Type ValidatorInterface = typeof(INotificationListener <>); var validatorType = ValidatorInterface.MakeGenericType(notification); return(this.Listeners.Where(FN.ClassImplements(validatorType))); }
public MediadorTypeManager() { var types = LoadFromAssemblies(); Commands = types.Where(FN.ClassImplements(typeof(ICommand))); Handlers = types.Where(FN.ClassImplements(typeof(IHandler))); Validators = types.Where(FN.ClassImplements(typeof(IValidator))); Notifications = types.Where(FN.ClassImplements(typeof(INotification))); Listeners = types.Where(FN.ClassImplements(typeof(INotificationListener))); }
private Type GetHandlerForCommand(Type command, Type commandReturnType = null) { var genericParams = (new[] { command, commandReturnType }).Where(FN.IsNotNull).ToArray(); Type handlerInterface = commandReturnType != null ? typeof(ICommandHandler <,>) : typeof(ICommandHandler <>); Type handlerType = handlerInterface.MakeGenericType(genericParams); return(this.Handlers.Single(FN.ClassImplements(handlerType))); }