void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     writer.WritePropertyName("connectionString-PrimaryKey");
     writer.WriteStringValue(ConnectionStringPrimaryKey);
     writer.WritePropertyName("connectionString-SecondaryKey");
     writer.WriteStringValue(ConnectionStringSecondaryKey);
     writer.WritePropertyName("endpointType");
     writer.WriteStringValue(EndpointType.ToString());
     if (Optional.IsCollectionDefined(Tags))
     {
         writer.WritePropertyName("tags");
         writer.WriteStartObject();
         foreach (var item in Tags)
         {
             writer.WritePropertyName(item.Key);
             writer.WriteStringValue(item.Value);
         }
         writer.WriteEndObject();
     }
     writer.WriteEndObject();
 }
 void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 {
     writer.WriteStartObject();
     if (TopicEndpoint != null)
     {
         writer.WritePropertyName("TopicEndpoint");
         writer.WriteStringValue(TopicEndpoint);
     }
     writer.WritePropertyName("accessKey1");
     writer.WriteStringValue(AccessKey1);
     writer.WritePropertyName("accessKey2");
     writer.WriteStringValue(AccessKey2);
     writer.WritePropertyName("endpointType");
     writer.WriteStringValue(EndpointType.ToString());
     if (ProvisioningState != null)
     {
         writer.WritePropertyName("provisioningState");
         writer.WriteStringValue(ProvisioningState.Value.ToString());
     }
     if (CreatedTime != null)
     {
         writer.WritePropertyName("createdTime");
         writer.WriteStringValue(CreatedTime.Value, "O");
     }
     if (Tags != null)
     {
         writer.WritePropertyName("tags");
         writer.WriteStartObject();
         foreach (var item in Tags)
         {
             writer.WritePropertyName(item.Key);
             writer.WriteStringValue(item.Value);
         }
         writer.WriteEndObject();
     }
     writer.WriteEndObject();
 }
        internal static DigitalTwinsEndpointResourceProperties DeserializeDigitalTwinsEndpointResourceProperties(JsonElement element)
        {
            if (element.TryGetProperty("endpointType", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "EventGrid": return(EventGrid.DeserializeEventGrid(element));

                case "EventHub": return(EventHub.DeserializeEventHub(element));

                case "ServiceBus": return(ServiceBus.DeserializeServiceBus(element));
                }
            }
            EndpointType endpointType = default;
            EndpointProvisioningState?   provisioningState = default;
            DateTimeOffset?              createdTime       = default;
            IDictionary <string, string> tags = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("endpointType"))
                {
                    endpointType = new EndpointType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("provisioningState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    provisioningState = new EndpointProvisioningState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("createdTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    createdTime = property.Value.GetDateTimeOffset("O");
                    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;
                }
            }
            return(new DigitalTwinsEndpointResourceProperties(endpointType, provisioningState, createdTime, tags));
        }
Пример #4
0
        internal static EventHub DeserializeEventHub(JsonElement element)
        {
            string       connectionStringPrimaryKey   = default;
            string       connectionStringSecondaryKey = default;
            EndpointType endpointType = default;
            EndpointProvisioningState?   provisioningState = default;
            DateTimeOffset?              createdTime       = default;
            IDictionary <string, string> tags = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("connectionString-PrimaryKey"))
                {
                    connectionStringPrimaryKey = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("connectionString-SecondaryKey"))
                {
                    connectionStringSecondaryKey = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("endpointType"))
                {
                    endpointType = new EndpointType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("provisioningState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    provisioningState = new EndpointProvisioningState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("createdTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    createdTime = property.Value.GetDateTimeOffset("O");
                    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;
                }
            }
            return(new EventHub(endpointType, provisioningState, createdTime, tags, connectionStringPrimaryKey, connectionStringSecondaryKey));
        }
Пример #5
0
        internal static EventGrid DeserializeEventGrid(JsonElement element)
        {
            Optional <string> topicEndpoint = default;
            string            accessKey1    = default;
            string            accessKey2    = default;
            EndpointType      endpointType  = default;
            Optional <EndpointProvisioningState>     provisioningState = default;
            Optional <DateTimeOffset>                createdTime       = default;
            Optional <IDictionary <string, string> > tags = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("TopicEndpoint"))
                {
                    topicEndpoint = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("accessKey1"))
                {
                    accessKey1 = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("accessKey2"))
                {
                    accessKey2 = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("endpointType"))
                {
                    endpointType = new EndpointType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("provisioningState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    provisioningState = new EndpointProvisioningState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("createdTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    createdTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    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;
                }
            }
            return(new EventGrid(endpointType, Optional.ToNullable(provisioningState), Optional.ToNullable(createdTime), Optional.ToDictionary(tags), topicEndpoint.Value, accessKey1, accessKey2));
        }
Пример #6
0
 internal ServiceBus(EndpointType endpointType, EndpointProvisioningState?provisioningState, DateTimeOffset?createdTime, IDictionary <string, string> tags, string primaryConnectionString, string secondaryConnectionString) : base(endpointType, provisioningState, createdTime, tags)
 {
     PrimaryConnectionString   = primaryConnectionString;
     SecondaryConnectionString = secondaryConnectionString;
     EndpointType = endpointType;
 }
Пример #7
0
 internal EventHub(EndpointType endpointType, EndpointProvisioningState?provisioningState, DateTimeOffset?createdTime, IDictionary <string, string> tags, string connectionStringPrimaryKey, string connectionStringSecondaryKey) : base(endpointType, provisioningState, createdTime, tags)
 {
     ConnectionStringPrimaryKey   = connectionStringPrimaryKey;
     ConnectionStringSecondaryKey = connectionStringSecondaryKey;
     EndpointType = endpointType;
 }
        internal static EventGrid DeserializeEventGrid(JsonElement element)
        {
            string       topicEndpoint = default;
            string       accessKey1    = default;
            string       accessKey2    = default;
            EndpointType endpointType  = default;
            EndpointProvisioningState?   provisioningState = default;
            DateTimeOffset?              createdTime       = default;
            IDictionary <string, string> tags = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("TopicEndpoint"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    topicEndpoint = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("accessKey1"))
                {
                    accessKey1 = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("accessKey2"))
                {
                    accessKey2 = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("endpointType"))
                {
                    endpointType = new EndpointType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("provisioningState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    provisioningState = new EndpointProvisioningState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("createdTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        continue;
                    }
                    createdTime = property.Value.GetDateTimeOffset("O");
                    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;
                }
            }
            return(new EventGrid(endpointType, provisioningState, createdTime, tags, topicEndpoint, accessKey1, accessKey2));
        }
Пример #9
0
        internal static ServiceBus DeserializeServiceBus(JsonElement element)
        {
            string       primaryConnectionString   = default;
            string       secondaryConnectionString = default;
            EndpointType endpointType = default;
            Optional <EndpointProvisioningState>     provisioningState = default;
            Optional <DateTimeOffset>                createdTime       = default;
            Optional <IDictionary <string, string> > tags = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("primaryConnectionString"))
                {
                    primaryConnectionString = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("secondaryConnectionString"))
                {
                    secondaryConnectionString = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("endpointType"))
                {
                    endpointType = new EndpointType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("provisioningState"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    provisioningState = new EndpointProvisioningState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("createdTime"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    createdTime = property.Value.GetDateTimeOffset("O");
                    continue;
                }
                if (property.NameEquals("tags"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    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;
                }
            }
            return(new ServiceBus(endpointType, Optional.ToNullable(provisioningState), Optional.ToNullable(createdTime), Optional.ToDictionary(tags), primaryConnectionString, secondaryConnectionString));
        }