internal static EffectiveNetworkSecurityRule DeserializeEffectiveNetworkSecurityRule(JsonElement element) { string name = default; EffectiveSecurityRuleProtocol?protocol = default; string sourcePortRange = default; string destinationPortRange = default; IReadOnlyList <string> sourcePortRanges = default; IReadOnlyList <string> destinationPortRanges = default; string sourceAddressPrefix = default; string destinationAddressPrefix = default; IReadOnlyList <string> sourceAddressPrefixes = default; IReadOnlyList <string> destinationAddressPrefixes = default; IReadOnlyList <string> expandedSourceAddressPrefix = default; IReadOnlyList <string> expandedDestinationAddressPrefix = default; SecurityRuleAccess? access = default; int?priority = default; SecurityRuleDirection?direction = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } name = property.Value.GetString(); continue; } if (property.NameEquals("protocol")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } protocol = new EffectiveSecurityRuleProtocol(property.Value.GetString()); continue; } if (property.NameEquals("sourcePortRange")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } sourcePortRange = property.Value.GetString(); continue; } if (property.NameEquals("destinationPortRange")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } destinationPortRange = property.Value.GetString(); continue; } if (property.NameEquals("sourcePortRanges")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(item.GetString()); } } sourcePortRanges = array; continue; } if (property.NameEquals("destinationPortRanges")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(item.GetString()); } } destinationPortRanges = array; continue; } if (property.NameEquals("sourceAddressPrefix")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } sourceAddressPrefix = property.Value.GetString(); continue; } if (property.NameEquals("destinationAddressPrefix")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } destinationAddressPrefix = property.Value.GetString(); continue; } if (property.NameEquals("sourceAddressPrefixes")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(item.GetString()); } } sourceAddressPrefixes = array; continue; } if (property.NameEquals("destinationAddressPrefixes")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(item.GetString()); } } destinationAddressPrefixes = array; continue; } if (property.NameEquals("expandedSourceAddressPrefix")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(item.GetString()); } } expandedSourceAddressPrefix = array; continue; } if (property.NameEquals("expandedDestinationAddressPrefix")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(item.GetString()); } } expandedDestinationAddressPrefix = array; continue; } if (property.NameEquals("access")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } access = new SecurityRuleAccess(property.Value.GetString()); continue; } if (property.NameEquals("priority")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } priority = property.Value.GetInt32(); continue; } if (property.NameEquals("direction")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } direction = new SecurityRuleDirection(property.Value.GetString()); continue; } } return(new EffectiveNetworkSecurityRule(name, protocol, sourcePortRange, destinationPortRange, sourcePortRanges, destinationPortRanges, sourceAddressPrefix, destinationAddressPrefix, sourceAddressPrefixes, destinationAddressPrefixes, expandedSourceAddressPrefix, expandedDestinationAddressPrefix, access, priority, direction)); }
internal static SecurityRule DeserializeSecurityRule(JsonElement element) { string name = default; string etag = default; string id = default; string description = default; SecurityRuleProtocol?protocol = default; string sourcePortRange = default; string destinationPortRange = default; string sourceAddressPrefix = default; IList <string> sourceAddressPrefixes = default; IList <ApplicationSecurityGroup> sourceApplicationSecurityGroups = default; string destinationAddressPrefix = default; IList <string> destinationAddressPrefixes = default; IList <ApplicationSecurityGroup> destinationApplicationSecurityGroups = default; IList <string> sourcePortRanges = default; IList <string> destinationPortRanges = default; SecurityRuleAccess?access = default; int?priority = default; SecurityRuleDirection?direction = default; ProvisioningState? provisioningState = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } name = property.Value.GetString(); continue; } if (property.NameEquals("etag")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } etag = property.Value.GetString(); continue; } if (property.NameEquals("id")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } id = property.Value.GetString(); continue; } if (property.NameEquals("properties")) { foreach (var property0 in property.Value.EnumerateObject()) { if (property0.NameEquals("description")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } description = property0.Value.GetString(); continue; } if (property0.NameEquals("protocol")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } protocol = new SecurityRuleProtocol(property0.Value.GetString()); continue; } if (property0.NameEquals("sourcePortRange")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } sourcePortRange = property0.Value.GetString(); continue; } if (property0.NameEquals("destinationPortRange")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } destinationPortRange = property0.Value.GetString(); continue; } if (property0.NameEquals("sourceAddressPrefix")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } sourceAddressPrefix = property0.Value.GetString(); continue; } if (property0.NameEquals("sourceAddressPrefixes")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } List <string> array = new List <string>(); foreach (var item in property0.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(item.GetString()); } } sourceAddressPrefixes = array; continue; } if (property0.NameEquals("sourceApplicationSecurityGroups")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } List <ApplicationSecurityGroup> array = new List <ApplicationSecurityGroup>(); foreach (var item in property0.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(ApplicationSecurityGroup.DeserializeApplicationSecurityGroup(item)); } } sourceApplicationSecurityGroups = array; continue; } if (property0.NameEquals("destinationAddressPrefix")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } destinationAddressPrefix = property0.Value.GetString(); continue; } if (property0.NameEquals("destinationAddressPrefixes")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } List <string> array = new List <string>(); foreach (var item in property0.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(item.GetString()); } } destinationAddressPrefixes = array; continue; } if (property0.NameEquals("destinationApplicationSecurityGroups")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } List <ApplicationSecurityGroup> array = new List <ApplicationSecurityGroup>(); foreach (var item in property0.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(ApplicationSecurityGroup.DeserializeApplicationSecurityGroup(item)); } } destinationApplicationSecurityGroups = array; continue; } if (property0.NameEquals("sourcePortRanges")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } List <string> array = new List <string>(); foreach (var item in property0.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(item.GetString()); } } sourcePortRanges = array; continue; } if (property0.NameEquals("destinationPortRanges")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } List <string> array = new List <string>(); foreach (var item in property0.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(item.GetString()); } } destinationPortRanges = array; continue; } if (property0.NameEquals("access")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } access = new SecurityRuleAccess(property0.Value.GetString()); continue; } if (property0.NameEquals("priority")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } priority = property0.Value.GetInt32(); continue; } if (property0.NameEquals("direction")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } direction = new SecurityRuleDirection(property0.Value.GetString()); continue; } if (property0.NameEquals("provisioningState")) { if (property0.Value.ValueKind == JsonValueKind.Null) { continue; } provisioningState = new ProvisioningState(property0.Value.GetString()); continue; } } continue; } } return(new SecurityRule(id, name, etag, description, protocol, sourcePortRange, destinationPortRange, sourceAddressPrefix, sourceAddressPrefixes, sourceApplicationSecurityGroups, destinationAddressPrefix, destinationAddressPrefixes, destinationApplicationSecurityGroups, sourcePortRanges, destinationPortRanges, access, priority, direction, provisioningState)); }