예제 #1
0
        internal static AggregateVariable DeserializeAggregateVariable(JsonElement element)
        {
            TimeSeriesExpression aggregation = default;
            string kind = default;
            Optional <TimeSeriesExpression> filter = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("aggregation"))
                {
                    aggregation = TimeSeriesExpression.DeserializeTimeSeriesExpression(property.Value);
                    continue;
                }
                if (property.NameEquals("kind"))
                {
                    kind = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("filter"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    filter = TimeSeriesExpression.DeserializeTimeSeriesExpression(property.Value);
                    continue;
                }
            }
            return(new AggregateVariable(kind, filter.Value, aggregation));
        }
예제 #2
0
 internal NumericVariable(string kind, TimeSeriesExpression filter, TimeSeriesExpression value, InterpolationOperation interpolation, TimeSeriesExpression aggregation) : base(kind, filter)
 {
     Value         = value;
     Interpolation = interpolation;
     Aggregation   = aggregation;
     Kind          = kind ?? "numeric";
 }
 internal CategoricalVariable(string kind, TimeSeriesExpression filter, TimeSeriesExpression value, InterpolationOperation interpolation, IList <TimeSeriesAggregateCategory> categories, TimeSeriesDefaultCategory defaultCategory) : base(kind, filter)
 {
     Value           = value;
     Interpolation   = interpolation;
     Categories      = categories;
     DefaultCategory = defaultCategory;
     Kind            = kind ?? "categorical";
 }
        public AggregateVariable(TimeSeriesExpression aggregation)
        {
            if (aggregation == null)
            {
                throw new ArgumentNullException(nameof(aggregation));
            }

            Aggregation = aggregation;
            Kind        = "aggregate";
        }
예제 #5
0
        public NumericVariable(TimeSeriesExpression value, TimeSeriesExpression aggregation)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }
            if (aggregation == null)
            {
                throw new ArgumentNullException(nameof(aggregation));
            }

            Value       = value;
            Aggregation = aggregation;
            Kind        = "numeric";
        }
        public CategoricalVariable(TimeSeriesExpression value, TimeSeriesDefaultCategory defaultCategory)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }
            if (defaultCategory == null)
            {
                throw new ArgumentNullException(nameof(defaultCategory));
            }

            Value           = value;
            Categories      = new ChangeTrackingList <TimeSeriesAggregateCategory>();
            DefaultCategory = defaultCategory;
            Kind            = "categorical";
        }
예제 #7
0
        internal static TimeSeriesVariable DeserializeTimeSeriesVariable(JsonElement element)
        {
            if (element.TryGetProperty("kind", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "aggregate": return(AggregateVariable.DeserializeAggregateVariable(element));

                case "categorical": return(CategoricalVariable.DeserializeCategoricalVariable(element));

                case "numeric": return(NumericVariable.DeserializeNumericVariable(element));
                }
            }
            string kind = default;
            Optional <TimeSeriesExpression> filter = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("kind"))
                {
                    kind = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("filter"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    filter = TimeSeriesExpression.DeserializeTimeSeriesExpression(property.Value);
                    continue;
                }
            }
            return(new TimeSeriesVariable(kind, filter.Value));
        }
        internal static CategoricalVariable DeserializeCategoricalVariable(JsonElement element)
        {
            TimeSeriesExpression value = default;
            Optional <InterpolationOperation> interpolation            = default;
            Optional <IList <TimeSeriesAggregateCategory> > categories = default;
            TimeSeriesDefaultCategory defaultCategory = default;
            string kind = default;
            Optional <TimeSeriesExpression> filter = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("value"))
                {
                    value = TimeSeriesExpression.DeserializeTimeSeriesExpression(property.Value);
                    continue;
                }
                if (property.NameEquals("interpolation"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    interpolation = InterpolationOperation.DeserializeInterpolationOperation(property.Value);
                    continue;
                }
                if (property.NameEquals("categories"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <TimeSeriesAggregateCategory> array = new List <TimeSeriesAggregateCategory>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TimeSeriesAggregateCategory.DeserializeTimeSeriesAggregateCategory(item));
                    }
                    categories = array;
                    continue;
                }
                if (property.NameEquals("defaultCategory"))
                {
                    defaultCategory = TimeSeriesDefaultCategory.DeserializeTimeSeriesDefaultCategory(property.Value);
                    continue;
                }
                if (property.NameEquals("kind"))
                {
                    kind = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("filter"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    filter = TimeSeriesExpression.DeserializeTimeSeriesExpression(property.Value);
                    continue;
                }
            }
            return(new CategoricalVariable(kind, filter.Value, value, interpolation.Value, Optional.ToList(categories), defaultCategory));
        }
 internal AggregateVariable(string kind, TimeSeriesExpression filter, TimeSeriesExpression aggregation) : base(kind, filter)
 {
     Aggregation = aggregation;
     Kind        = kind ?? "aggregate";
 }