internal static MediaGraphProcessor DeserializeMediaGraphProcessor(JsonElement element)
        {
            if (element.TryGetProperty("@type", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "#Microsoft.Media.MediaGraphCognitiveServicesVisionExtension": return(MediaGraphCognitiveServicesVisionExtension.DeserializeMediaGraphCognitiveServicesVisionExtension(element));

                case "#Microsoft.Media.MediaGraphExtensionProcessorBase": return(MediaGraphExtensionProcessorBase.DeserializeMediaGraphExtensionProcessorBase(element));

                case "#Microsoft.Media.MediaGraphGrpcExtension": return(MediaGraphGrpcExtension.DeserializeMediaGraphGrpcExtension(element));

                case "#Microsoft.Media.MediaGraphHttpExtension": return(MediaGraphHttpExtension.DeserializeMediaGraphHttpExtension(element));

                case "#Microsoft.Media.MediaGraphMotionDetectionProcessor": return(MediaGraphMotionDetectionProcessor.DeserializeMediaGraphMotionDetectionProcessor(element));

                case "#Microsoft.Media.MediaGraphSignalGateProcessor": return(MediaGraphSignalGateProcessor.DeserializeMediaGraphSignalGateProcessor(element));
                }
            }
            string type = default;
            string name = default;
            IList <MediaGraphNodeInput> inputs = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("@type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("inputs"))
                {
                    List <MediaGraphNodeInput> array = new List <MediaGraphNodeInput>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(MediaGraphNodeInput.DeserializeMediaGraphNodeInput(item));
                    }
                    inputs = array;
                    continue;
                }
            }
            return(new MediaGraphProcessor(type, name, inputs));
        }
        internal static MediaGraphExtensionProcessorBase DeserializeMediaGraphExtensionProcessorBase(JsonElement element)
        {
            if (element.TryGetProperty("@type", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "#Microsoft.Media.MediaGraphCognitiveServicesVisionExtension": return(MediaGraphCognitiveServicesVisionExtension.DeserializeMediaGraphCognitiveServicesVisionExtension(element));

                case "#Microsoft.Media.MediaGraphGrpcExtension": return(MediaGraphGrpcExtension.DeserializeMediaGraphGrpcExtension(element));

                case "#Microsoft.Media.MediaGraphHttpExtension": return(MediaGraphHttpExtension.DeserializeMediaGraphHttpExtension(element));
                }
            }
            MediaGraphEndpoint endpoint = default;
            MediaGraphImage    image    = default;
            Optional <MediaGraphSamplingOptions> samplingOptions = default;
            string type = default;
            string name = default;
            IList <MediaGraphNodeInput> inputs = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("endpoint"))
                {
                    endpoint = MediaGraphEndpoint.DeserializeMediaGraphEndpoint(property.Value);
                    continue;
                }
                if (property.NameEquals("image"))
                {
                    image = MediaGraphImage.DeserializeMediaGraphImage(property.Value);
                    continue;
                }
                if (property.NameEquals("samplingOptions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    samplingOptions = MediaGraphSamplingOptions.DeserializeMediaGraphSamplingOptions(property.Value);
                    continue;
                }
                if (property.NameEquals("@type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("inputs"))
                {
                    List <MediaGraphNodeInput> array = new List <MediaGraphNodeInput>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        array.Add(MediaGraphNodeInput.DeserializeMediaGraphNodeInput(item));
                    }
                    inputs = array;
                    continue;
                }
            }
            return(new MediaGraphExtensionProcessorBase(type, name, inputs, endpoint, image, samplingOptions.Value));
        }