예제 #1
0
        public bool AddRecord(ref GameView obj, int index)
        {
            try
            {
                if (index < 0 || index > mRecordTable.Count)
                {
                    //Log.Trace("index error");
                    return(false);
                }

                if (null == obj)
                {
                    //Log.Trace("obj is null");
                    return(false);
                }

                if (!mRecordTable.ContainsKey(index))
                {
                    //Log.Trace("not include index:" + index.ToString());
                    return(false);
                }

                RecData    recData = mRecordTable[index];
                GameRecord record  = new GameRecord();
                record.SetName(recData.strName);
                record.SetColCount(recData.nCols);
                for (int i = 0; i < recData.nCols; i++)
                {
                    int type = recData.ColTypes[i];
                    switch (type)
                    {
                    case OuterDataType.OUTER_TYPE_BYTE:
                    case OuterDataType.OUTER_TYPE_WORD:
                    case OuterDataType.OUTER_TYPE_DWORD:
                    {
                        record.SetColType(i, VarType.Int);
                    }
                    break;

                    case OuterDataType.OUTER_TYPE_QWORD:
                    {
                        record.SetColType(i, VarType.Int64);
                    }
                    break;

                    case OuterDataType.OUTER_TYPE_FLOAT:
                    {
                        record.SetColType(i, VarType.Float);
                    }
                    break;

                    case OuterDataType.OUTER_TYPE_DOUBLE:
                    {
                        record.SetColType(i, VarType.Double);
                    }
                    break;

                    case OuterDataType.OUTER_TYPE_STRING:
                    {
                        record.SetColType(i, VarType.String);
                    }
                    break;

                    case OuterDataType.OUTER_TYPE_WIDESTR:
                    {
                        record.SetColType(i, VarType.WideStr);
                    }
                    break;

                    case OuterDataType.OUTER_TYPE_OBJECT:
                    {
                        record.SetColType(i, VarType.Object);
                    }
                    break;

                    default:
                        //Log.Trace("unkown type");
                        break;
                    }
                }//end for

                return(obj.AddRecord2Set(recData.strName, ref record));
            }//end try
            catch (Exception ex)
            {
                //Log.Trace("Exception:" + ex.ToString());
                return(false);
            }
        }