internal static Trigger DeserializeTrigger(JsonElement element)
        {
            if (element.TryGetProperty("type", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "BlobEventsTrigger": return(BlobEventsTrigger.DeserializeBlobEventsTrigger(element));

                case "BlobTrigger": return(BlobTrigger.DeserializeBlobTrigger(element));

                case "ChainingTrigger": return(ChainingTrigger.DeserializeChainingTrigger(element));

                case "MultiplePipelineTrigger": return(MultiplePipelineTrigger.DeserializeMultiplePipelineTrigger(element));

                case "RerunTumblingWindowTrigger": return(RerunTumblingWindowTrigger.DeserializeRerunTumblingWindowTrigger(element));

                case "ScheduleTrigger": return(ScheduleTrigger.DeserializeScheduleTrigger(element));

                case "TumblingWindowTrigger": return(TumblingWindowTrigger.DeserializeTumblingWindowTrigger(element));
                }
            }
            string            type        = default;
            Optional <string> description = default;
            Optional <TriggerRuntimeState> runtimeState                   = default;
            Optional <IList <object> >     annotations                    = default;
            IDictionary <string, object>   additionalProperties           = default;
            Dictionary <string, object>    additionalPropertiesDictionary = new Dictionary <string, object>();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("runtimeState"))
                {
                    runtimeState = new TriggerRuntimeState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("annotations"))
                {
                    List <object> array = new List <object>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(item.GetObject());
                    }
                    annotations = array;
                    continue;
                }
                additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject());
            }
            additionalProperties = additionalPropertiesDictionary;
            return(new Trigger(type, description.Value, Optional.ToNullable(runtimeState), Optional.ToList(annotations), additionalProperties));
        }
        internal static RerunTriggerResource DeserializeRerunTriggerResource(JsonElement element)
        {
            RerunTumblingWindowTrigger properties = default;
            string id   = default;
            string name = default;
            string type = default;
            string etag = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("properties"))
                {
                    properties = RerunTumblingWindowTrigger.DeserializeRerunTumblingWindowTrigger(property.Value);
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("etag"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    etag = property.Value.GetString();
                    continue;
                }
            }
            return(new RerunTriggerResource(id, name, type, etag, properties));
        }
        internal static RerunTriggerResource DeserializeRerunTriggerResource(JsonElement element)
        {
            RerunTumblingWindowTrigger properties = default;
            Optional <string>          id         = default;
            Optional <string>          name       = default;
            Optional <string>          type       = default;
            Optional <string>          etag       = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("properties"))
                {
                    properties = RerunTumblingWindowTrigger.DeserializeRerunTumblingWindowTrigger(property.Value);
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("etag"))
                {
                    etag = property.Value.GetString();
                    continue;
                }
            }
            return(new RerunTriggerResource(id.Value, name.Value, type.Value, etag.Value, properties));
        }
Exemple #4
0
        internal static Trigger DeserializeTrigger(JsonElement element)
        {
            if (element.TryGetProperty("type", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "MultiplePipelineTrigger": return(MultiplePipelineTrigger.DeserializeMultiplePipelineTrigger(element));

                case "RerunTumblingWindowTrigger": return(RerunTumblingWindowTrigger.DeserializeRerunTumblingWindowTrigger(element));
                }
            }
            string type        = default;
            string description = default;
            TriggerRuntimeState?         runtimeState                   = default;
            IList <object>               annotations                    = default;
            IDictionary <string, object> additionalProperties           = default;
            Dictionary <string, object>  additionalPropertiesDictionary = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("runtimeState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    runtimeState = new TriggerRuntimeState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("annotations"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <object> array = new List <object>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(item.GetObject());
                        }
                    }
                    annotations = array;
                    continue;
                }
                additionalPropertiesDictionary ??= new Dictionary <string, object>();
                if (property.Value.ValueKind == JsonValueKind.Null)
                {
                    additionalPropertiesDictionary.Add(property.Name, null);
                }
                else
                {
                    additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject());
                }
            }
            additionalProperties = additionalPropertiesDictionary;
            return(new Trigger(type, description, runtimeState, annotations, additionalProperties));
        }