Ejemplo n.º 1
0
        public static void DefineMethods(TypeBuilder typeBuilder, FieldBuilder fieldBuilder, Type interfaceType, MethodInfo interceptMethodInfo)
        {
            var methodArray = interfaceType.GetMethods();

            foreach (MethodInfo interfaceMethodInfo in methodArray)
            {
                var title = GenerateTitle(interfaceType, interfaceMethodInfo);

                var parameterArray     = interfaceMethodInfo.GetParameters();
                var parameterTypeArray = GetParameterTypes(parameterArray);
                var parameterTupleType = CustomTuple.CreateType(parameterTypeArray);

                DefineMethod(interfaceMethodInfo, interceptMethodInfo, parameterTupleType, typeBuilder, fieldBuilder, title);
            }
        }
Ejemplo n.º 2
0
        private void RegisterService(string serviceName, string actionName, object service, Type serviceType, MethodInfo methodInfo, IRpcSerializer rpcSerializer)
        {
            var typeArray = DynamicProxyHelper.GetParameterTypes(methodInfo.GetParameters());

            if (typeArray.Length > 10)
            {
                throw new ArgumentException(string.Format("RegisterService error,service:{0},action:{1}, parameters count is not valid, max method parameter count is {2} ", serviceName, actionName, 10));
            }

            var parameterTupleType = CustomTuple.CreateType(typeArray);
            var title = DynamicProxyHelper.FormatTitle(serviceName, actionName, typeArray, methodInfo.ReturnType);

            var invocation = new Invocation(title, serviceType, methodInfo, parameterTupleType, rpcSerializer);

            _invocationDictionary.TryAdd(invocation.Key, invocation);

            LogAgent.Info(string.Format("RegisterService -> {0}", title));
        }