Esempio n. 1
0
        public string ToUrl(SubFloat?shiftedMinValue = null)
        {
            var str = new StringBuilder();

            if (!CustomUrl.IsEmpty())
            {
                str.Append(CustomUrl);
                if (MinPrice.HasValue && MinPrice.Value != 0)
                {
                    str.Append("&");
                    str.Append(_minPrice);
                    str.Append("=");
                    str.Append(MinPrice);
                }

                if (MaxPrice.HasValue && MaxPrice.Value != 0)
                {
                    str.Append("&");
                    str.Append(_maxPrice);
                    str.Append("=");
                    str.Append(MaxPrice);
                }
            }
            else
            {
                str.Append(@"https://www.aliexpress.com/wholesale?site=glo&tc=af&g=y");
                //var str = new StringBuilder(@"https://www.aliexpress.com/wholesale?tc=af&g=y");
                foreach (var prop in GetType().GetProperties())
                {
                    var attrs = prop.GetCustomAttributes(typeof(NameAttribute), false);
                    if (attrs.Length < 1)
                    {
                        continue;
                    }
                    var attr = attrs[0] as NameAttribute;
                    str.Append("&");
                    str.Append(attr.Name);
                    str.Append("=");
                    object value;

                    if (shiftedMinValue != null && attr.Name.IsEqual(_minPrice))
                    {
                        value = shiftedMinValue;
                    }
                    else
                    {
                        value = prop.GetValue(this);
                    }
                    str.Append(value.ToStringNull());
                }
                str.Append("&page=");
            }

            currentUrl = str.ToString();
            return(currentUrl);
        }
Esempio n. 2
0
 public string SetUrlPage(int pageNumber)
 {
     if (currentUrl.IsEmpty())
     {
         ToUrl();
     }
     if (!CustomUrl.IsEmpty())
     {
         return(currentUrl.ReplaceBetween("{", "}", pageNumber));
     }
     else
     {
         return(currentUrl + pageNumber);
     }
 }