internal static AutoForecastHorizon DeserializeAutoForecastHorizon(JsonElement element) { ForecastHorizonMode mode = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("mode")) { mode = new ForecastHorizonMode(property.Value.GetString()); continue; } } return(new AutoForecastHorizon(mode)); }
internal static CustomForecastHorizon DeserializeCustomForecastHorizon(JsonElement element) { int value = default; ForecastHorizonMode mode = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("value")) { value = property.Value.GetInt32(); continue; } if (property.NameEquals("mode")) { mode = new ForecastHorizonMode(property.Value.GetString()); continue; } } return(new CustomForecastHorizon(mode, value)); }
internal static ForecastHorizon DeserializeForecastHorizon(JsonElement element) { if (element.TryGetProperty("mode", out JsonElement discriminator)) { switch (discriminator.GetString()) { case "Auto": return(AutoForecastHorizon.DeserializeAutoForecastHorizon(element)); case "Custom": return(CustomForecastHorizon.DeserializeCustomForecastHorizon(element)); } } ForecastHorizonMode mode = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("mode")) { mode = new ForecastHorizonMode(property.Value.GetString()); continue; } } return(new ForecastHorizon(mode)); }