Exemple #1
0
        // 替换一列的参照信息
        private static bool ReplaceColumn(DataTable aDataTable, int aColIndex, List <ColumnInfo> fieldTypeAryo)
        {
            ColumnInfo colInfo = fieldTypeAryo[aColIndex];

            if (colInfo.m_isRef)
            {
                Regex reg = new Regex(@"^\w+\s*\{(\s*\w+\.\w+\s*)?\}$");
                if (reg.IsMatch(colInfo.m_param))
                {
                    string tmp        = string.Format("{0}[\"{1}\"]", aDataTable.TableName, colInfo.m_name);
                    int    startIndex = colInfo.m_param.IndexOf('{');
                    int    endIndex   = colInfo.m_param.IndexOf('}');
                    string param      = colInfo.m_param.Substring(startIndex + 1, endIndex - startIndex - 1).Trim(' ');
                    if (ReferenceHandle.FindRefenrence(aDataTable, fieldTypeAryo, ref colInfo.m_name, ref colInfo.m_type, param, tmp, true) != ErrRefenrence.ErrRefenrenceNone)
                    {
                        return(false);
                    }
                }
                else
                {
                    UnityEngine.Debug.LogError(string.Format("表头参照格式错误,表{0}[\"{1}\"]列的表头:{2} 格式不正确!", aDataTable.TableName, colInfo.m_name, colInfo.m_param));
                    return(false);
                }
            }
            else if (colInfo.m_isComplex)
            {
                Regex regDivide = new Regex(@"\w+\s+\w+");
                bool  isDivide  = regDivide.IsMatch(colInfo.m_param.Substring(colInfo.m_param.IndexOf('[')));
                colInfo.m_param = colInfo.m_param.Replace(" ", "");
                Regex reg = new Regex(@"^\w+\{((\w+=\w+\.\w+,)*\w+=\w+\.\w+)?\}\[((\w+,)*\w+)?\]$");
                if (!isDivide && reg.IsMatch(colInfo.m_param))
                {
                    string param = colInfo.m_param.Substring(colInfo.m_param.IndexOf('{'));
                    if (!CheckComplexColumn(param, colInfo, aDataTable, fieldTypeAryo))
                    {
                        return(false);
                    }
                    colInfo.m_type = typeof(string);
                }
                else
                {
                    UnityEngine.Debug.LogError(string.Format("表头拆分格式错误,表{0}[\"{1}\"]列的表头:{2} 格式不正确!", aDataTable.TableName, colInfo.m_name, colInfo.m_param));
                    return(false);
                }
            }
            return(true);
        }
Exemple #2
0
        private static bool CheckComplexColumn(string value, ColumnInfo fInfo, DataTable dt, List <ColumnInfo> fieldTypeAryo)
        {
            Dictionary <string, string> dic = new Dictionary <string, string>();
            int    index = value.IndexOf('[');
            string str   = value.Substring(index + 1, value.IndexOf(']') - index - 1);

            string[] keys = str.Split(',');
            for (int i = 0; i < keys.Length; ++i)
            {
                if (keys[i].Length != 0)
                {
                    dic.Add(keys[i], null);
                }
            }
            str = value.Substring(1, value.IndexOf('}') - 1);
            string[] v = str.Split(',');
            string   k = "";

            for (int i = 0; i < v.Length; ++i)
            {
                str = v[i];
                if (str.Length == 0)
                {
                    continue;
                }
                k = str.Substring(0, str.IndexOf('='));
                if (dic.ContainsKey(k))
                {
                    dic[k] = str.Substring(str.IndexOf('=') + 1);

                    string tmp = string.Format("{0}[\"{1}\"]", dt.TableName, fInfo.m_name);
                    if (ReferenceHandle.FindRefenrence(dt, fieldTypeAryo, ref fInfo.m_name, ref fInfo.m_type, dic[k], tmp, true) != ErrRefenrence.ErrRefenrenceNone)
                    {
                        return(false);
                    }
                }
                else
                {
                    UnityEngine.Debug.LogError(string.Format("表头拆分格式错误,表{0}[\"{1}\"]列参照名称:{2}不在拆分名称中!", dt.TableName, fInfo.m_name, k));
                    return(false);
                }
            }
            fInfo.m_splitDic = dic;
            return(true);
        }