Example #1
0
        internal static AutoScaleRun DeserializeAutoScaleRun(JsonElement element)
        {
            DateTimeOffset    timestamp = default;
            string            results   = default;
            AutoScaleRunError error     = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("timestamp"))
                {
                    timestamp = property.Value.GetDateTimeOffset("S");
                    continue;
                }
                if (property.NameEquals("results"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    results = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("error"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    error = AutoScaleRunError.DeserializeAutoScaleRunError(property.Value);
                    continue;
                }
            }
            return(new AutoScaleRun(timestamp, results, error));
        }
 internal AutoScaleRun(DateTimeOffset timestamp, string results, AutoScaleRunError error)
 {
     Timestamp = timestamp;
     Results   = results;
     Error     = error;
 }