private static object[] GetURLArguments(MethodInfo method, UriRequest uri)
        {
            var methodParams = method.GetParameters();
            var args = new Object[methodParams.Count()];

            for (var i = 0; i < args.Length; i++){
                var param = methodParams[i];

                var value = uri.GetParameter(param.Name);
                if (value == null){
                    args[i] = param.DefaultValue;
                }
                else{
                    if (param.ParameterType == typeof (int)){
                        args[i] = int.Parse(value);
                    }
                    else if (param.ParameterType == typeof (string)){
                        args[i] = value;
                    }
                    else{
                        args[i] = value;
                    }
                }
            }
            return args;
        }
예제 #2
0
 public Request(Session session, string uri, string body)
 {
     Session = session;
     Uri = new UriRequest(uri);
     Body = body;
 }
예제 #3
0
 public void SlashesAreUsedToDelimateSegments()
 {
     var request = new UriRequest("/Hello/World");
     request.Segments.Should().BeEquivalentTo("Hello", "World");
 }
예제 #4
0
 public void SegmentsAreParsedCorrectly()
 {
     var request = new UriRequest("Bomb");
     request.Segments.Should().BeEquivalentTo("Bomb");
 }
예제 #5
0
 public void ParametersAreParsed()
 {
     var request = new UriRequest("/Info?Name=12");
     request.GetParameter("Name").Should().Be("12");
     request.GetParameter("wowow").Should().BeNull();
 }
예제 #6
0
 public void ParametersAreExcludedFromSegments()
 {
     var request = new UriRequest("/What/Is?time=0");
     request.Segments.Should().BeEquivalentTo("What", "Is");
 }
예제 #7
0
 public void CanGetParameter()
 {
     var request = new UriRequest("/?name=nick&time=4");
     request.GetParameter("name").Should().Be("nick");
     request.GetParameter("time").Should().Be("4");
 }