Пример #1
0
        public void FirstParameterOfStaticMethodDoesNotAppearInTheReflectedModel()
        {
            ServiceClassBuilder    scb        = new ServiceClassBuilder();
            MethodInfo             method     = typeof(ServiceWithStaticMethod).GetMethod("StaticMethod");
            JsonRpcMethodAttribute attribute  = new JsonRpcMethodAttribute();
            IAttributeAttachment   attachment = attribute;

            attachment.SetAttachment(method);
            IMethodReflector reflector = attribute;
            MethodBuilder    mb        = scb.DefineMethod();

            reflector.Build(mb);
            Assert.AreEqual(0, mb.Parameters.Count);
        }
Пример #2
0
        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();
                TrySetAttachment(reflector, method);
            }

            reflector.Build(builder);

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

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

            builder.CustomAttributes = method;

            //
            // Modify...
            //

            IMethodModifier[] modifiers = (IMethodModifier[])GetCustomAttributes(method, typeof(IMethodModifier), true);
            foreach (IMethodModifier modifier in modifiers)
            {
                modifier.Modify(builder);
            }
        }