private static void BuildMethod(MethodBuilder builder, MethodInfo method)
        {
            Debug.Assert(method != null);
            Debug.Assert(builder != null);

            builder.InternalName = method.Name;
            builder.ResultType = method.ReturnType;
            builder.Handler = new TypeMethodImpl(method);

            //
            // Build via attributes.
            //

            object[] attributes = method.GetCustomAttributes(typeof(Attribute), true);
            foreach (Attribute attribute in attributes)
            {
                IMethodReflector reflector = attribute as IMethodReflector;

                if (reflector != null)
                    reflector.Build(builder, method);
                else
                    builder.AddCustomAttribute(attribute);
            }

            //
            // Fault in the method name if still without name.
            //

            if (builder.Name.Length == 0)
                builder.Name = method.Name;

            //
            // Build the method parameters.
            //

            foreach (ParameterInfo parameter in method.GetParameters())
                BuildParameter(builder.DefineParameter(), parameter);
        }
        internal static void BuildMethod(MethodBuilder builder, MethodInfo method)
        {
            Debug.Assert(method != null);
            Debug.Assert(builder != null);

            builder.InternalName = method.Name;
            builder.ResultType = method.ReturnType;
            builder.Handler = new TypeMethodImpl(method);

            //
            // Build...
            //

            IMethodReflector reflector = (IMethodReflector) FindCustomAttribute(method, typeof(IMethodReflector), true);

            if (reflector == null)
                reflector = new JsonRpcMethodAttribute();

            reflector.Build(builder, method);

            //
            // Fault in the method name if still without name.
            //

            if (builder.Name.Length == 0)
                builder.Name = method.Name;

            //
            // Modify...
            //

            object[] attributes = method.GetCustomAttributes(typeof(Attribute), true);
            foreach (Attribute attribute in attributes)
            {
                IMethodModifier modifier = attribute as IMethodModifier;

                if (modifier != null)
                    modifier.Modify(builder, method);
                else if (!(attribute is IMethodReflector))
                    builder.AddCustomAttribute(attribute);
            }
        }
 void IMethodModifier.Modify(MethodBuilder builder, MethodInfo method)
 {
     builder.AddCustomAttribute(this);
 }
 void IMethodReflector.Build(MethodBuilder builder, MethodInfo method)
 {
     builder.AddCustomAttribute(this);
 }