예제 #1
0
파일: ConfigCommon.cs 프로젝트: zjbsean/TM
        public static string ConvertToItemStr(this TIntKeyValueList kvList)
        {
            StringBuilder sb = new StringBuilder();

            for (int i = 0; i < kvList.GetElements().Count; i++)
            {
                sb.Append(kvList.GetElements()[i].key);
                sb.Append(',');
                sb.Append(kvList.GetElements()[i].value);

                if (i != kvList.GetElements().Count - 1)
                {
                    sb.Append('|');
                }
            }

            return(sb.ToString());
        }
예제 #2
0
파일: ConfigCommon.cs 프로젝트: zjbsean/TM
        /// <summary>
        /// 道具配置解析
        /// </summary>
        /// <param name="itemStr"></param>
        /// <returns></returns>
        public static TIntKeyValueList ItemCfgparse(string itemStr)
        {
            TIntKeyValueList result = new TIntKeyValueList();

            if (!string.IsNullOrEmpty(itemStr))
            {
                string[] strArr1 = itemStr.Split('|');
                foreach (var str1 in strArr1)
                {
                    if (string.Empty != str1)
                    {
                        string[] itemKeyVal = str1.Split(',');
                        int      itemID     = Convert.ToInt32(itemKeyVal[0]);
                        int      num        = Convert.ToInt32(itemKeyVal[1]);
                        result.Add(new TIntKeyValue()
                        {
                            key = itemID, value = num
                        });
                    }
                }
            }

            return(result);
        }