public void ReflectsInfo()
 {
     IRpcMethodDescriptor method = new StubMethodDescriptor();
     
     RpcParameterDescriptor parameter = new RpcParameterDescriptor(method, _sumInfo.GetParameters()[0]);
     Assert.AreEqual("a", parameter.Name);
     Assert.AreEqual(typeof(int), parameter.ParameterType);
     Assert.AreSame(method, parameter.MethodDescriptor);
 }
        public RpcMethodDescriptor(IRpcServiceDescriptor serviceDescriptor, MethodInfo method, JsonRpcMethodAttribute attribute)
        {
            if (serviceDescriptor == null)
                throw new ArgumentNullException("serviceDescriptor");

            if (method == null)
                throw new ArgumentNullException("method");

            _serviceDescriptor = serviceDescriptor;
            _method = method;
            _name = method.Name;

            //
            // If an attribute was not supplied then grab one from the method.
            //

            if (attribute == null)
                attribute = (JsonRpcMethodAttribute) Attribute.GetCustomAttribute(method, typeof(JsonRpcMethodAttribute), true);

            //
            // If an attribute was supplied then use it to apply customizations,
            // such as the external method name.
            //

            if (attribute != null)
            {
                if (attribute.Name.Length > 0)
                    _name = attribute.Name;
            }

            //
            // Enumerate the parameters.
            //

            ParameterInfo[] parameters = _method.GetParameters();
            _rpcParameters = new IRpcParameterDescriptor[parameters.Length];

            for (int i = 0; i < parameters.Length; i++)
                _rpcParameters[i] = new RpcParameterDescriptor(this, parameters[i]);
        }