Beispiel #1
0
        protected virtual object[] GetArguments()
        {
            // TODO: consider extracting this functionality into an ExecutionResponse class that takes the request and resolves the
            // relevant bits using an IExecutionRequestTargetResolver stated in ResolveExecutionTargetInfo.
            //           AND/OR
            // TODO: consider breaking this class up into specific ExecutionRequest implementations that encapsulate the style of intput parameters/arguments
            //  JsonParamsExecutionRequest, OrderedHttpArgsExecutionRequest, FormEncodedPostExecutionRequest, QueryStringParametersExecutionRequest.
            //  The type of the request should be resolved by examining the ContentType

            // see ExecutionRequestResolver.ResolveExecutionRequest

            // This method is becoming a little bloated
            // due to accomodating too many input paths.
            // This will need to be refactored IF
            // changes continue to be necessary
            // 07/29/2018 - +1 added notes -BA
            // see commit 2526558ea460852c033d1151dc190308a9feaefd

            object[] result = new object[] { };;
            if (HttpArgs.Has("jsonParams", out string jsonParams))
            {
                string[] jsonStrings = jsonParams.FromJson <string[]>();
                result = GetJsonArguments(jsonStrings);
            }
            else if (!string.IsNullOrEmpty(JsonParams))
            {
                // POST: bam.invoke
                string[] jsonStrings = JsonParams.FromJson <string[]>();

                result = GetJsonArguments(jsonStrings);
            }
            else if (Request != null && InputString.Length > 0)
            {
                // POST: probably from a form
                Queue <string> inputValues = new Queue <string>(InputString.Split('&'));

                result = GetFormArguments(inputValues);
            }
            else if (Request != null)
            {
                // GET: parse the querystring
                ViewName = Request.QueryString["view"];
                if (string.IsNullOrEmpty(ViewName))
                {
                    ViewName = "Default";
                }

                jsonParams = Request.QueryString["jsonParams"];
                bool numbered = !string.IsNullOrEmpty(Request.QueryString["numbered"]) ? true : false;
                bool named    = !numbered;

                if (!string.IsNullOrEmpty(jsonParams))
                {
                    dynamic  o           = JsonConvert.DeserializeObject <dynamic>(jsonParams);
                    string[] jsonStrings = ((string)(o["jsonParams"])).FromJson <string[]>();
                    result = GetJsonArguments(jsonStrings);
                }
                else if (named)
                {
                    result = GetNamedQueryStringArguments();
                }
                else
                {
                    result = GetNumberedQueryStringArguments();
                }
            }

            return(result);
        }
Beispiel #2
0
        protected object[] GetParameters()
        {
            // TODO: consider breaking this class up into specific ExecutionRequest implementations that encapsulate the style of parameters
            //  JsonParamsExecutionRequest, OrderedHttpArgsExecutionRequest, FormEncodedPostExecutionRequest, QueryStringParametersExecutionRequest

            // This method is becoming a little bloated
            // due to accomodating too many input paths.
            // This will need to be refactored IF
            // changes continue to be necessary

            object[] result = new object[] { };;
            string   jsonParams;

            if (HttpArgs.Has("jsonParams", out jsonParams))
            {
                string[] jsonStrings = jsonParams.FromJson <string[]>();
                result = GetJsonParameters(jsonStrings);
            }
            else if (HttpArgs.Ordered.Length > 0)
            {
                result = new object[HttpArgs.Ordered.Length];
                HttpArgs.Ordered.Each((val, i) =>
                {
                    result[i] = val;
                });
            }
            else if (!string.IsNullOrEmpty(JsonParams))
            {
                // POST: bam.invoke
                string[] jsonStrings = JsonParams.FromJson <string[]>();

                result = GetJsonParameters(jsonStrings);
            }
            else if (Request != null && InputString.Length > 0)
            {
                // POST: probably from a form
                Queue <string> inputValues = new Queue <string>(InputString.Split('&'));

                result = GetFormParameters(inputValues);
            }
            else if (Request != null)
            {
                // GET: parse the querystring
                ViewName = Request.QueryString["view"];
                if (string.IsNullOrEmpty(ViewName))
                {
                    ViewName = "Default";
                }

                jsonParams = Request.QueryString["jsonParams"];
                bool numbered = !string.IsNullOrEmpty(Request.QueryString["numbered"]) ? true : false;
                bool named    = !numbered;

                if (!string.IsNullOrEmpty(jsonParams))
                {
                    dynamic  o           = JsonConvert.DeserializeObject <dynamic>(jsonParams);
                    string[] jsonStrings = ((string)(o["jsonParams"])).FromJson <string[]>();
                    result = GetJsonParameters(jsonStrings);
                }
                else if (named)
                {
                    result = GetNamedQueryStringParameters();
                }
                else
                {
                    result = GetNumberedParameters();
                }
            }

            return(result);
        }