Esempio n. 1
0
        internal static CustomTargetLags DeserializeCustomTargetLags(JsonElement element)
        {
            IList <int>    values = default;
            TargetLagsMode mode   = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("values"))
                {
                    List <int> array = new List <int>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetInt32());
                    }
                    values = array;
                    continue;
                }
                if (property.NameEquals("mode"))
                {
                    mode = new TargetLagsMode(property.Value.GetString());
                    continue;
                }
            }
            return(new CustomTargetLags(mode, values));
        }
Esempio n. 2
0
        internal static AutoTargetLags DeserializeAutoTargetLags(JsonElement element)
        {
            TargetLagsMode mode = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("mode"))
                {
                    mode = new TargetLagsMode(property.Value.GetString());
                    continue;
                }
            }
            return(new AutoTargetLags(mode));
        }
Esempio n. 3
0
        internal static TargetLags DeserializeTargetLags(JsonElement element)
        {
            if (element.TryGetProperty("mode", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "Auto": return(AutoTargetLags.DeserializeAutoTargetLags(element));

                case "Custom": return(CustomTargetLags.DeserializeCustomTargetLags(element));
                }
            }
            TargetLagsMode mode = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("mode"))
                {
                    mode = new TargetLagsMode(property.Value.GetString());
                    continue;
                }
            }
            return(new TargetLags(mode));
        }
Esempio n. 4
0
 internal CustomTargetLags(TargetLagsMode mode, IList <int> values) : base(mode)
 {
     Values = values;
     Mode   = mode;
 }