Exemplo n.º 1
0
        public ScaleRule(MetricTrigger metricTrigger, ScaleAction scaleAction)
        {
            if (metricTrigger == null)
            {
                throw new ArgumentNullException(nameof(metricTrigger));
            }
            if (scaleAction == null)
            {
                throw new ArgumentNullException(nameof(scaleAction));
            }

            MetricTrigger = metricTrigger;
            ScaleAction   = scaleAction;
        }
        internal static ScaleRule DeserializeScaleRule(JsonElement element)
        {
            MetricTrigger metricTrigger = default;
            ScaleAction   scaleAction   = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("metricTrigger"))
                {
                    metricTrigger = MetricTrigger.DeserializeMetricTrigger(property.Value);
                    continue;
                }
                if (property.NameEquals("scaleAction"))
                {
                    scaleAction = ScaleAction.DeserializeScaleAction(property.Value);
                    continue;
                }
            }
            return(new ScaleRule(metricTrigger, scaleAction));
        }