예제 #1
0
 private IAggregation GetValueMetricOrAggregation(JsonReader reader, JsonSerializer serializer)
 {
     reader.Read();
     var metric = new ValueMetric()
     {
         Value = (reader.Value as double?)
     };
     if (metric.Value == null && reader.ValueType == typeof(long))
         metric.Value = reader.Value as long?;
     reader.Read();
     return metric;
 }
		private IAggregation GetValueMetricOrAggregation(JsonReader reader, JsonSerializer serializer)
		{
			reader.Read();
			var valueMetric = new ValueMetric()
			{
				Value = (reader.Value as double?)
			};
			if (valueMetric.Value == null && reader.ValueType == typeof(long))
				valueMetric.Value = reader.Value as long?;

			if (valueMetric.Value != null)
			{
				reader.Read();
				return valueMetric;
			}

			var scriptedMetric = serializer.Deserialize(reader);

			if (scriptedMetric != null)
				return new ScriptedValueMetric { _Value = scriptedMetric };

			reader.Read();
			return valueMetric;
		}