示例#1
0
 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));
        }
示例#3
0
        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();
        }