Beispiel #1
0
        internal static BatchEndpointProperties DeserializeBatchEndpointProperties(JsonElement element)
        {
            Optional <BatchEndpointDefaults>     defaults          = default;
            Optional <EndpointProvisioningState> provisioningState = default;
            EndpointAuthMode            authMode                = default;
            Optional <string>           description             = default;
            Optional <EndpointAuthKeys> keys                    = default;
            Optional <IDictionary <string, string> > properties = default;
            Optional <Uri> scoringUri = default;
            Optional <Uri> swaggerUri = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("defaults"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        defaults = null;
                        continue;
                    }
                    defaults = BatchEndpointDefaults.DeserializeBatchEndpointDefaults(property.Value);
                    continue;
                }
                if (property.NameEquals("provisioningState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    provisioningState = new EndpointProvisioningState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("authMode"))
                {
                    authMode = new EndpointAuthMode(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        description = null;
                        continue;
                    }
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("keys"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        keys = null;
                        continue;
                    }
                    keys = EndpointAuthKeys.DeserializeEndpointAuthKeys(property.Value);
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        properties = null;
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.Value.ValueKind == JsonValueKind.Null)
                        {
                            dictionary.Add(property0.Name, null);
                        }
                        else
                        {
                            dictionary.Add(property0.Name, property0.Value.GetString());
                        }
                    }
                    properties = dictionary;
                    continue;
                }
                if (property.NameEquals("scoringUri"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        scoringUri = null;
                        continue;
                    }
                    scoringUri = new Uri(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("swaggerUri"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        swaggerUri = null;
                        continue;
                    }
                    swaggerUri = new Uri(property.Value.GetString());
                    continue;
                }
            }
            return(new BatchEndpointProperties(authMode, description.Value, keys.Value, Optional.ToDictionary(properties), scoringUri.Value, swaggerUri.Value, defaults.Value, Optional.ToNullable(provisioningState)));
        }
Beispiel #2
0
        internal static OnlineEndpointProperties DeserializeOnlineEndpointProperties(JsonElement element)
        {
            Optional <string> compute = default;
            Optional <IDictionary <string, int> > mirrorTraffic       = default;
            Optional <EndpointProvisioningState>  provisioningState   = default;
            Optional <PublicNetworkAccessType>    publicNetworkAccess = default;
            Optional <IDictionary <string, int> > traffic             = default;
            EndpointAuthMode            authMode                = default;
            Optional <string>           description             = default;
            Optional <EndpointAuthKeys> keys                    = default;
            Optional <IDictionary <string, string> > properties = default;
            Optional <Uri> scoringUri = default;
            Optional <Uri> swaggerUri = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("compute"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        compute = null;
                        continue;
                    }
                    compute = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("mirrorTraffic"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        mirrorTraffic = null;
                        continue;
                    }
                    Dictionary <string, int> dictionary = new Dictionary <string, int>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetInt32());
                    }
                    mirrorTraffic = dictionary;
                    continue;
                }
                if (property.NameEquals("provisioningState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    provisioningState = new EndpointProvisioningState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("publicNetworkAccess"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    publicNetworkAccess = new PublicNetworkAccessType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("traffic"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        traffic = null;
                        continue;
                    }
                    Dictionary <string, int> dictionary = new Dictionary <string, int>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetInt32());
                    }
                    traffic = dictionary;
                    continue;
                }
                if (property.NameEquals("authMode"))
                {
                    authMode = new EndpointAuthMode(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("description"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        description = null;
                        continue;
                    }
                    description = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("keys"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        keys = null;
                        continue;
                    }
                    keys = EndpointAuthKeys.DeserializeEndpointAuthKeys(property.Value);
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        properties = null;
                        continue;
                    }
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.Value.ValueKind == JsonValueKind.Null)
                        {
                            dictionary.Add(property0.Name, null);
                        }
                        else
                        {
                            dictionary.Add(property0.Name, property0.Value.GetString());
                        }
                    }
                    properties = dictionary;
                    continue;
                }
                if (property.NameEquals("scoringUri"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        scoringUri = null;
                        continue;
                    }
                    scoringUri = new Uri(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("swaggerUri"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        swaggerUri = null;
                        continue;
                    }
                    swaggerUri = new Uri(property.Value.GetString());
                    continue;
                }
            }
            return(new OnlineEndpointProperties(authMode, description.Value, keys.Value, Optional.ToDictionary(properties), scoringUri.Value, swaggerUri.Value, compute.Value, Optional.ToDictionary(mirrorTraffic), Optional.ToNullable(provisioningState), Optional.ToNullable(publicNetworkAccess), Optional.ToDictionary(traffic)));
        }