Example #1
0
        private static List <RuleExecutionParameter> GetParameterListFromForm(NameValueCollection form, string controlPrefix)
        {
            if (form == null)
            {
                throw new Exception("Cannot populate Rule Set Parameters. Form was null.");
            }

            var tempContainer = new List <RuleExecutionParameter>();

            foreach (var fieldName in form.AllKeys)
            {
                if (fieldName.StartsWith(controlPrefix + Literals.ParamNameKeyPart))
                {
                    var paramName = form[fieldName];
                    if (!String.IsNullOrWhiteSpace(paramName))
                    {
                        var parameter = new RuleExecutionParameter {
                            Name = paramName.Trim()
                        };
                        var suffixText = Regex.Match(fieldName, @"\d+$", RegexOptions.RightToLeft);
                        if (suffixText.Success)
                        {
                            int suffixCount;
                            if (int.TryParse(suffixText.Value, out suffixCount))
                            {
                                parameter.Value = form[controlPrefix + Literals.ParamValueKeyPart + suffixCount];
                            }
                        }
                        tempContainer.Add(parameter);
                    }
                }
            }
            return(tempContainer);
        }
        private static List <RuleExecutionParameter> GetParameters()
        {
            var parameters      = new List <RuleExecutionParameter>();
            var queryParameters = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.QueryParameters;
            var boundVariables  = WebOperationContext.Current.IncomingRequest.UriTemplateMatch.BoundVariables;

            foreach (var key in queryParameters.AllKeys)
            {
                if (key != null)
                {
                    if (!boundVariables.ContainsKey(key.ToUpper()))
                    {
                        var parameter = new RuleExecutionParameter
                        {
                            Name  = key,
                            Value = queryParameters[key]
                        };
                        parameters.Add(parameter);
                    }
                }
            }
            return(parameters);
        }