Beispiel #1
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"))
                {
                    provisioningState = new EndpointProvisioningState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("createdTime"))
                {
                    createdTime = property.Value.GetDateTimeOffset("O");
                    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;
                }
            }
            return(new EventGrid(endpointType, Optional.ToNullable(provisioningState), Optional.ToNullable(createdTime), Optional.ToDictionary(tags), topicEndpoint.Value, accessKey1, accessKey2));
        }
        internal static EventHub DeserializeEventHub(JsonElement element)
        {
            string       connectionStringPrimaryKey   = default;
            string       connectionStringSecondaryKey = 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("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"))
                {
                    provisioningState = new EndpointProvisioningState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("createdTime"))
                {
                    createdTime = property.Value.GetDateTimeOffset("O");
                    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;
                }
            }
            return(new EventHub(endpointType, Optional.ToNullable(provisioningState), Optional.ToNullable(createdTime), Optional.ToDictionary(tags), connectionStringPrimaryKey, connectionStringSecondaryKey));
        }
        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;
            Optional <EndpointProvisioningState>     provisioningState = default;
            Optional <DateTimeOffset>                createdTime       = default;
            Optional <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"))
                {
                    provisioningState = new EndpointProvisioningState(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("createdTime"))
                {
                    createdTime = property.Value.GetDateTimeOffset("O");
                    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;
                }
            }
            return(new DigitalTwinsEndpointResourceProperties(endpointType, Optional.ToNullable(provisioningState), Optional.ToNullable(createdTime), Optional.ToDictionary(tags)));
        }
Beispiel #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));
        }
        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));
        }
Beispiel #6
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));
        }