/// <summary>
        /// 添加行数据
        /// </summary>
        private void AddLine(string line)
        {
            if (string.IsNullOrEmpty(line))
            {
                return;
            }

            var items = line.Split('\t');
            LanguageLineData configLineData = new LanguageLineData
            {
                Key   = items[0],
                eLang = configLang,
                Value = items[1],
            };

            configLineDatas.Add(configLineData);
        }
예제 #2
0
        /// <summary>
        /// 查找相同的Value
        /// </summary>
        /// <param name="lineData"></param>
        /// <returns></returns>
        public bool HasSameValue(LanguageLineData lineData)
        {
            int langIndex = GetLangIndex(lineData.eLang);
            int cnIndex   = GetLangIndex(eLanguageEnum.Cn);
            int count     = configLineDatas.Count;

            for (int i = 0; i < count; i++)
            {
                var myLineData = configLineDatas[i];
                try
                {
                    var flag1 = myLineData.Values[langIndex];
                    var flag2 = lineData.Value;
                    if (myLineData.Values[cnIndex] == lineData.Key && flag1 == flag2)
                    {
                        return(true);
                    }

                    //原表没有值  肯定需要添加
                    if (myLineData.Values[cnIndex] == lineData.Key && string.IsNullOrEmpty(flag1))
                    {
                        return(false);
                    }
                }
                catch (Exception ex)
                {
                    throw new Exception($"语言表的行列数{i + 1}找不到比对的语言{lineData.eLang.ToString()}+{ex.Message}+{ex.StackTrace}");
                }
            }

            //原表没有这个Key了  要忽略掉
            var find = true;

            for (int i = 0; i < count; i++)
            {
                var myLineData = configLineDatas[i];
                if (myLineData.Values[cnIndex] == lineData.Key)
                {
                    find = false;
                    break;
                }
            }

            return(find);
        }
        /// <summary>
        /// 添加一行数据
        /// </summary>
        /// <param name="key"></param>
        public void AddNewKey(string key)
        {
            var find = false;

            foreach (var item in configLineDatas)
            {
                if (item.Key == key)
                {
                    find = true;
                    break;
                }
            }

            if (!find)
            {
                LanguageLineData configLineData = new LanguageLineData
                {
                    Key   = key,
                    eLang = configLang,
                };

                configLineDatas.Add(configLineData);
            }
        }