コード例 #1
0
        protected void ReadMetricProperties(IMetricAggregation metric, Dictionary <string, JToken> properties)
        {
            if (properties.TryGetValue("field", out JToken fieldToken))
            {
                metric.Field = fieldToken.ToString();
            }

            if (properties.TryGetValue("script", out JToken scriptToken))
            {
                var scriptProps = JObject.FromObject(scriptToken).Properties().ToDictionary(p => p.Name, p => p.Value);
                if (scriptProps.ContainsKey("source") || scriptProps.ContainsKey("inline"))
                {
                    metric.Script = scriptToken.ToObject <InlineScript>();
                }
                else if (scriptProps.TryGetValue("id", out JToken idToken))
                {
                    metric.Script = idToken.ToObject <IndexedScript>();
                }
            }

            if (properties.TryGetValue("missing", out JToken missingToken))
            {
                metric.Missing = double.Parse(missingToken.ToString());
            }
        }
コード例 #2
0
        protected void ReadMetricProperties(IMetricAggregation metric, Dictionary <string, JToken> properties)
        {
            if (properties.ContainsKey("field"))
            {
                metric.Field = properties["field"].ToString();
            }

            if (properties.ContainsKey("script"))
            {
                var scriptProps = JObject.FromObject(properties["script"]).Properties().ToDictionary(p => p.Name, p => p.Value);
                if (scriptProps.ContainsKey("inline"))
                {
                    metric.Script = properties["script"].ToObject <InlineScript>();
                }
                else if (scriptProps.ContainsKey("file"))
                {
                    metric.Script = properties["script"].ToObject <FileScript>();
                }
                else if (scriptProps.ContainsKey("id"))
                {
                    metric.Script = properties["id"].ToObject <IndexedScript>();
                }
            }

            if (properties.ContainsKey("missing"))
            {
                metric.Missing = double.Parse(properties["missing"].ToString());
            }
        }
コード例 #3
0
		protected void ReadMetricProperties(IMetricAggregation metric, Dictionary<string, JToken> properties)
		{
			if (properties.ContainsKey("field"))
				metric.Field = properties["field"].ToString();

			if (properties.ContainsKey("script"))
			{
				var scriptProps = JObject.FromObject(properties["script"]).Properties().ToDictionary(p => p.Name, p => p.Value);
				if (scriptProps.ContainsKey("inline"))
					metric.Script = properties["script"].ToObject<InlineScript>();
				else if (scriptProps.ContainsKey("file"))
					metric.Script = properties["script"].ToObject<FileScript>();
				else if (scriptProps.ContainsKey("id"))
					metric.Script = properties["id"].ToObject<IndexedScript>();
			}

			if (properties.ContainsKey("missing"))
				metric.Missing = double.Parse(properties["missing"].ToString());
		}
コード例 #4
0
        protected void WriteMetricProperties(IMetricAggregation metric, JsonWriter writer, JsonSerializer serializer)
        {
            if (metric.Field != null)
            {
                var settings = serializer.GetConnectionSettings();
                writer.WritePropertyName("field");
                writer.WriteValue(settings.Inferrer.Field(metric.Field));
            }

            if (metric.Script != null)
            {
                writer.WritePropertyName("script");
                serializer.Serialize(writer, metric.Script);
            }

            if (metric.Missing.HasValue)
            {
                writer.WritePropertyName("missing");
                writer.WriteValue(metric.Missing);
            }
        }
コード例 #5
0
		protected void WriteMetricProperties(IMetricAggregation metric, JsonWriter writer, JsonSerializer serializer)
		{

			if (metric.Field != null)
			{
				var settings = serializer.GetConnectionSettings();
				writer.WritePropertyName("field");
				writer.WriteValue(settings.Inferrer.Field(metric.Field));
			}
			
			if (metric.Script != null)
			{
				writer.WritePropertyName("script");
				serializer.Serialize(writer, metric.Script);
			}

			if (metric.Missing.HasValue)
			{
				writer.WritePropertyName("missing");
				writer.WriteValue(metric.Missing);
			}
		}