示例#1
0
        internal static ConnectionMonitorTestConfiguration DeserializeConnectionMonitorTestConfiguration(JsonElement element)
        {
            string         name             = default;
            Optional <int> testFrequencySec = default;
            ConnectionMonitorTestConfigurationProtocol protocol             = default;
            Optional <PreferredIPVersion> preferredIPVersion                = default;
            Optional <ConnectionMonitorHttpConfiguration> httpConfiguration = default;
            Optional <ConnectionMonitorTcpConfiguration>  tcpConfiguration  = default;
            Optional <ConnectionMonitorIcmpConfiguration> icmpConfiguration = default;
            Optional <ConnectionMonitorSuccessThreshold>  successThreshold  = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("testFrequencySec"))
                {
                    testFrequencySec = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("protocol"))
                {
                    protocol = new ConnectionMonitorTestConfigurationProtocol(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("preferredIPVersion"))
                {
                    preferredIPVersion = new PreferredIPVersion(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("httpConfiguration"))
                {
                    httpConfiguration = ConnectionMonitorHttpConfiguration.DeserializeConnectionMonitorHttpConfiguration(property.Value);
                    continue;
                }
                if (property.NameEquals("tcpConfiguration"))
                {
                    tcpConfiguration = ConnectionMonitorTcpConfiguration.DeserializeConnectionMonitorTcpConfiguration(property.Value);
                    continue;
                }
                if (property.NameEquals("icmpConfiguration"))
                {
                    icmpConfiguration = ConnectionMonitorIcmpConfiguration.DeserializeConnectionMonitorIcmpConfiguration(property.Value);
                    continue;
                }
                if (property.NameEquals("successThreshold"))
                {
                    successThreshold = ConnectionMonitorSuccessThreshold.DeserializeConnectionMonitorSuccessThreshold(property.Value);
                    continue;
                }
            }
            return(new ConnectionMonitorTestConfiguration(name, Optional.ToNullable(testFrequencySec), protocol, Optional.ToNullable(preferredIPVersion), httpConfiguration.Value, tcpConfiguration.Value, icmpConfiguration.Value, successThreshold.Value));
        }
 internal ConnectionMonitorTestConfiguration(string name, int?testFrequencySec, ConnectionMonitorTestConfigurationProtocol protocol, PreferredIPVersion?preferredIPVersion, ConnectionMonitorHttpConfiguration httpConfiguration, ConnectionMonitorTcpConfiguration tcpConfiguration, ConnectionMonitorIcmpConfiguration icmpConfiguration, ConnectionMonitorSuccessThreshold successThreshold)
 {
     Name               = name;
     TestFrequencySec   = testFrequencySec;
     Protocol           = protocol;
     PreferredIPVersion = preferredIPVersion;
     HttpConfiguration  = httpConfiguration;
     TcpConfiguration   = tcpConfiguration;
     IcmpConfiguration  = icmpConfiguration;
     SuccessThreshold   = successThreshold;
 }
示例#3
0
        internal static ConnectionMonitorTestConfiguration DeserializeConnectionMonitorTestConfiguration(JsonElement element)
        {
            string name             = default;
            int?   testFrequencySec = default;
            ConnectionMonitorTestConfigurationProtocol protocol = default;
            PreferredIPVersion?preferredIPVersion = default;
            ConnectionMonitorHttpConfiguration httpConfiguration = default;
            ConnectionMonitorTcpConfiguration  tcpConfiguration  = default;
            ConnectionMonitorIcmpConfiguration icmpConfiguration = default;
            ConnectionMonitorSuccessThreshold  successThreshold  = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("testFrequencySec"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    testFrequencySec = property.Value.GetInt32();
                    continue;
                }
                if (property.NameEquals("protocol"))
                {
                    protocol = new ConnectionMonitorTestConfigurationProtocol(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("preferredIPVersion"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    preferredIPVersion = new PreferredIPVersion(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("httpConfiguration"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    httpConfiguration = ConnectionMonitorHttpConfiguration.DeserializeConnectionMonitorHttpConfiguration(property.Value);
                    continue;
                }
                if (property.NameEquals("tcpConfiguration"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    tcpConfiguration = ConnectionMonitorTcpConfiguration.DeserializeConnectionMonitorTcpConfiguration(property.Value);
                    continue;
                }
                if (property.NameEquals("icmpConfiguration"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    icmpConfiguration = ConnectionMonitorIcmpConfiguration.DeserializeConnectionMonitorIcmpConfiguration(property.Value);
                    continue;
                }
                if (property.NameEquals("successThreshold"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    successThreshold = ConnectionMonitorSuccessThreshold.DeserializeConnectionMonitorSuccessThreshold(property.Value);
                    continue;
                }
            }
            return(new ConnectionMonitorTestConfiguration(name, testFrequencySec, protocol, preferredIPVersion, httpConfiguration, tcpConfiguration, icmpConfiguration, successThreshold));
        }