예제 #1
0
        public void Intercept(IInvocation invocation)
        {
            // Build Request
            var methodInfo = new RestMethodInfo(invocation.Method); // TODO: Memoize these objects in a hash for performance
            var request = new RequestBuilder(methodInfo, invocation.Arguments).Build();

            // Execute request
            var responseType = invocation.Method.ReturnType;
            var genericTypeArgument = responseType.GenericTypeArguments[0];
            // We have to find the method manually due to limitations of GetMethod()
            var methods = restClient.GetType().GetMethods();
            MethodInfo method = methods.Where(m => m.Name == "Execute").First(m => m.IsGenericMethod);
            MethodInfo generic = method.MakeGenericMethod(genericTypeArgument);
            invocation.ReturnValue =  generic.Invoke(restClient, new object[] { request });

        }
예제 #2
0
        public void Intercept(IInvocation invocation)
        {
            // Build Request
            var methodInfo = new RestMethodInfo(invocation.Method); // TODO: Memoize these objects in a hash for performance
            var request    = new RequestBuilder(methodInfo, invocation.Arguments).Build();

            // Execute request
            var responseType        = invocation.Method.ReturnType;
            var genericTypeArgument = responseType.GenericTypeArguments[0];
            // We have to find the method manually due to limitations of GetMethod()
            var        methods = restClient.GetType().GetMethods();
            MethodInfo method  = methods.Where(m => m.Name == "Execute").First(m => m.IsGenericMethod);
            MethodInfo generic = method.MakeGenericMethod(genericTypeArgument);

            invocation.ReturnValue = generic.Invoke(restClient, new object[] { request });
        }
예제 #3
0
 public RequestBuilder(RestMethodInfo methodInfo, object[] arguments)
 {
     this.methodInfo = methodInfo;
     this.arguments = arguments;
 }
예제 #4
0
 public RequestBuilder(RestMethodInfo methodInfo, object[] arguments)
 {
     this.methodInfo = methodInfo;
     this.arguments  = arguments;
 }