Example #1
0
        internal static AutoSeasonality DeserializeAutoSeasonality(JsonElement element)
        {
            SeasonalityMode mode = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("mode"))
                {
                    mode = new SeasonalityMode(property.Value.GetString());
                    continue;
                }
            }
            return(new AutoSeasonality(mode));
        }
Example #2
0
        internal static CustomSeasonality DeserializeCustomSeasonality(JsonElement element)
        {
            int             value = default;
            SeasonalityMode mode  = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("value"))
                {
                    value = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("mode"))
                {
                    mode = new SeasonalityMode(property.Value.GetString());
                    continue;
                }
            }
            return(new CustomSeasonality(mode, value));
        }
Example #3
0
        internal static Seasonality DeserializeSeasonality(JsonElement element)
        {
            if (element.TryGetProperty("mode", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "Auto": return(AutoSeasonality.DeserializeAutoSeasonality(element));

                case "Custom": return(CustomSeasonality.DeserializeCustomSeasonality(element));
                }
            }
            SeasonalityMode mode = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("mode"))
                {
                    mode = new SeasonalityMode(property.Value.GetString());
                    continue;
                }
            }
            return(new Seasonality(mode));
        }