Ejemplo n.º 1
0
        private bool ProcessBodyMethod(ClrTypeInfo type, MethodInfo method, EControllerMethodKind kind)
        {
            var paras = method.GetParameters();

            if (paras.Length == 1 && paras[0].IsDefined(Constants.FromBody))
            {
                Methods.AddOrUpdate(kind, new BoundMethod(method));
                return(true);
            }
            return(false);
        }
Ejemplo n.º 2
0
        private bool ProcessKeysMethod(ClrTypeInfo type, MethodInfo method, EControllerMethodKind kind)
        {
            var paras = method.GetParameters();
            var keys  = CheckKeyParameters(type, paras);

            if (keys != null && keys.Length == paras.Length)
            {
                Methods.AddOrUpdate(kind, new UnboundMethod(method, keys));
                return(true);
            }
            return(false);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 按指定控制器方法种类获取相信方法信息对象。
        /// </summary>
        /// <typeparam name="T">方法信息对象类型。</typeparam>
        /// <param name="kind">控制器方法种类。</param>
        /// <param name="key">获取方法的键值。</param>
        /// <returns></returns>
        public T GetAction <T>(EControllerMethodKind kind, string key = "")
            where T : class, IControllerMethod
        {
            switch (kind)
            {
            case EControllerMethodKind.BoundAction:
                if (BoundActions.TryGetValue(key, out BoundMethod methodAction))
                {
                    return(methodAction as T);
                }
                break;

            case EControllerMethodKind.UnboundAction:
                if (UnboundActions.TryGetValue(key, out UnboundMethod methodActionKeys))
                {
                    return(methodActionKeys as T);
                }
                break;

            case EControllerMethodKind.BoundFunction:
                if (BoundFunctions.TryGetValue(key, out BoundFunctionMethod methodFunction))
                {
                    return(methodFunction as T);
                }
                break;

            case EControllerMethodKind.UnboundFunction:
                if (UnboundFunctions.TryGetValue(key, out UnboundFunctionMethod methodFunctionKeys))
                {
                    return(methodFunctionKeys as T);
                }
                break;

            case EControllerMethodKind.Navigate:
                if (Navigates.TryGetValue(key, out UnboundMethod methodNavi))
                {
                    return(methodNavi as T);
                }
                break;

            default:
                if (Methods.TryGetValue(kind, out IControllerMethod methodSimple))
                {
                    return(methodSimple as T);
                }
                break;
            }
            return(null);
        }
Ejemplo n.º 4
0
        private bool ProcessKeysBodyMethod(ClrTypeInfo type, MethodInfo method, EControllerMethodKind kind)
        {
            var paras = method.GetParameters();
            var keys  = CheckKeyParameters(type, paras);

            if (keys != null && keys.Length == paras.Length)
            {
                if (paras.Length == keys.Length + 1 && paras[keys.Length].IsDefined(Constants.FromBody))
                {
                    Methods.AddOrUpdate(kind, new UnboundMethod(method, keys));
                    return(true);
                }
            }
            return(false);
        }