public DescribeGroupByParameterFor For(string category, LocalizedString name, LocalizedString description)
        {
            DescribeGroupByParameterFor describeFor;

            if (!_describes.TryGetValue(category, out describeFor))
            {
                describeFor          = new DescribeGroupByParameterFor(category, name, description);
                _describes[category] = describeFor;
            }
            return(describeFor);
        }
        private void DescribeNumericFieldMemberContext(
            ContentPartFieldDefinition localField,
            ContentPartDefinition localPart,
            DescribeGroupByParameterFor descriptor,
            string storageName,
            LocalizedString description,
            LocalizedString displayName,
            IFieldTypeEditor fieldTypeEditor)
        {
            if (localField.FieldDefinition.Name != "NumericField")
            {
                throw new ArgumentException("localField is not an instance of DateTimeField");
            }

            //field.FieldDefinition.Name
            List <AggregateMethods> methods = new List <AggregateMethods>();

            methods.Add(AggregateMethods.Count);
            methods.Add(AggregateMethods.Sum);
            methods.Add(AggregateMethods.Average);
            methods.Add(AggregateMethods.Minimum);
            methods.Add(AggregateMethods.Maximum);

            Tuple <string, string, int>[] intervals = new Tuple <string, string, int>[] {
                new Tuple <string, string, int>("Without", "Without any interval", 1),
                new Tuple <string, string, int>("By10", "in intervals of 10", 10),
                new Tuple <string, string, int>("By100", "in intervals of 100", 100),
                new Tuple <string, string, int>("By1000", "in intervals of 1000", 1000),
                new Tuple <string, string, int>("By10000", "in intervals of 10000", 10000),
            };

            foreach (var interval in intervals)
            {
                string typeValue = string.Format(CultureInfo.InvariantCulture, "{0}.{1}.{2}.{3}", localPart.Name, localField.Name, storageName, interval.Item1);

                LocalizedString name = interval.Item3 != 1 ?
                                       T("{0} ({1})", localField.DisplayName, interval.Item3.ToString(CultureInfo.InvariantCulture)) :
                                       T(localField.DisplayName);

                descriptor.Element(
                    type: typeValue,
                    name: name,
                    description: T("group the result by {0} values {1}", localField.DisplayName, interval.Item2),
                    run: (query, method) => { return(this.fieldAggregateQueryService.RunNumericAggregation(query, method, localField.Name, localPart.Name, interval.Item3)); },
                    aggregateMethods: methods,
                    display: context => fieldTypeEditor.DisplayFilter(localPart.Name.CamelFriendly() + "." + localField.DisplayName, storageName, context.State));
            }
        }