Exemplo n.º 1
0
 public static void ParseRouteValue <T>(RouteValueDictionary requestValues, RouteValueDictionary values, string key, out T value, T defalutValue)
 {
     if (RouteHepler.IsRequestRouteValue(values, key))
     {
         RouteHepler.TryGetRouteValue <T>(requestValues, key, out value, defalutValue);
     }
     else
     {
         RouteHepler.TryGetRouteValue <T>(values, key, out value, defalutValue);
     }
 }
Exemplo n.º 2
0
        public static string GeneratParamUrl(RouteValueDictionary requestValues, RouteValueDictionary values)
        {
            StringBuilder path = new StringBuilder();

            ItemSort itemSort = ItemSort.Ignore;

            RouteHepler.ParseRouteValue <ItemSort>(requestValues, values, "sort", out itemSort, itemSort);
            switch (itemSort)
            {
            case ItemSort.AboutBaby:
                path.Append("aboutbaby");
                break;

            case ItemSort.AboutMother:
                path.Append("Aboutmother");
                break;

            default:
                break;
            }
            ItemType itemType = ItemType.Ignore;

            RouteHepler.ParseRouteValue <ItemType>(requestValues, values, "category", out itemType, itemType);
            switch (itemType)
            {
            case ItemType.Clothes:
                path.Append("-clothes");
                break;

            case ItemType.Toys:
                path.Append("-toys");
                break;

            case ItemType.Cots:
                path.Append("-cots");
                break;

            case ItemType.Others:
                path.Append("-others");
                break;

            default:
                break;
            }
            PriceRange priceRange = PriceRange.Ignore;

            RouteHepler.ParseRouteValue <PriceRange>(requestValues, values, "range", out priceRange, priceRange);
            switch (priceRange)
            {
            case PriceRange.TenZone:
                path.Append("-tenzone");
                break;

            case PriceRange.HundredZone:
                path.Append("-hundredzone");
                break;

            default:
                break;
            }

            SexType sexType = SexType.Ignore;

            RouteHepler.ParseRouteValue <SexType>(requestValues, values, "sex", out sexType, sexType);
            switch (sexType)
            {
            case SexType.Man:
                path.Append("-男孩");
                break;

            case SexType.Woman:
                path.Append("-女孩");
                break;
            }

            int age = 0;

            RouteHepler.ParseRouteValue <int>(requestValues, values, "age", out age, age);
            switch (age)
            {
            case 1:
                path.Append("-0-1岁");
                break;

            case 2:
                path.Append("-2岁");
                break;

            case 3:
                path.Append("-3岁");
                break;

            case 4:
                path.Append("-4岁");
                break;
            }

            return(path.ToString());
        }