internal static GeoFilter DeserializeGeoFilter(JsonElement element) { string relativePath = default; GeoFilterAction action = default; IList <string> countryCodes = default; foreach (var property in element.EnumerateObject()) { if (property.NameEquals("relativePath")) { relativePath = property.Value.GetString(); continue; } if (property.NameEquals("action")) { action = property.Value.GetString().ToGeoFilterAction(); continue; } if (property.NameEquals("countryCodes")) { List <string> array = new List <string>(); foreach (var item in property.Value.EnumerateArray()) { array.Add(item.GetString()); } countryCodes = array; continue; } } return(new GeoFilter(relativePath, action, countryCodes)); }
public GeoFilter(string relativePath, GeoFilterAction action, IEnumerable <string> countryCodes) { if (relativePath == null) { throw new ArgumentNullException(nameof(relativePath)); } if (countryCodes == null) { throw new ArgumentNullException(nameof(countryCodes)); } RelativePath = relativePath; Action = action; CountryCodes = countryCodes.ToList(); }
public static string ToSerialString(this GeoFilterAction value) => value switch {
internal GeoFilter(string relativePath, GeoFilterAction action, IList <string> countryCodes) { RelativePath = relativePath; Action = action; CountryCodes = countryCodes; }