/// <summary>
        /// 使用指定服务接口的类型以及接口中的方法信息,创建调用操作信息
        /// </summary>
        /// <param name="interfaceType">接口类型</param>
        /// <param name="operationInfo">操作方法信息</param>
        /// <returns></returns>
        public static InvokeOperationInfo Create(Type interfaceType, MethodInfo operationInfo)
        {
            InvokeOperationInfo info = new InvokeOperationInfo();

            Fill(info, interfaceType, operationInfo);
            return(info);
        }
        internal static void Fill(InvokeOperationInfo info, Type interfaceType, MethodInfo operationInfo)
        {
            var interfaceSchema        = ServiceModelSchema.GetServiceInterfaceSchema(interfaceType);
            var operationSchema        = ServiceModelSchema.GetServiceOperationSchema(interfaceType, operationInfo);
            var invokeParameterSchemas = ServiceModelSchema.GetServiceInvokeParameterSchemas(interfaceType, operationInfo);
            var returnParameterSchema  = ServiceModelSchema.GetServiceReturnParameterSchema(interfaceType, operationInfo);

            info.InterfaceSchema        = interfaceSchema;
            info.OperationSchema        = operationSchema;
            info.InvokeParameterSchemas = invokeParameterSchemas;
            info.ReturnParameterSchema  = returnParameterSchema;
        }
Beispiel #3
0
        public Object InovkeHandle(Object proxy, Type interfaceType, MethodInfo invokeMethod, Object[] parameterValues)
        {
            Object result = null;

            try
            {
                InvokeOperationInfo invokeInfo = InvokeOperationInfo.Create(interfaceType, invokeMethod);

                InvokePacket invokePacket = new InvokePacket();
                invokePacket.InterfaceName = invokeInfo.InterfaceSchema.Name;
                invokePacket.OperationName = invokeInfo.OperationSchema.Name;

                invokePacket.ParameterValues = parameterValues;
                invokePacket.ParameterTypes  = invokeInfo.InvokeParameterSchemas.Select(t => t.ParameterType.FullName).ToArray();

                invokePacket.InvokeTime = DateTime.Now;
#if SerializePerformance
                Debug.WriteLine("SerializeInvokePacket Start Time: " + DateTime.Now.ToString("ss:fff"));
                var invokeTransportableObject = this.Serializer.SerializeInvokePacket(invokePacket);
                Debug.WriteLine("SerializeInvokePacket End Time: " + DateTime.Now.ToString("ss:fff"));
#else
                var invokeTransportableObject = this.Serializer.SerializeInvokePacket(invokePacket);
#endif
                var returnTransportableObject = this.Serializer.CreateTransportable();

                if (this.Transmitter.Transfer(invokeTransportableObject, returnTransportableObject))
                {
                    //调用用户自定义过程

#if SerializePerformance
                    Debug.WriteLine("DeSerialize Return Packet Start Time: " + DateTime.Now.ToString("ss:fff"));
                    var returnPacket = this.Serializer.DeSerializeToReturnPacket(returnTransportableObject);
                    result = returnPacket.Content;
                    Debug.WriteLine("DeSerialize Return Packet End Time: " + DateTime.Now.ToString("ss:fff"));
#else
                    var returnPacket = this.Serializer.DeSerializeToReturnPacket(returnTransportableObject);
                    result = returnPacket.Content;
#endif
                }
            }
            finally
            {
            }
            return(result);
        }