Example #1
0
        /// <summary>
        /// 将File内容读进来并存储
        /// </summary>
        /// <param name="_fileInfo"></param>
        private void ReadCSVFile(FileInfo _fileInfo)
        {
            string file, strViewFilter, strKey, strValue;

            file = _fileInfo.Name.Split('.')[0];
            if (!LocalizeDataTable.ContainsKey(file))
            {
                LocalizeDataTable.Add(file, new Dictionary <string, Dictionary <string, string> >());
            }

            ScpReader tmpCSVDocument = new ScpReader(_fileInfo.FullName, true, 2);

            string tmpCurrentView = string.Empty;

            for (int i = 0; i < tmpCSVDocument.GetRecordCount(); ++i)
            {
                //读"界面名"
                strViewFilter = tmpCSVDocument.GetString(i, (int)ELocalizationFile.ELF_View, i == 0?string.Empty: tmpCurrentView);
                if (i == 0 && strViewFilter == string.Empty)
                {
                    Trace.LogError("配置表 " + file + " 出错!!第一个ViewFilter不能是空的。");
                    break;
                }
                else if (strViewFilter == string.Empty)//表当前位置与上一个位置的ViewFilter一致
                {
                    strViewFilter = tmpCurrentView;
                }
                else if (strViewFilter != tmpCurrentView)//表当前位置属于另一个ViewFilter
                {
                    tmpCurrentView = strViewFilter;
                }
                //读"关键字"
                strKey = tmpCSVDocument.GetString(i, (int)ELocalizationFile.ELF_Key, string.Empty);
                if (strKey == string.Empty)
                {
                    Trace.LogError("配置表:" + file + ",在界面:" + strViewFilter + " 有个关键字是空的,这是不允许的出错。");
                    break;
                }
                //读"显示内容"
                strValue = tmpCSVDocument.GetString(i, (int)ELocalizationFile.ELF_Value, string.Empty);
                if (strValue == string.Empty)
                {
                    Trace.LogWarning("配置表:" + file + ",在界面:" + strViewFilter + ",有个值:" + strKey + " 显示的内容是空的,虽然这是允许,但请注意下。");
                }
                if (!LocalizeDataTable[file].ContainsKey(strViewFilter))
                {
                    LocalizeDataTable[file].Add(strViewFilter, new Dictionary <string, string>());
                }
                if (LocalizeDataTable[file][strViewFilter].ContainsKey(strKey))
                {
                    Trace.LogError("配置表: " + file + ",在界面:" + strViewFilter + ",有个值:" + strKey + " 是重复的,这是不允许的,请修改。");
                }
                else
                {
                    LocalizeDataTable[file][strViewFilter].Add(strKey, strValue);
                }
            }
        }
Example #2
0
        private void ReadCSVMPKFile(string _strFileName)
        {
            string strFilePath, strViewFilter, strKey, strValue;

            //file = _fileInfo.Name.Split('.')[0];
            string strFormatEditor  = "{0}{1}/UI/{2}.csv";
            string strFormatRunning = "{0}{1}\\UI\\{2}.csv";
            string strConfigPath    = Initialize.Instance != null ? ViewConfigManager.DataScpPath : ViewConfigManager.Editor_DataScpPath;

            strFilePath = string.Format(Initialize.Instance != null ? strFormatRunning : strFormatEditor, strConfigPath, Language.Name, _strFileName);//ViewConfigManager.DataScpPath + Language.Name + "\\UI\\" + _strFileName+".csv";//

            if (!LocalizeDataTable.ContainsKey(_strFileName))
            {
                LocalizeDataTable.Add(_strFileName, new Dictionary <string, Dictionary <string, string> >());
            }

            ScpReader tmpCSVDocument = new ScpReader(strFilePath, true, 2);

            string tmpCurrentView = string.Empty;

            for (int i = 0; i < tmpCSVDocument.GetRecordCount(); ++i)
            {
                //读"界面名"
                strViewFilter = tmpCSVDocument.GetString(i, (int)ELocalizationFile.ELF_View, i == 0 ? string.Empty : tmpCurrentView);
                if (i == 0 && strViewFilter == string.Empty)
                {
                    Trace.LogError("配置表 " + _strFileName + " 出错!!第一个ViewFilter不能是空的。");
                    break;
                }
                else if (strViewFilter == string.Empty)//表当前位置与上一个位置的ViewFilter一致
                {
                    strViewFilter = tmpCurrentView;
                }
                else if (strViewFilter != tmpCurrentView)//表当前位置属于另一个ViewFilter
                {
                    tmpCurrentView = strViewFilter;
                }
                //读"关键字"
                strKey = tmpCSVDocument.GetString(i, (int)ELocalizationFile.ELF_Key, string.Empty);
                if (strKey == string.Empty)
                {
                    Trace.LogError("配置表:" + _strFileName + ",在界面:" + strViewFilter + " 有个关键字是空的,这是不允许的出错。");
                    break;
                }
                //读"显示内容"
                strValue = tmpCSVDocument.GetString(i, (int)ELocalizationFile.ELF_Value, string.Empty);
                if (strValue == string.Empty)
                {
                    Trace.LogWarning("配置表:" + _strFileName + ",在界面:" + strViewFilter + ",有个值:" + strKey + " 显示的内容是空的,虽然这是允许,但请注意下。");
                }
                if (!LocalizeDataTable[_strFileName].ContainsKey(strViewFilter))
                {
                    LocalizeDataTable[_strFileName].Add(strViewFilter, new Dictionary <string, string>());
                }
                if (LocalizeDataTable[_strFileName][strViewFilter].ContainsKey(strKey))
                {
                    Trace.LogError("配置表: " + _strFileName + ",在界面:" + strViewFilter + ",有个值:" + strKey + " 是重复的,这是不允许的,请修改。");
                }
                else
                {
                    LocalizeDataTable[_strFileName][strViewFilter].Add(strKey, strValue);
                }
            }
        }