private void registerQueryHandlerMethod <TAttributed, TQuery, TResult>(Func <TAttributed> attributedObjectFactory, QueryHandlerAttributeMethod queryHandlerMethod)
            where TAttributed : class
            where TQuery : class, IQuery <TResult>
        {
            Type specificQueryType = typeof(TQuery);

            QueryHandlerDelegate <TResult> handleQueryDelegate;

            if (_queryHandlerDelegatesByQueryType.TryGetValue(specificQueryType, out handleQueryDelegate))
            {
                throw new InvalidOperationException($"Duplicate query handler registered for {specificQueryType.Name} query.");
            }

            QueryHandlerDelegate <TResult> newHandleQueryDelegate = queryHandlerMethod.CreateDelegate <TAttributed, TQuery, TResult>(attributedObjectFactory);

            _queryHandlerDelegatesByQueryType.Add(specificQueryType, newHandleQueryDelegate);
        }
        private static IEnumerable <QueryHandlerAttributeMethod> getQueryHandlerMethods(Type queryHandlerType)
        {
            IEnumerable <MethodInfo> methods = queryHandlerType.GetRuntimeMethods().Where(m => m.CustomAttributes.Any(a => a.AttributeType == typeof(QueryHandlerAttribute)));

            return(QueryHandlerAttributeMethod.FromMethodInfos(methods));
        }