Exemplo n.º 1
0
        /// <summary>
        /// 接收响应数据
        /// </summary>
        /// <param name="responseType"></param>
        /// <param name="pData"></param>
        /// <param name="requestID"></param>
        protected void ReceiveResponseData(TResponseType responseType, IntPtr pData, int requestID)
        {
            //建立响应数据缓存
            if (this.responseDataMap.ContainsKey(requestID) == false)
            {
                this.responseDataMap[requestID] = new List <Object>();
            }

            //保存响应数据
            if (pData != IntPtr.Zero)
            {
                Object value = null;

                if (responseDataTypeMapping.ContainsKey(responseType))
                {
                    Type t = responseDataTypeMapping[responseType];

                    if (t != null)
                    {
                        value = PInvokeUtility.GetObjectFromIntPtr(t, pData);
                    }
                }

                if (value != null)
                {
                    this.responseDataMap[requestID].Add(value);
                }
            }
        }
Exemplo n.º 2
0
        protected override XSpeedResponseInfo GetResponseInfo(IntPtr pRspInfo)
        {
            XSpeedResponseInfo rsp = new XSpeedResponseInfo();

            DFITCErrorRtnFiled rspInfo = PInvokeUtility.GetObjectFromIntPtr <DFITCErrorRtnFiled>(pRspInfo);

            rsp.ErrorID = rspInfo.ErrorID;
            //rsp.Message = PInvokeUtility.GetUnicodeString(rspInfo.ErrorMsg);
            rsp.Message = rspInfo.ErrorMsg;

            return(rsp);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 创建事件参数
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="rspData"></param>
        /// <param name="rspInfo"></param>
        /// <returns></returns>
        protected XSpeedEventArgs <T> CreateEventArgs <T>(IntPtr rspData, XSpeedResponseInfo rspInfo)
        {
            //转换响应数据
            T value = default(T);

            if (rspData != IntPtr.Zero)
            {
                value = PInvokeUtility.GetObjectFromIntPtr <T>(rspData);
            }

            //创建事件参数
            XSpeedEventArgs <T> args = new XSpeedEventArgs <T>(value, rspInfo);

            return(args);
        }