Пример #1
0
		void PopulateProperties (QueryDescriptor descriptor, Type queryType, object instance)
		{
			foreach (var key in descriptor.Parameters.Keys) {
				var propertyName = key.ToPascalCase ();
				var property = queryType.GetProperty (propertyName);
				if (property != null) {
                    var value = descriptor.Parameters[key].ToString().ParseTo(property.PropertyType);
					property.SetValue (instance, value, null);
				}
			}
		}
Пример #2
0
        public QueryResult Execute(QueryDescriptor descriptor, PagingInfo paging)
        {
            var queryType = _typeDiscoverer.GetQueryTypeByName(descriptor.GeneratedFrom);
            var query = _container.Get(queryType) as IQuery;

			PopulateProperties (descriptor, queryType, query);

            var result = _queryCoordinator.Execute(query, paging);
            if( result.Success ) AddClientTypeInformation(result);
            return result;
        }
Пример #3
0
 static void PopulateProperties(QueryDescriptor descriptor, Type queryType, object instance)
 {
     foreach (var key in descriptor.Parameters.Keys)
     {
         var propertyName = key.ToPascalCase();
         var property = queryType.GetProperty(propertyName);
         if (property != null)
         {
             var stringValue = descriptor.Parameters[key].ToString();
             try
             {
                 var parsedValue = stringValue.ParseTo(property.PropertyType);
                 property.SetValue(instance, parsedValue, null);
             }
             catch (ConvertException e)
             {
                 throw new HttpStatus.HttpStatusException(400, e.Message + " Parameter name: " + key);
             }
         }
     }
 }