| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | // <auto-generated/> |
| | 5 | |
|
| | 6 | | #nullable disable |
| | 7 | |
|
| | 8 | | using System.Collections.Generic; |
| | 9 | | using System.Text.Json; |
| | 10 | | using Azure.Core; |
| | 11 | |
|
| | 12 | | namespace Azure.ResourceManager.Storage.Models |
| | 13 | | { |
| | 14 | | public partial class CorsRule : IUtf8JsonSerializable |
| | 15 | | { |
| | 16 | | void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) |
| | 17 | | { |
| 24 | 18 | | writer.WriteStartObject(); |
| 24 | 19 | | writer.WritePropertyName("allowedOrigins"); |
| 24 | 20 | | writer.WriteStartArray(); |
| 128 | 21 | | foreach (var item in AllowedOrigins) |
| | 22 | | { |
| 40 | 23 | | writer.WriteStringValue(item); |
| | 24 | | } |
| 24 | 25 | | writer.WriteEndArray(); |
| 24 | 26 | | writer.WritePropertyName("allowedMethods"); |
| 24 | 27 | | writer.WriteStartArray(); |
| 208 | 28 | | foreach (var item in AllowedMethods) |
| | 29 | | { |
| 80 | 30 | | writer.WriteStringValue(item.ToString()); |
| | 31 | | } |
| 24 | 32 | | writer.WriteEndArray(); |
| 24 | 33 | | writer.WritePropertyName("maxAgeInSeconds"); |
| 24 | 34 | | writer.WriteNumberValue(MaxAgeInSeconds); |
| 24 | 35 | | writer.WritePropertyName("exposedHeaders"); |
| 24 | 36 | | writer.WriteStartArray(); |
| 128 | 37 | | foreach (var item in ExposedHeaders) |
| | 38 | | { |
| 40 | 39 | | writer.WriteStringValue(item); |
| | 40 | | } |
| 24 | 41 | | writer.WriteEndArray(); |
| 24 | 42 | | writer.WritePropertyName("allowedHeaders"); |
| 24 | 43 | | writer.WriteStartArray(); |
| 128 | 44 | | foreach (var item in AllowedHeaders) |
| | 45 | | { |
| 40 | 46 | | writer.WriteStringValue(item); |
| | 47 | | } |
| 24 | 48 | | writer.WriteEndArray(); |
| 24 | 49 | | writer.WriteEndObject(); |
| 24 | 50 | | } |
| | 51 | |
|
| | 52 | | internal static CorsRule DeserializeCorsRule(JsonElement element) |
| | 53 | | { |
| 48 | 54 | | IList<string> allowedOrigins = default; |
| 48 | 55 | | IList<CorsRuleAllowedMethodsItem> allowedMethods = default; |
| 48 | 56 | | int maxAgeInSeconds = default; |
| 48 | 57 | | IList<string> exposedHeaders = default; |
| 48 | 58 | | IList<string> allowedHeaders = default; |
| 576 | 59 | | foreach (var property in element.EnumerateObject()) |
| | 60 | | { |
| 240 | 61 | | if (property.NameEquals("allowedOrigins")) |
| | 62 | | { |
| 48 | 63 | | List<string> array = new List<string>(); |
| 256 | 64 | | foreach (var item in property.Value.EnumerateArray()) |
| | 65 | | { |
| 80 | 66 | | if (item.ValueKind == JsonValueKind.Null) |
| | 67 | | { |
| 0 | 68 | | array.Add(null); |
| | 69 | | } |
| | 70 | | else |
| | 71 | | { |
| 80 | 72 | | array.Add(item.GetString()); |
| | 73 | | } |
| | 74 | | } |
| 48 | 75 | | allowedOrigins = array; |
| 48 | 76 | | continue; |
| | 77 | | } |
| 192 | 78 | | if (property.NameEquals("allowedMethods")) |
| | 79 | | { |
| 48 | 80 | | List<CorsRuleAllowedMethodsItem> array = new List<CorsRuleAllowedMethodsItem>(); |
| 416 | 81 | | foreach (var item in property.Value.EnumerateArray()) |
| | 82 | | { |
| 160 | 83 | | array.Add(new CorsRuleAllowedMethodsItem(item.GetString())); |
| | 84 | | } |
| 48 | 85 | | allowedMethods = array; |
| 48 | 86 | | continue; |
| | 87 | | } |
| 144 | 88 | | if (property.NameEquals("maxAgeInSeconds")) |
| | 89 | | { |
| 48 | 90 | | maxAgeInSeconds = property.Value.GetInt32(); |
| 48 | 91 | | continue; |
| | 92 | | } |
| 96 | 93 | | if (property.NameEquals("exposedHeaders")) |
| | 94 | | { |
| 48 | 95 | | List<string> array = new List<string>(); |
| 256 | 96 | | foreach (var item in property.Value.EnumerateArray()) |
| | 97 | | { |
| 80 | 98 | | if (item.ValueKind == JsonValueKind.Null) |
| | 99 | | { |
| 0 | 100 | | array.Add(null); |
| | 101 | | } |
| | 102 | | else |
| | 103 | | { |
| 80 | 104 | | array.Add(item.GetString()); |
| | 105 | | } |
| | 106 | | } |
| 48 | 107 | | exposedHeaders = array; |
| 48 | 108 | | continue; |
| | 109 | | } |
| 48 | 110 | | if (property.NameEquals("allowedHeaders")) |
| | 111 | | { |
| 48 | 112 | | List<string> array = new List<string>(); |
| 256 | 113 | | foreach (var item in property.Value.EnumerateArray()) |
| | 114 | | { |
| 80 | 115 | | if (item.ValueKind == JsonValueKind.Null) |
| | 116 | | { |
| 0 | 117 | | array.Add(null); |
| | 118 | | } |
| | 119 | | else |
| | 120 | | { |
| 80 | 121 | | array.Add(item.GetString()); |
| | 122 | | } |
| | 123 | | } |
| 48 | 124 | | allowedHeaders = array; |
| | 125 | | continue; |
| | 126 | | } |
| | 127 | | } |
| 48 | 128 | | return new CorsRule(allowedOrigins, allowedMethods, maxAgeInSeconds, exposedHeaders, allowedHeaders); |
| | 129 | | } |
| | 130 | | } |
| | 131 | | } |