List<Tuple<UniversalValue, UniversalValue>>  FromListToGroup(List<UniversalValue> distributionParameters)
 {
     List<Tuple<UniversalValue, UniversalValue>> distributionParametersIntervals = new List<Tuple<UniversalValue, UniversalValue>>();
     UniversalValue first = distributionParameters.First();
     UniversalValue min, max;
     switch (first.Type)
     {
         case UniversalValue.UniversalClassType.Numeric:
             min = new UniversalValue(Double.MinValue);
             max = new UniversalValue(Double.MaxValue);
             break;
         case UniversalValue.UniversalClassType.TimeSpan:
             min = new UniversalValue(TimeSpan.MinValue);
             max = new UniversalValue(TimeSpan.MaxValue);
             break;
         default:
             throw new Exception("Cannot convert list of string distribution pararameters to intervals");
     }
     distributionParametersIntervals.Add(new Tuple<UniversalValue, UniversalValue>(min,distributionParameters[0]));
     for (int i = 0; i < distributionParameters.Count-1; i++)
     {
         distributionParametersIntervals.Add(new Tuple<UniversalValue, UniversalValue>(distributionParameters[i], distributionParameters[i+1]));
     }
     distributionParametersIntervals.Add(new Tuple<UniversalValue, UniversalValue>(distributionParameters[distributionParameters.Count - 1], max));
     return distributionParametersIntervals;
 }
 public DistributionGroupAggregationOperation(Type valuesDataType, string parameters)
 {
     _valuesDataType = UniversalValue.UniversalClassTypeByType(valuesDataType);
     var boundaries = parameters.Split(new[] {'|'}, StringSplitOptions.RemoveEmptyEntries).Select(t => UniversalValue.ParseFromString(valuesDataType, t)).ToList();
     if (boundaries.Count == 0)
         throw new Exception("boundaries list is empty");
     List<DistributionGroup> distributionGroups = new List<DistributionGroup>();
     UniversalValue minBound, maxBound;
     switch (_valuesDataType)
     {
         case UniversalValue.UniversalClassType.Numeric:
             minBound = new UniversalValue(Double.MinValue);
             maxBound = new UniversalValue(Double.MaxValue);
             break;
         case UniversalValue.UniversalClassType.TimeSpan:
             minBound = new UniversalValue(TimeSpan.MinValue);
             maxBound = new UniversalValue(TimeSpan.MaxValue);
             break;
         default:
             throw new Exception("Type " + _valuesDataType + " not supported for interval distribution groupping");
     }
     distributionGroups.Add(new DistributionGroup(minBound, boundaries.First()));
     for (int i = 0; i < boundaries.Count - 1; i++)
     {
         distributionGroups.Add(new DistributionGroup(boundaries[i], boundaries[i + 1]));
     }
     distributionGroups.Add(new DistributionGroup(boundaries.Last(), maxBound));
     _distributionGroups = distributionGroups;
 }
 public CounterSeriesData(string seriesName, UniversalValue.UniversalClassType valueType, string counterCategory, string counterName, string counterSource, string counterInstance, string counterExtData)
 {
     SeriesName = seriesName;
     ValueType = valueType;
     CounterCategory = counterCategory;
     CounterName = counterName;
     CounterSource = counterSource;
     CounterInstance = counterInstance;
     CounterExtData = counterExtData;
 }
 public SeriesPoint(DateTime dateTime, UniversalValue value)
 {
     DateTime = dateTime;
     Value = value == null? (double?)null: value.Type == UniversalValue.UniversalClassType.TimeSpan ? value.TimespanValue.TotalMilliseconds : value.DoubleValue;
 }
 public GroupAggregationResult(IGrouping<CounterGroup, UniversalValue> s, UniversalValue result)
 {
     CounterGroup = s.Key;
     Result = new List<Tuple<string, UniversalValue>>() { new Tuple<string, UniversalValue>("value", result) };
 }
 public DistributionGroup(UniversalValue lowerBound, UniversalValue upperBound)
 {
     LowerBound = lowerBound;
     UpperBound = upperBound;
 }
 private BsonValue GetBsonValue(UniversalValue item)
 {
     switch (item.Type)
     {
         case UniversalValue.UniversalClassType.Numeric:
             return new BsonDouble(item.DoubleValue);
         case UniversalValue.UniversalClassType.TimeSpan:
             return new BsonString(item.TimespanValue.ToString());
         case UniversalValue.UniversalClassType.String:
             return new BsonString(item.StringValue);
         default:
             throw new Exception("Unknown type " + item.Type);
     }
 }
 public CounterData(DateTime dateTime, UniversalValue value)
 {
     DateTime = dateTime;
     Value = value;
 }
 public void Add(string key, UniversalValue value)
 {
     Value.Add(new KeyValuePair<string, UniversalValue>(key, value));
 }
 public SeriesPoint(DateTime dateTime, UniversalValue value)
 {
     DateTime = dateTime;
     Value    = value == null? (double?)null: value.Type == UniversalValue.UniversalClassType.TimeSpan ? value.TimespanValue.TotalMilliseconds : value.DoubleValue;
 }