コード例 #1
0
 internal ConnectionMonitorEndpoint(string name, EndpointType?endpointType, ResourceIdentifier resourceId, string address, ConnectionMonitorEndpointFilter filter, ConnectionMonitorEndpointScope scope, CoverageLevel?coverageLevel)
 {
     Name          = name;
     EndpointType  = endpointType;
     ResourceId    = resourceId;
     Address       = address;
     Filter        = filter;
     Scope         = scope;
     CoverageLevel = coverageLevel;
 }
        internal static ConnectionMonitorEndpoint DeserializeConnectionMonitorEndpoint(JsonElement element)
        {
            string name = default;
            Optional <EndpointType> type       = default;
            Optional <string>       resourceId = default;
            Optional <string>       address    = default;
            Optional <ConnectionMonitorEndpointFilter> filter = default;
            Optional <ConnectionMonitorEndpointScope>  scope  = default;
            Optional <CoverageLevel> coverageLevel            = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("type"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    type = new EndpointType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("resourceId"))
                {
                    resourceId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("address"))
                {
                    address = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("filter"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    filter = ConnectionMonitorEndpointFilter.DeserializeConnectionMonitorEndpointFilter(property.Value);
                    continue;
                }
                if (property.NameEquals("scope"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    scope = ConnectionMonitorEndpointScope.DeserializeConnectionMonitorEndpointScope(property.Value);
                    continue;
                }
                if (property.NameEquals("coverageLevel"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    coverageLevel = new CoverageLevel(property.Value.GetString());
                    continue;
                }
            }
            return(new ConnectionMonitorEndpoint(name, Optional.ToNullable(type), resourceId.Value, address.Value, filter.Value, scope.Value, Optional.ToNullable(coverageLevel)));
        }