/// <summary>
        /// Retreives the parameters.
        /// </summary>
        /// <returns></returns>
        public override object[] RetreiveParameters()
        {
            ParameterInfo[] pi = method.GetParameters();

            object[] args = new object[pi.Length];

            // initialize default values
            for (int i = 0; i < pi.Length; i++)
            {
                args[i] = pi[i].DefaultValue;
            }

            string v = context.Request["data"];

            // If something went wrong or there are no arguments
            // we can return with the empty argument array.

            if (v == null || pi.Length == 0 || v == "{}")
            {
                return(args);
            }

            if (context.Request.ContentEncoding != System.Text.Encoding.UTF8)
            {
                v = System.Text.Encoding.UTF8.GetString(context.Request.ContentEncoding.GetBytes(v));
            }

            hashCode = v.GetHashCode();

            // check if we have to decrypt the JSON string.
            if (Utility.Settings != null && Utility.Settings.Security != null)
            {
                v = Utility.Settings.Security.SecurityProvider.Decrypt(v);
            }

            context.Items.Add(Constant.AjaxID + ".JSON", v);

            JavaScriptObject jso = (JavaScriptObject)JavaScriptDeserializer.DeserializeFromJson(v, typeof(JavaScriptObject));

            for (int i = 0; i < pi.Length; i++)
            {
                //if (pi[i].ParameterType.IsAssignableFrom(jso[pi[i].Name].GetType()))
                //{
                //    args[i] = jso[pi[i].Name];
                //}
                //else
                {
                    args[i] = JavaScriptDeserializer.Deserialize((IJavaScriptObject)jso[pi[i].Name], pi[i].ParameterType);
                }
            }

            return(args);
        }
        /// <summary>
        /// Retreives the parameters.
        /// </summary>
        /// <returns></returns>
        public override object[] RetreiveParameters()
        {
            context.Request.ContentEncoding = System.Text.UTF8Encoding.UTF8;

            ParameterInfo[] pi = method.GetParameters();

            object[] args = new object[pi.Length];

            // initialize default values
            for (int i = 0; i < pi.Length; i++)
            {
                args[i] = pi[i].DefaultValue;
            }

            byte[] b = new byte[context.Request.InputStream.Length];

            if (context.Request.InputStream.Read(b, 0, b.Length) == 0)
            {
                return(null);
            }

            StreamReader sr = new StreamReader(new MemoryStream(b), System.Text.UTF8Encoding.UTF8);

            string v = null;

            try
            {
                v = sr.ReadToEnd();
            }
            finally
            {
                sr.Close();
            }

            // If something went wrong or there are no arguments
            // we can return with the empty argument array.

            if (v == null || pi.Length == 0 || v == "{}")
            {
                return(args);
            }

            hashCode = v.GetHashCode();

            // check if we have to decrypt the JSON string.
            if (Utility.Settings != null && Utility.Settings.Security != null)
            {
                v = Utility.Settings.Security.SecurityProvider.Decrypt(v);
            }

            context.Items.Add(Constant.AjaxID + ".JSON", v);

            JavaScriptObject jso = (JavaScriptObject)JavaScriptDeserializer.DeserializeFromJson(v, typeof(JavaScriptObject));

            for (int i = 0; i < pi.Length; i++)
            {
                if (jso.Contains(pi[i].Name))
                {
                    //if(pi[i].ParameterType.IsAssignableFrom(jso[pi[i].Name].GetType()))
                    //{
                    //    args[i] = jso[pi[i].Name];
                    //}
                    //else
                    {
                        args[i] = JavaScriptDeserializer.Deserialize((IJavaScriptObject)jso[pi[i].Name], pi[i].ParameterType);
                    }
                }
            }

            return(args);
        }