internal static UnsecuredEndpoint DeserializeUnsecuredEndpoint(JsonElement element)
        {
            string type = default;
            Optional <CredentialsBase> credentials = default;
            string url = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("@type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("credentials"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    credentials = CredentialsBase.DeserializeCredentialsBase(property.Value);
                    continue;
                }
                if (property.NameEquals("url"))
                {
                    url = property.Value.GetString();
                    continue;
                }
            }
            return(new UnsecuredEndpoint(type, credentials.Value, url));
        }
        internal static IotHubDeviceConnection DeserializeIotHubDeviceConnection(JsonElement element)
        {
            string deviceId = default;
            Optional <CredentialsBase> credentials = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("deviceId"))
                {
                    deviceId = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("credentials"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    credentials = CredentialsBase.DeserializeCredentialsBase(property.Value);
                    continue;
                }
            }
            return(new IotHubDeviceConnection(deviceId, credentials.Value));
        }
Ejemplo n.º 3
0
        internal static TlsEndpoint DeserializeTlsEndpoint(JsonElement element)
        {
            Optional <CertificateSource>    trustedCertificates = default;
            Optional <TlsValidationOptions> validationOptions   = default;
            string type = default;
            Optional <CredentialsBase> credentials = default;
            string url = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("trustedCertificates"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    trustedCertificates = CertificateSource.DeserializeCertificateSource(property.Value);
                    continue;
                }
                if (property.NameEquals("validationOptions"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    validationOptions = TlsValidationOptions.DeserializeTlsValidationOptions(property.Value);
                    continue;
                }
                if (property.NameEquals("@type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("credentials"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    credentials = CredentialsBase.DeserializeCredentialsBase(property.Value);
                    continue;
                }
                if (property.NameEquals("url"))
                {
                    url = property.Value.GetString();
                    continue;
                }
            }
            return(new TlsEndpoint(type, credentials.Value, url, trustedCertificates.Value, validationOptions.Value));
        }
        internal static EndpointBase DeserializeEndpointBase(JsonElement element)
        {
            if (element.TryGetProperty("@type", out JsonElement discriminator))
            {
                switch (discriminator.GetString())
                {
                case "#Microsoft.VideoAnalyzer.TlsEndpoint": return(TlsEndpoint.DeserializeTlsEndpoint(element));

                case "#Microsoft.VideoAnalyzer.UnsecuredEndpoint": return(UnsecuredEndpoint.DeserializeUnsecuredEndpoint(element));
                }
            }
            string type = default;
            Optional <CredentialsBase> credentials = default;
            string url = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("@type"))
                {
                    type = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("credentials"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    credentials = CredentialsBase.DeserializeCredentialsBase(property.Value);
                    continue;
                }
                if (property.NameEquals("url"))
                {
                    url = property.Value.GetString();
                    continue;
                }
            }
            return(new EndpointBase(type, credentials.Value, url));
        }
 internal UnsecuredEndpoint(string type, CredentialsBase credentials, string url) : base(type, credentials, url)
 {
     Type = type ?? "#Microsoft.VideoAnalyzer.UnsecuredEndpoint";
 }
Ejemplo n.º 6
0
 internal EndpointBase(string type, CredentialsBase credentials, string url)
 {
     Type        = type;
     Credentials = credentials;
     Url         = url;
 }
Ejemplo n.º 7
0
 internal TlsEndpoint(string type, CredentialsBase credentials, string url, CertificateSource trustedCertificates, TlsValidationOptions validationOptions) : base(type, credentials, url)
 {
     TrustedCertificates = trustedCertificates;
     ValidationOptions   = validationOptions;
     Type = type ?? "#Microsoft.VideoAnalyzer.TlsEndpoint";
 }
 internal IotHubDeviceConnection(string deviceId, CredentialsBase credentials)
 {
     DeviceId    = deviceId;
     Credentials = credentials;
 }