Example #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="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));
        }
Example #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="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(AjaxNet.AjaxMethodAttribute), true).Length == 0)
            {
                return(null);
            }

            AjaxNet.AjaxAliasAttribute[] classns  = (AjaxNet.AjaxAliasAttribute[])method.ReflectedType.GetCustomAttributes(typeof(AjaxNet.AjaxAliasAttribute), true);
            AjaxNet.AjaxAliasAttribute[] methodns = (AjaxNet.AjaxAliasAttribute[])method.GetCustomAttributes(typeof(AjaxNet.AjaxAliasAttribute), true);

            ClientMethod cm = new ClientMethod();

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

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

            return(cm);
        }
Example #3
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(AjaxNet.AjaxMethodAttribute), true).Length == 0)
                return null;

            AjaxNet.AjaxAliasAttribute[] classns = (AjaxNet.AjaxAliasAttribute[])method.ReflectedType.GetCustomAttributes(typeof(AjaxNet.AjaxAliasAttribute), true);
            AjaxNet.AjaxAliasAttribute[] methodns = (AjaxNet.AjaxAliasAttribute[])method.GetCustomAttributes(typeof(AjaxNet.AjaxAliasAttribute), true);

            ClientMethod cm = new ClientMethod();

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

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

            return cm;
        }