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); }
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); } }
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); }
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); } }