internal AutoscaleProfile(string name, ScaleCapacity capacity, IList <ScaleRule> rules, TimeWindow fixedDate, Recurrence recurrence) { Name = name; Capacity = capacity; Rules = rules; FixedDate = fixedDate; Recurrence = recurrence; }
internal static AutoscaleProfile DeserializeAutoscaleProfile(JsonElement element) { string name = default; ScaleCapacity capacity = default; IList <ScaleRule> rules = default; Optional <TimeWindow> fixedDate = default; Optional <Recurrence> recurrence = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("capacity")) { capacity = ScaleCapacity.DeserializeScaleCapacity(property.Value); continue; } if (property.NameEquals("rules")) { List <ScaleRule> array = new List <ScaleRule>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(ScaleRule.DeserializeScaleRule(item)); } rules = array; continue; } if (property.NameEquals("fixedDate")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } fixedDate = TimeWindow.DeserializeTimeWindow(property.Value); continue; } if (property.NameEquals("recurrence")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } recurrence = Recurrence.DeserializeRecurrence(property.Value); continue; } } return(new AutoscaleProfile(name, capacity, rules, fixedDate.Value, recurrence.Value)); }
public AutoscaleProfile(string name, ScaleCapacity capacity, IEnumerable <ScaleRule> rules) { if (name == null) { throw new ArgumentNullException(nameof(name)); } if (capacity == null) { throw new ArgumentNullException(nameof(capacity)); } if (rules == null) { throw new ArgumentNullException(nameof(rules)); } Name = name; Capacity = capacity; Rules = rules.ToList(); }