public void DefineTwoMethods() { Assert.IsFalse(_builder.HasMethods); Assert.IsNotNull(_builder.DefineMethod()); Assert.IsTrue(_builder.HasMethods); Assert.IsNotNull(_builder.DefineMethod()); Assert.IsTrue(_builder.HasMethods); MethodBuilder[] methods = (MethodBuilder[])CollectionHelper.ToArray(_builder.Methods, typeof(MethodBuilder)); Assert.IsNotNull(methods); Assert.AreEqual(2, methods.Length); }
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); }
void IServiceClassReflector.Build(ServiceClassBuilder builder, Type type) { builder.Name = Name; // // Get all the public instance methods on the type and create a // filtered table of those to expose from the service. // MethodInfo[] publicMethods = type.GetMethods(BindingFlags.Public | BindingFlags.Instance); foreach (MethodInfo method in publicMethods) { if (JsonRpcServiceReflector.ShouldBuild(method)) JsonRpcServiceReflector.BuildMethod(builder.DefineMethod(), method); } }
public void Init() { _classBuilder = new ServiceClassBuilder(); _builder = _classBuilder.DefineMethod(); }
private static void BuildClass(ServiceClassBuilder builder, Type type) { // // Build via attributes. // object[] attributes = type.GetCustomAttributes(typeof(IServiceClassReflector), true); foreach (IServiceClassReflector reflector in attributes) reflector.Build(builder, type); // // Fault in the type name if still without name. // if (builder.Name.Length == 0) builder.Name = type.Name; // // Get all the public instance methods on the type and create a // filtered table of those to expose from the service. // MethodInfo[] publicMethods = type.GetMethods(BindingFlags.Public | BindingFlags.Instance); foreach (MethodInfo method in publicMethods) { if (ShouldBuild(method)) BuildMethod(builder.DefineMethod(), method); } }
public void Init() { _classBuilder = new ServiceClassBuilder(); _builder = _classBuilder.DefineMethod(); }