Пример #1
0
        public async Task<object> Send(QueryRequest query)
        {
            var typeInformation = new QueryRequestTypeInformation(query);

            var queryObject = JsonConvert.DeserializeObject(query.QueryData, typeInformation.QueryType);

            var handlerType = typeof(IQueryHandler<,>).MakeGenericType(typeInformation.QueryType, typeInformation.ResultType);

            var handler = serviceLocator.Resolve(handlerType);

            var sendMethodInfo = handlerType.GetMethod("Send");

            return await (dynamic)sendMethodInfo.Invoke(handler, new[] { queryObject });
        }
 public QueryRequestTypeInformation(QueryRequest query)
 {
     this.QueryType = Type.GetType(query.QueryTypeName);
     this.ResultType = this.QueryType.GetInterfaces().Single(i => i.Name.Contains("IQuery")).GetGenericArguments()[0];
 }