示例#1
0
    public static void GetWhiteList()
    {
        whiteList = null;
        whiteList = new List <Dictionary <string, List <string> > >();
        for (int iCount = 0; iCount < EnumCount; iCount++)
        {
            whiteList.Add(new Dictionary <string, List <string> >());
        }
        string  pathsPath = @"CheckToolFiles\WhiteList.xlsx";
        DataSet data      = ExcelTool.GetData(pathsPath);

        if (data == null)
        {
            return;
        }
        if (data.Tables == null)
        {
            return;
        }
        try
        {
            var Rows = data.Tables[0].Rows;

            for (int iCount = 1; iCount < Rows.Count; iCount++)
            {
                bool isWhiteList = Rows[iCount][3].ToString().Trim().Contains("1") ? true : false;
                if (isWhiteList)
                {
                    string path = Rows[iCount][0].ToString().Trim();
                    path = path.Replace(@"\", "/");
                    var strs = path.Split(new string[1] {
                        "Assets/"
                    }, StringSplitOptions.RemoveEmptyEntries);
                    path = "Assets/" + strs[strs.Length - 1];
                    string name = Rows[iCount][1].ToString().Trim();
                    path += "/" + name;
                    path  = path.Replace("//", "/");//以防重复添加斜杠

                    var indexStrs = Rows[iCount][2].ToString().Trim().Split(',');
                    for (int jCount = 0; jCount < indexStrs.Length; jCount++)
                    {
                        int index = 0;
                        int.TryParse(indexStrs[jCount], out index);
                        if (index > 0)
                        {
                            index -= 1;           //枚举类型从1开始,而whiteList从0开始
                        }
                        else
                        {
                            continue;
                        }
                        if (!whiteList[index].ContainsKey(path))
                        {
                            whiteList[index].Add(path, null);
                            //Debug.Log(path + " " + (index + 1));
                        }
                        if (index == (int)CheckType.LostMotion - 1)
                        {
                            if (whiteList[index][path] == null)
                            {
                                whiteList[index][path] = new List <string>();
                            }
                            var stateStrs = Rows[iCount][4].ToString().Trim().Split(',');
                            foreach (var stateStr in stateStrs)
                            {
                                string state = stateStr.Trim();
                                if (!whiteList[index][path].Contains(state))
                                {
                                    whiteList[index][path].Add(state);
                                }
                                //Debug.Log(stateStr);
                            }
                        }
                    }
                }
            }
        }
        catch
        {
            Debug.LogError("请查看根目录 " + pathsPath + " 是否存在且为最新版本。");
        }
    }