internal static SqlConnection DeserializeSqlConnection(JsonElement element)
        {
            SqlConnectionType            type = default;
            string                       name = default;
            IDictionary <string, object> additionalProperties           = default;
            Dictionary <string, object>  additionalPropertiesDictionary = default;

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("type"))
                {
                    type = new SqlConnectionType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                additionalPropertiesDictionary ??= new Dictionary <string, object>();
                if (property.Value.ValueKind == JsonValueKind.Null)
                {
                    additionalPropertiesDictionary.Add(property.Name, null);
                }
                else
                {
                    additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject());
                }
            }
            additionalProperties = additionalPropertiesDictionary;
            return(new SqlConnection(type, name, additionalProperties));
        }
Beispiel #2
0
        public SqlConnection(SqlConnectionType type, string name)
        {
            if (name == null)
            {
                throw new ArgumentNullException(nameof(name));
            }

            Type = type;
            Name = name;
            AdditionalProperties = new ChangeTrackingDictionary <string, object>();
        }
        internal static SqlConnection DeserializeSqlConnection(JsonElement element)
        {
            Optional <SqlConnectionType> type                           = default;
            Optional <string>            name                           = default;
            Optional <string>            poolName                       = default;
            Optional <string>            databaseName                   = default;
            IDictionary <string, object> additionalProperties           = default;
            Dictionary <string, object>  additionalPropertiesDictionary = new Dictionary <string, object>();

            foreach (var property in element.EnumerateObject())
            {
                if (property.NameEquals("type"))
                {
                    if (property.Value.ValueKind == JsonValueKind.Null)
                    {
                        property.ThrowNonNullablePropertyIsNull();
                        continue;
                    }
                    type = new SqlConnectionType(property.Value.GetString());
                    continue;
                }
                if (property.NameEquals("name"))
                {
                    name = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("poolName"))
                {
                    poolName = property.Value.GetString();
                    continue;
                }
                if (property.NameEquals("databaseName"))
                {
                    databaseName = property.Value.GetString();
                    continue;
                }
                additionalPropertiesDictionary.Add(property.Name, property.Value.GetObject());
            }
            additionalProperties = additionalPropertiesDictionary;
            return(new SqlConnection(Optional.ToNullable(type), name.Value, poolName.Value, databaseName.Value, additionalProperties));
        }
Beispiel #4
0
 internal SqlConnection(SqlConnectionType type, string name, IDictionary <string, object> additionalProperties)
 {
     Type = type;
     Name = name;
     AdditionalProperties = additionalProperties;
 }