Пример #1
0
        /// <summary>
        /// Returns a ClientMethod instance to get the name of the class and method name on the client-side JavaScript.
        /// </summary>
        /// <param name="method">The MethodInfo.</param>
        /// <returns>
        /// Returns the ClientMethod info, if it is not a AjaxMethod it will return null.
        /// </returns>
		public static ClientMethod FromMethodInfo(MethodInfo method)
		{
			if(method.GetCustomAttributes(typeof(AjaxPro.AjaxMethodAttribute), true).Length == 0)
				return null;

			AjaxPro.AjaxNamespaceAttribute[] classns = (AjaxPro.AjaxNamespaceAttribute[])method.ReflectedType.GetCustomAttributes(typeof(AjaxPro.AjaxNamespaceAttribute), true);
			AjaxPro.AjaxNamespaceAttribute[] methodns = (AjaxPro.AjaxNamespaceAttribute[])method.GetCustomAttributes(typeof(AjaxPro.AjaxNamespaceAttribute), true);

			ClientMethod cm = new ClientMethod();

			if (classns.Length > 0)
				cm.ClassName = classns[0].ClientNamespace;
			else
			{
				if (Utility.Settings.UseSimpleObjectNaming)
					cm.ClassName = method.ReflectedType.Name;
				else
					cm.ClassName = method.ReflectedType.FullName;
			}

			if(methodns.Length > 0)
				cm.MethodName += methodns[0].ClientNamespace;
			else
				cm.MethodName += method.Name;

			return cm;
		}
Пример #2
0
        /// <summary>
        /// Returns a ClientMethod instance to get the name of the class and method name on the client-side JavaScript.
        /// </summary>
        /// <param name="d">The Delegate.</param>
        /// <returns>
        /// Returns the ClientMethod info, if it is not a AjaxMethod it will return null.
        /// </returns>
        public static ClientMethod FromDelegate(Delegate d)
        {
            if (d == null)
            {
                return(null);
            }

            return(ClientMethod.FromMethodInfo(d.Method));
        }
Пример #3
0
        public static string GetClientMethod(MethodInfo method)
        {
            ClientMethod cm = ClientMethod.FromMethodInfo(method);

            if (cm == null)
            {
                return(null);
            }

            return(cm.ClassName + "," + cm.MethodName);
        }
Пример #4
0
        /// <summary>
        /// Returns a ClientMethod instance to get the name of the class and method name on the client-side JavaScript.
        /// </summary>
        /// <param name="method">The MethodInfo.</param>
        /// <returns>
        /// Returns the ClientMethod info, if it is not a AjaxMethod it will return null.
        /// </returns>
        public static ClientMethod FromMethodInfo(MethodInfo method)
        {
            if (method.GetCustomAttributes(typeof(AjaxPro.AjaxMethodAttribute), true).Length == 0)
            {
                return(null);
            }

            AjaxPro.AjaxNamespaceAttribute[] classns  = (AjaxPro.AjaxNamespaceAttribute[])method.ReflectedType.GetCustomAttributes(typeof(AjaxPro.AjaxNamespaceAttribute), true);
            AjaxPro.AjaxNamespaceAttribute[] methodns = (AjaxPro.AjaxNamespaceAttribute[])method.GetCustomAttributes(typeof(AjaxPro.AjaxNamespaceAttribute), true);

            ClientMethod cm = new ClientMethod();

            if (classns.Length > 0)
            {
                cm.ClassName = classns[0].ClientNamespace;
            }
            else
            {
                if (Utility.Settings.UseSimpleObjectNaming)
                {
                    cm.ClassName = method.ReflectedType.Name;
                }
                else
                {
                    cm.ClassName = method.ReflectedType.FullName;
                }
            }

            if (methodns.Length > 0)
            {
                cm.MethodName += methodns[0].ClientNamespace;
            }
            else
            {
                cm.MethodName += method.Name;
            }

            return(cm);
        }