internal static FaultInjectionProperties DeserializeFaultInjectionProperties(JsonElement element)
        {
            Optional <string> iotHubName = default;
            Optional <FaultInjectionConnectionProperties> connection = default;
            Optional <DateTimeOffset> lastUpdatedTimeUtc             = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("IotHubName"))
                {
                    iotHubName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("connection"))
                {
                    connection = FaultInjectionConnectionProperties.DeserializeFaultInjectionConnectionProperties(property.Value);
                    continue;
                }
                if (property.NameEquals("lastUpdatedTimeUtc"))
                {
                    lastUpdatedTimeUtc = property.Value.GetDateTimeOffset("O");
                    continue;
                }
            }
            return(new FaultInjectionProperties(iotHubName.Value, connection.Value, Optional.ToNullable(lastUpdatedTimeUtc)));
        }
Пример #2
0
        internal static FaultInjectionProperties DeserializeFaultInjectionProperties(JsonElement element)
        {
            string iotHubName = default;
            FaultInjectionConnectionProperties connection = default;
            DateTimeOffset?lastUpdatedTimeUtc             = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("IotHubName"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    iotHubName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("connection"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    connection = FaultInjectionConnectionProperties.DeserializeFaultInjectionConnectionProperties(property.Value);
                    continue;
                }
                if (property.NameEquals("lastUpdatedTimeUtc"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    lastUpdatedTimeUtc = property.Value.GetDateTimeOffset("O");
                    continue;
                }
            }
            return(new FaultInjectionProperties(iotHubName, connection, lastUpdatedTimeUtc));
        }
 internal FaultInjectionProperties(string iotHubName, FaultInjectionConnectionProperties connection, DateTimeOffset?lastUpdatedTimeUtc)
 {
     IotHubName         = iotHubName;
     Connection         = connection;
     LastUpdatedTimeUtc = lastUpdatedTimeUtc;
 }