internal static AliasPath DeserializeAliasPath(JsonElement element) { Optional <string> path = default; Optional <IReadOnlyList <string> > apiVersions = default; Optional <AliasPattern> pattern = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("path")) { path = property.Value.GetString(); continue; } if (property.NameEquals("apiVersions")) { List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(item.GetString()); } apiVersions = array; continue; } if (property.NameEquals("pattern")) { pattern = AliasPattern.DeserializeAliasPattern(property.Value); continue; } } return(new AliasPath(path.Value, Optional.ToList(apiVersions), pattern.Value)); }
internal static Alias DeserializeAlias(JsonElement element) { Optional <string> name = default; Optional <IReadOnlyList <AliasPath> > paths = default; Optional <AliasType> type = default; Optional <string> defaultPath = default; Optional <AliasPattern> defaultPattern = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("name")) { name = property.Value.GetString(); continue; } if (property.NameEquals("paths")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } List <AliasPath> array = new List <AliasPath>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(AliasPath.DeserializeAliasPath(item)); } paths = array; continue; } if (property.NameEquals("type")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } type = property.Value.GetString().ToAliasType(); continue; } if (property.NameEquals("defaultPath")) { defaultPath = property.Value.GetString(); continue; } if (property.NameEquals("defaultPattern")) { if (property.Value.ValueKind == JsonValueKind.Null) { property.ThrowNonNullablePropertyIsNull(); continue; } defaultPattern = AliasPattern.DeserializeAliasPattern(property.Value); continue; } } return(new Alias(name.Value, Optional.ToList(paths), Optional.ToNullable(type), defaultPath.Value, defaultPattern.Value)); }
internal static AliasPath DeserializeAliasPath(JsonElement element) { string path = default; IReadOnlyList <string> apiVersions = default; AliasPattern pattern = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("path")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } path = property.Value.GetString(); continue; } if (property.NameEquals("apiVersions")) { 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()); } } apiVersions = array; continue; } if (property.NameEquals("pattern")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } pattern = AliasPattern.DeserializeAliasPattern(property.Value); continue; } } return(new AliasPath(path, apiVersions, pattern)); }
internal static Alias DeserializeAlias(JsonElement element) { string name = default; IReadOnlyList <AliasPath> paths = default; AliasType? type = default; string defaultPath = default; AliasPattern defaultPattern = 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("paths")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } List <AliasPath> array = new List <AliasPath>(); foreach (var item in property.Value.EnumerateArray()) { if (item.ValueKind == JsonValueKind.Null) { array.Add(null); } else { array.Add(AliasPath.DeserializeAliasPath(item)); } } paths = array; continue; } if (property.NameEquals("type")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } type = property.Value.GetString().ToAliasType(); continue; } if (property.NameEquals("defaultPath")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } defaultPath = property.Value.GetString(); continue; } if (property.NameEquals("defaultPattern")) { if (property.Value.ValueKind == JsonValueKind.Null) { continue; } defaultPattern = AliasPattern.DeserializeAliasPattern(property.Value); continue; } } return(new Alias(name, paths, type, defaultPath, defaultPattern)); }