Ejemplo 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));
        }
Ejemplo 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));
        }
Ejemplo 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));
        }
Ejemplo n.º 4
0
 internal CustomTargetLags(TargetLagsMode mode, IList <int> values) : base(mode)
 {
     Values = values;
     Mode   = mode;
 }