示例#1
0
        private IEnumerable <Type> GetValidatorsForCommand(Type command)
        {
            Type ValidatorInterface = typeof(ICommandValidator <>);
            var  validatorType      = ValidatorInterface.MakeGenericType(command);

            return(this.Validators.Where(FN.ClassImplements(validatorType)));
        }
示例#2
0
        private IEnumerable <Type> GetListenersForNotification(Type notification)
        {
            Type ValidatorInterface = typeof(INotificationListener <>);
            var  validatorType      = ValidatorInterface.MakeGenericType(notification);

            return(this.Listeners.Where(FN.ClassImplements(validatorType)));
        }
示例#3
0
        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)));
        }
示例#4
0
        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)));
        }