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));
        }
Ejemplo n.º 2
0
        internal static MultiplePipelineTrigger DeserializeMultiplePipelineTrigger(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 "ScheduleTrigger": return(ScheduleTrigger.DeserializeScheduleTrigger(element));
                }
            }
            Optional <IList <TriggerPipelineReference> > pipelines = default;
            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("pipelines"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    List <TriggerPipelineReference> array = new List <TriggerPipelineReference>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(TriggerPipelineReference.DeserializeTriggerPipelineReference(item));
                    }
                    pipelines = array;
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("runtimeState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    runtimeState = new TriggerRuntimeState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("annotations"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    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 MultiplePipelineTrigger(type, description.Value, Optional.ToNullable(runtimeState), Optional.ToList(annotations), additionalProperties, Optional.ToList(pipelines)));
        }