Пример #1
0
        /// <summary>
        /// 根据字段在模板中的索引进行赋值构建请求数据包
        /// </summary>
        /// <param name="fastmsg">请求包</param>
        /// <param name="filedType">字段类型</param>
        /// <param name="filedValue">字段值</param>
        /// <param name="filedIndex">字段在模板中的索引</param>
        public static void SetFastMsgValue(LDFastMessageAdapter fastmsg, int filedType, string filedValue, int filedIndex)
        {
            switch (filedType)
            {
            case LDSdkTag.TypeInt16:
            case LDSdkTag.TypeuInt16:
            case LDSdkTag.TypeInt32:
            case LDSdkTag.TypeuInt32:
                Int32 intValue = 0;
                Int32.TryParse(filedValue, out intValue);
                fastmsg.SetInt32byIndex(filedIndex, intValue);
                //fastmsg.SetInt32(filedIndex, intValue);
                break;

            case LDSdkTag.TypeInt64:
            case LDSdkTag.TypeuInt64:
                Int64 longValue = 0;
                Int64.TryParse(filedValue, out longValue);
                fastmsg.SetInt64byIndex(filedIndex, (ulong)longValue);
                break;

            case LDSdkTag.TypeDouble:
                double doubleValue = 0;
                double.TryParse(filedValue, out doubleValue);
                fastmsg.SetDoublebyIndex(filedIndex, doubleValue);
                break;

            case LDSdkTag.TypeString:
            case LDSdkTag.TypeVector:
                if (string.IsNullOrEmpty(filedValue))
                {
                    filedValue = " ";
                }
                fastmsg.SetStringbyIndex(filedIndex, filedValue);
                break;

            default:
                break;
            }
        }