internal static ConnectionMonitorResult DeserializeConnectionMonitorResult(JsonElement element)
        {
            string name     = default;
            string id       = default;
            string etag     = default;
            string type     = default;
            string location = default;
            IReadOnlyDictionary <string, string> tags = default;
            ConnectionMonitorSource      source       = default;
            ConnectionMonitorDestination destination  = default;
            bool?autoStart = default;
            int? monitoringIntervalInSeconds = default;
            IReadOnlyList <ConnectionMonitorEndpoint>          endpoints          = default;
            IReadOnlyList <ConnectionMonitorTestConfiguration> testConfigurations = default;
            IReadOnlyList <ConnectionMonitorTestGroup>         testGroups         = default;
            IReadOnlyList <ConnectionMonitorOutput>            outputs            = default;
            string                notes                 = default;
            ProvisioningState?    provisioningState     = default;
            DateTimeOffset?       startTime             = default;
            string                monitoringStatus      = default;
            ConnectionMonitorType?connectionMonitorType = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("etag"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    etag = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    location = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    if (property.Value.ValueKind == JsonValueKind.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());
                        }
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("source"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            source = ConnectionMonitorSource.DeserializeConnectionMonitorSource(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("destination"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            destination = ConnectionMonitorDestination.DeserializeConnectionMonitorDestination(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("autoStart"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            autoStart = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("monitoringIntervalInSeconds"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            monitoringIntervalInSeconds = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("endpoints"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            List <ConnectionMonitorEndpoint> array = new List <ConnectionMonitorEndpoint>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                if (item.ValueKind == JsonValueKind.Null)
                                {
                                    array.Add(null);
                                }
                                else
                                {
                                    array.Add(ConnectionMonitorEndpoint.DeserializeConnectionMonitorEndpoint(item));
                                }
                            }
                            endpoints = array;
                            continue;
                        }
                        if (property0.NameEquals("testConfigurations"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            List <ConnectionMonitorTestConfiguration> array = new List <ConnectionMonitorTestConfiguration>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                if (item.ValueKind == JsonValueKind.Null)
                                {
                                    array.Add(null);
                                }
                                else
                                {
                                    array.Add(ConnectionMonitorTestConfiguration.DeserializeConnectionMonitorTestConfiguration(item));
                                }
                            }
                            testConfigurations = array;
                            continue;
                        }
                        if (property0.NameEquals("testGroups"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            List <ConnectionMonitorTestGroup> array = new List <ConnectionMonitorTestGroup>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                if (item.ValueKind == JsonValueKind.Null)
                                {
                                    array.Add(null);
                                }
                                else
                                {
                                    array.Add(ConnectionMonitorTestGroup.DeserializeConnectionMonitorTestGroup(item));
                                }
                            }
                            testGroups = array;
                            continue;
                        }
                        if (property0.NameEquals("outputs"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            List <ConnectionMonitorOutput> array = new List <ConnectionMonitorOutput>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                if (item.ValueKind == JsonValueKind.Null)
                                {
                                    array.Add(null);
                                }
                                else
                                {
                                    array.Add(ConnectionMonitorOutput.DeserializeConnectionMonitorOutput(item));
                                }
                            }
                            outputs = array;
                            continue;
                        }
                        if (property0.NameEquals("notes"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            notes = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            provisioningState = new ProvisioningState(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("startTime"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            startTime = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("monitoringStatus"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            monitoringStatus = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("connectionMonitorType"))
                        {
                            if (property0.Value.ValueKind == JsonValueKind.Null)
                            {
                                continue;
                            }
                            connectionMonitorType = new ConnectionMonitorType(property0.Value.GetString());
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new ConnectionMonitorResult(name, id, etag, type, location, tags, source, destination, autoStart, monitoringIntervalInSeconds, endpoints, testConfigurations, testGroups, outputs, notes, provisioningState, startTime, monitoringStatus, connectionMonitorType));
        }
        internal static ConnectionMonitorParameters DeserializeConnectionMonitorParameters(JsonElement element)
        {
            ConnectionMonitorSource      source      = default;
            ConnectionMonitorDestination destination = default;
            bool?autoStart = default;
            int? monitoringIntervalInSeconds = default;
            IList <ConnectionMonitorEndpoint>          endpoints          = default;
            IList <ConnectionMonitorTestConfiguration> testConfigurations = default;
            IList <ConnectionMonitorTestGroup>         testGroups         = default;
            IList <ConnectionMonitorOutput>            outputs            = default;
            string notes = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("source"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    source = ConnectionMonitorSource.DeserializeConnectionMonitorSource(property.Value);
                    continue;
                }
                if (property.NameEquals("destination"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    destination = ConnectionMonitorDestination.DeserializeConnectionMonitorDestination(property.Value);
                    continue;
                }
                if (property.NameEquals("autoStart"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    autoStart = property.Value.GetBoolean();
                    continue;
                }
                if (property.NameEquals("monitoringIntervalInSeconds"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    monitoringIntervalInSeconds = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("endpoints"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <ConnectionMonitorEndpoint> array = new List <ConnectionMonitorEndpoint>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(ConnectionMonitorEndpoint.DeserializeConnectionMonitorEndpoint(item));
                        }
                    }
                    endpoints = array;
                    continue;
                }
                if (property.NameEquals("testConfigurations"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <ConnectionMonitorTestConfiguration> array = new List <ConnectionMonitorTestConfiguration>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(ConnectionMonitorTestConfiguration.DeserializeConnectionMonitorTestConfiguration(item));
                        }
                    }
                    testConfigurations = array;
                    continue;
                }
                if (property.NameEquals("testGroups"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <ConnectionMonitorTestGroup> array = new List <ConnectionMonitorTestGroup>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(ConnectionMonitorTestGroup.DeserializeConnectionMonitorTestGroup(item));
                        }
                    }
                    testGroups = array;
                    continue;
                }
                if (property.NameEquals("outputs"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    List <ConnectionMonitorOutput> array = new List <ConnectionMonitorOutput>();
                    foreach (var item in property.Value.EnumerateArray())
                    {
                        if (item.ValueKind == JsonValueKind.Null)
                        {
                            array.Add(null);
                        }
                        else
                        {
                            array.Add(ConnectionMonitorOutput.DeserializeConnectionMonitorOutput(item));
                        }
                    }
                    outputs = array;
                    continue;
                }
                if (property.NameEquals("notes"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    notes = property.Value.GetString();
                    continue;
                }
            }
            return(new ConnectionMonitorParameters(source, destination, autoStart, monitoringIntervalInSeconds, endpoints, testConfigurations, testGroups, outputs, notes));
        }
コード例 #3
0
        internal static ConnectionMonitorResult DeserializeConnectionMonitorResult(JsonElement element)
        {
            Optional <string> name     = default;
            Optional <string> id       = default;
            Optional <string> etag     = default;
            Optional <string> type     = default;
            Optional <string> location = default;
            Optional <IReadOnlyDictionary <string, string> > tags = default;
            Optional <ConnectionMonitorSource>      source        = default;
            Optional <ConnectionMonitorDestination> destination   = default;
            Optional <bool> autoStart = default;
            Optional <int>  monitoringIntervalInSeconds = default;
            Optional <IReadOnlyList <ConnectionMonitorEndpoint> >          endpoints          = default;
            Optional <IReadOnlyList <ConnectionMonitorTestConfiguration> > testConfigurations = default;
            Optional <IReadOnlyList <ConnectionMonitorTestGroup> >         testGroups         = default;
            Optional <IReadOnlyList <ConnectionMonitorOutput> >            outputs            = default;
            Optional <string>                notes                 = default;
            Optional <ProvisioningState>     provisioningState     = default;
            Optional <DateTimeOffset>        startTime             = default;
            Optional <string>                monitoringStatus      = default;
            Optional <ConnectionMonitorType> connectionMonitorType = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("id"))
                {
                    id = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("etag"))
                {
                    etag = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("location"))
                {
                    location = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    Dictionary <string, string> dictionary = new Dictionary <string, string>();
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        dictionary.Add(property0.Name, property0.Value.GetString());
                    }
                    tags = dictionary;
                    continue;
                }
                if (property.NameEquals("properties"))
                {
                    foreach (var property0 in property.Value.EnumerateObject())
                    {
                        if (property0.NameEquals("source"))
                        {
                            source = ConnectionMonitorSource.DeserializeConnectionMonitorSource(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("destination"))
                        {
                            destination = ConnectionMonitorDestination.DeserializeConnectionMonitorDestination(property0.Value);
                            continue;
                        }
                        if (property0.NameEquals("autoStart"))
                        {
                            autoStart = property0.Value.GetBoolean();
                            continue;
                        }
                        if (property0.NameEquals("monitoringIntervalInSeconds"))
                        {
                            monitoringIntervalInSeconds = property0.Value.GetInt32();
                            continue;
                        }
                        if (property0.NameEquals("endpoints"))
                        {
                            List <ConnectionMonitorEndpoint> array = new List <ConnectionMonitorEndpoint>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ConnectionMonitorEndpoint.DeserializeConnectionMonitorEndpoint(item));
                            }
                            endpoints = array;
                            continue;
                        }
                        if (property0.NameEquals("testConfigurations"))
                        {
                            List <ConnectionMonitorTestConfiguration> array = new List <ConnectionMonitorTestConfiguration>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ConnectionMonitorTestConfiguration.DeserializeConnectionMonitorTestConfiguration(item));
                            }
                            testConfigurations = array;
                            continue;
                        }
                        if (property0.NameEquals("testGroups"))
                        {
                            List <ConnectionMonitorTestGroup> array = new List <ConnectionMonitorTestGroup>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ConnectionMonitorTestGroup.DeserializeConnectionMonitorTestGroup(item));
                            }
                            testGroups = array;
                            continue;
                        }
                        if (property0.NameEquals("outputs"))
                        {
                            List <ConnectionMonitorOutput> array = new List <ConnectionMonitorOutput>();
                            foreach (var item in property0.Value.EnumerateArray())
                            {
                                array.Add(ConnectionMonitorOutput.DeserializeConnectionMonitorOutput(item));
                            }
                            outputs = array;
                            continue;
                        }
                        if (property0.NameEquals("notes"))
                        {
                            notes = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("provisioningState"))
                        {
                            provisioningState = new ProvisioningState(property0.Value.GetString());
                            continue;
                        }
                        if (property0.NameEquals("startTime"))
                        {
                            startTime = property0.Value.GetDateTimeOffset("O");
                            continue;
                        }
                        if (property0.NameEquals("monitoringStatus"))
                        {
                            monitoringStatus = property0.Value.GetString();
                            continue;
                        }
                        if (property0.NameEquals("connectionMonitorType"))
                        {
                            connectionMonitorType = new ConnectionMonitorType(property0.Value.GetString());
                            continue;
                        }
                    }
                    continue;
                }
            }
            return(new ConnectionMonitorResult(name.Value, id.Value, etag.Value, type.Value, location.Value, Optional.ToDictionary(tags), source.Value, destination.Value, Optional.ToNullable(autoStart), Optional.ToNullable(monitoringIntervalInSeconds), Optional.ToList(endpoints), Optional.ToList(testConfigurations), Optional.ToList(testGroups), Optional.ToList(outputs), notes.Value, Optional.ToNullable(provisioningState), Optional.ToNullable(startTime), monitoringStatus.Value, Optional.ToNullable(connectionMonitorType)));
        }