internal static DimensionSpecification ExtractQuerySpec(DimensionSpecification queryParameters,
                                                                out QuerySpecification querySpec)
        {
            var filterDimensions = new DimensionSpecification();

            querySpec = new QuerySpecification();

            foreach (var param in queryParameters)
            {
                if (string.Equals(param.Key, ReservedDimensions.DimensionDimension, StringComparison.OrdinalIgnoreCase))
                {
                    querySpec.CrossQueryDimension = param.Value;

                    // Ensure that split dimension is not also sent a filter dimension
                    if (queryParameters.ContainsKey(param.Value))
                    {
                        return(null);
                    }
                }
                else if (string.Equals(param.Key, ReservedDimensions.AggregateSamplesDimension, StringComparison.OrdinalIgnoreCase))
                {
                    querySpec.Combine = Convert.ToBoolean(param.Value);
                }
                else if (string.Equals(param.Key, ReservedDimensions.PercentileDimension, StringComparison.OrdinalIgnoreCase))
                {
                    if (string.Equals(param.Value, ReservedDimensions.PercentileDimensionValueForAverage,
                                      StringComparison.OrdinalIgnoreCase))
                    {
                        querySpec.QueryType = QueryType.Average;
                    }
                    else if (string.Equals(param.Value, ReservedDimensions.PercentileDimensionValueForMaximum,
                                           StringComparison.OrdinalIgnoreCase))
                    {
                        querySpec.QueryType = QueryType.Maximum;
                    }
                    else if (string.Equals(param.Value, ReservedDimensions.PercentileDimensionValueForMinimum,
                                           StringComparison.OrdinalIgnoreCase))
                    {
                        querySpec.QueryType = QueryType.Minimum;
                    }
                    else
                    {
                        querySpec.QueryType  = QueryType.Percentile;
                        querySpec.Percentile = double.Parse(param.Value);
                    }
                }
                else
                {
                    filterDimensions.Add(param.Key, param.Value);
                }
            }

            return(filterDimensions);
        }
        public DimensionSpecification KeyToDimensionSpecification(Key key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            var dimensionSpec = new DimensionSpecification();

            for (var i = 0; i < this.dimensions.Length; ++i)
            {
                dimensionSpec.Add(this.dimensions[i].Name, this.dimensions[i].IndexToString(key[i]));
            }

            return(dimensionSpec);
        }