コード例 #1
0
        public CommandDispatcher(ICommandHandlerFactory handlerFactory,
                                 ICommandHandlerContextFactory contextFactory)
        {
            Contract.Requires(handlerFactory != null);
            Contract.Requires(contextFactory != null);

            _handlerFactory = handlerFactory;
            _contextFactory = contextFactory;
        }
        public static IEnumerable <ICommandHandlerContext> Create(this ICommandHandlerContextFactory commandHandlerContextFactory, IEnumerable <MethodInfo> methodInfos)
        {
            if (commandHandlerContextFactory is null)
            {
                throw new System.ArgumentNullException(nameof(commandHandlerContextFactory));
            }
            if (methodInfos is null)
            {
                throw new System.ArgumentNullException(nameof(methodInfos));
            }

            foreach (var methodInfo in methodInfos)
            {
                yield return(commandHandlerContextFactory.Create(methodInfo));
            }
        }