Пример #1
0
        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));
        }
Пример #2
0
        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();
        }
Пример #3
0
 public static string ToSerialString(this GeoFilterAction value) => value switch
 {
Пример #4
0
 internal GeoFilter(string relativePath, GeoFilterAction action, IList <string> countryCodes)
 {
     RelativePath = relativePath;
     Action       = action;
     CountryCodes = countryCodes;
 }