Example #1
0
        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";
        }
Example #2
0
 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";
 }
Example #3
0
        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));
        }