Example #1
0
        /// <summary>
        /// 解析列信息
        /// </summary>
        private void ParseColumnDef()
        {
            //第2行定义了列数据的变量名和类型
            int columnDefRow     = 2;
            var columnDefStrList = m_rawDataReader.ReadLine(columnDefRow - 1);

            m_columnInfoList.Clear();
            for (int i = 0; i < columnDefStrList.Length; i++)
            {
                var columnDefStr = columnDefStrList[i];
                //如果该列定义以“#”开头,忽略该列的导出
                if (columnDefStr.StartsWith("#"))
                {
                    continue;
                }
                string[] tuple = columnDefStr.Split(new char[] { ':' });
                if (tuple.Length != 2)
                {
                    ThrowException(string.Format("the column def {0} at[{1},{2}] is not a tuple", columnDefStr, columnDefRow, i));
                }
                var columnName    = tuple[0];
                var columnTypeStr = tuple[1];
                if (!ConfigDataHelper.IsValidVariableName(columnName))
                {
                    ThrowException(string.Format("the column variable name {0} at[{1},{2}] is not valid", columnName, columnDefRow, i));
                }
                if (string.IsNullOrEmpty(tuple[1]))
                {
                    ThrowException(string.Format("the column's type str {0} at[{1},{2}] is null", columnTypeStr, columnDefRow, i));
                }
                m_columnInfoList.Add(new ConfigDataTableColumnInfo(m_tableName, columnName, columnTypeStr, i));
            }
        }
Example #2
0
        /// <summary>
        /// 解析表信息
        /// </summary>
        private void ParseTableInfo()
        {
            //第0行,第0列定义了表的名字和类型
            string content = m_rawDataReader.ReadCell(0, 0);

            string[] tuple = content.Split(new char[] { ':' });
            if (tuple.Length != 2)
            {
                ThrowException("table at [0,0] is not a tuple");
            }
            string tableName     = tuple[0];
            string tableTypeName = tuple[1];

            if (!ConfigDataHelper.IsValidVariableName(tableName))
            {
                ThrowException(string.Format("'{0}' is not a valid table name", tableName));
            }
            m_tableName = tableName;
            m_tableType = (ConfigDataTabelType)Enum.Parse(typeof(ConfigDataTabelType), tableTypeName);
            if (m_tableType == null)
            {
                ThrowException(string.Format("{0} is not a valid table type", tableTypeName));
            }
        }