Пример #1
0
        internal static MediaJobOutput DeserializeMediaJobOutput(JsonElement element)
        {
            if (element.TryGetProperty("@odata.type", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "#Microsoft.Media.JobOutputAsset": return(MediaJobOutputAsset.DeserializeMediaJobOutputAsset(element));
                }
            }
            string odataType = default;
            Optional <MediaJobError> error = default;
            Optional <string>        label = default;
            long          progress         = default;
            MediaJobState state            = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("@odata.type"))
                {
                    odataType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("error"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    error = MediaJobError.DeserializeMediaJobError(property.Value);
                    continue;
                }
                if (property.NameEquals("label"))
                {
                    label = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("progress"))
                {
                    progress = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("state"))
                {
                    state = property.Value.GetString().ToMediaJobState();
                    continue;
                }
            }
            return(new MediaJobOutput(odataType, error.Value, label.Value, progress, state));
        }
        internal static MediaJobOutputAsset DeserializeMediaJobOutputAsset(JsonElement element)
        {
            Optional <string>        assetName = default;
            Optional <string>        odataType = default;
            Optional <MediaJobError> error     = default;
            Optional <string>        label     = default;
            long          progress             = default;
            MediaJobState state = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("assetName"))
                {
                    assetName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("@odata.type"))
                {
                    odataType = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("error"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    error = MediaJobError.DeserializeMediaJobError(property.Value);
                    continue;
                }
                if (property.NameEquals("label"))
                {
                    label = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("progress"))
                {
                    progress = property.Value.GetInt64();
                    continue;
                }
                if (property.NameEquals("state"))
                {
                    state = property.Value.GetString().ToMediaJobState();
                    continue;
                }
            }
            return(new MediaJobOutputAsset(odataType.Value, error.Value, label.Value, progress, state, assetName.Value));
        }