コード例 #1
0
 public override void Prepare()
 {
     if (CommandType != CommandType.TableDirect)
     {
         if (ParameterRegex.IsMatch(this.CommandText))
         {
             foreach (Match match in ParameterRegex.Matches(this.CommandText))
             {
                 // enhance the regex compare to ignore parameter if preceded by a declare
                 if (!match.Value.Equals("@output", StringComparison.CurrentCulture) &&
                     Parameters[match.Value] is null)
                 {
                     throw new ArgumentException(MockDBErrors.MissingDbParameter, match.Value);
                 }
             }
         }
     }
     else if (CommandType == CommandType.TableDirect)
     {
     }
 }
コード例 #2
0
        public RouteParameters GetFrom(string pattern)
        {
            MatchCollection matches = ParameterRegex.Matches(pattern);

            foreach (Match match in matches)
            {
                string value             = match.Value.Substring(1, match.Value.Length - 2);
                string name              = value;
                IRouteParameterType type = new StringRouteParameterType();

                if (value.Contains(":"))
                {
                    string[] parts = value.Split(':');
                    name = parts[0];

                    switch (parts[1])
                    {
                    case "int":
                        type = new IntRouteParameterType();
                        break;

                    case "guid":
                        type = new GuidRouteParameterType();
                        break;

                    default:
                        type = new StringRouteParameterType(GetAnyOfChoices(parts[1]));
                        break;
                    }
                }

                Add(name, type);
            }

            return(this);
        }