Exemple #1
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)));
        }
Exemple #2
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)));
        }