Exemplo n.º 1
0
        /// <summary>
        /// 将没有传入的参数替换为默认参数
        /// </summary>
        /// <param name="route"></param>
        /// <param name="request"></param>
        protected static void ReplaceDefaults(Route route, Request request)
        {
            string varName, defaults;

            for (int i = 0; i < route.Compiled.Variables.Length; i++)
            {
                varName = route.Compiled.Variables[i];
                if (request.Get(varName) == null)
                {
                    defaults = route.GetDefaults(varName);
                    if (!string.IsNullOrEmpty(defaults))
                    {
                        request.AddParameters(varName, defaults);
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 将没有传入的参数替换为默认参数
        /// </summary>
        /// <param name="route"></param>
        /// <param name="request"></param>
        private static void ReplaceDefaults(Route route, Request request)
        {
            string varName, defaults;

            for (var i = 0; i < route.Compiled.Variables.Length; i++)
            {
                varName = route.Compiled.Variables[i];
                if (request.Get(varName) != null)
                {
                    continue;
                }
                defaults = route.GetDefaults(varName);
                if (!string.IsNullOrEmpty(defaults))
                {
                    request.ReplaceParameter(varName, defaults);
                }
            }
        }