Example #1
0
        /// <summary>
        /// 得到一个类型中,所有标记为ControllerMethod的方法
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        private static ControllerInfo FindControllerMethods(System.Type type)
        {
            MethodInfo[] mis = type.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);

            List <ControllerMethodInfo> methodList = new List <ControllerMethodInfo>();
            MethodInfo defaultMethod = null;

            foreach (MethodInfo mi in mis)
            {
                ControllerMethodAttribute cma = AttributeHelper.GetCustomAttribute <ControllerMethodAttribute>(mi);

                if (cma != null)
                {
                    ControllerMethodInfo cmi = new ControllerMethodInfo(mi, cma.ForceIgnoreParameters);

                    methodList.Add(cmi);

                    if (defaultMethod == null && cma.Default)
                    {
                        defaultMethod = mi;
                    }
                }
            }

            return(new ControllerInfo(methodList.ToArray(), defaultMethod));
        }
		/// <summary>
		/// 得到一个类型中,所有标记为ControllerMethod的方法
		/// </summary>
		/// <param name="type"></param>
		/// <returns></returns>
		private static ControllerInfo FindControllerMethods(System.Type type)
		{
			MethodInfo[] mis = type.GetMethods(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public);

			List<ControllerMethodInfo> methodList = new List<ControllerMethodInfo>();
			MethodInfo defaultMethod = null;

			foreach (MethodInfo mi in mis)
			{
				ControllerMethodAttribute cma = AttributeHelper.GetCustomAttribute<ControllerMethodAttribute>(mi);

				if (cma != null)
				{
					ControllerMethodInfo cmi = new ControllerMethodInfo(mi, cma.ForceIgnoreParameters);

					methodList.Add(cmi);

					if (defaultMethod == null && cma.Default)
						defaultMethod = mi;
				}
			}

			return new ControllerInfo(methodList.ToArray(), defaultMethod);
		}