private string SubstituteParameters(StringBuilder sql, NameValueCollection requestParams)
        {
            foreach (string name in Parameters.Keys)
            {
                var parameter = Parameters[name];
                var value = requestParams != null && requestParams.Contains(name) ? requestParams[name] : parameter.Default;

                if (parameter.Required && !value.HasValue())
                {
                    Errors.Add(string.Format("Missing value for {0}!", name));

                    continue;
                }

                if (parameter.Type.HasValue())
                {
                    if (!ValidateType(parameter.Type, value))
                    {
                        Errors.Add(string.Format("Expected value of {0} to be a {1}!", name, parameter.Type));

                        continue;
                    }

                    value = EncodeType(parameter.Type, value);
                }

                sql.Replace("##" + name + "##", value);
            }

            return sql.ToString();
        }
Пример #2
0
 public static void TestRequiredParameters(NameValueCollection query)
 {
     query.ContainsAndEquals("email", TestClient.EmailAddress);
     query.Contains("expires");
     query.Contains("signature");
 }