コード例 #1
0
        public override bool validate(string v)
        {
            ProtoData    pd = ProtoData.ms_protoDatas[m_tableName];
            Type         t  = pd.Type;
            PropertyInfo pi = t.GetProperty("id_raw");

            // 如果是第一次使用该外键,建立查找字典
            if (null == pd.m_dataDic)
            {
                var dic = new Dictionary <int, IExtensible>();
                for (int i = 0; i < pd.Count; i++)
                {
                    IExtensible o  = pd[i];
                    int         id = int.Parse((string)pi.GetValue(o, null));
                    // 主键重复
                    try
                    {
                        dic.Add(id, o);
                    }
                    catch (ArgumentException)
                    {
                        if ("CutsceneConfig" != m_tableName)
                        {
                            Console.WriteLine("  " + m_tableName + "表包含重复的ID:" + id);
                        }
                    }
                }
                pd.m_dataDic = dic;
            }

            try
            {
                int vid = int.Parse(v);
                return(pd.m_dataDic.ContainsKey(vid));
            }
            catch (Exception)
            {
                return(false);
            }
        }
コード例 #2
0
        void DoEnd()
        {
            if (convType == ConvType.Client)
            {
                if (!Directory.Exists(exlClientLibs))
                {
                    Console.WriteLine("找不到路径: " + exlClientLibs + " 是否创建(Y/N)?");
                    string pressKey = Console.ReadLine();
                    if (pressKey.ToLower() == "y")
                    {
                        Directory.CreateDirectory(exlClientLibs);
                        if (!Directory.Exists(exlClientLibs))
                        {
                            Console.WriteLine("创建路径: " + exlClientLibs + " 失败!");
                        }
                    }
                }

                foreach (var fi in (new DirectoryInfo(dllPath)).GetFiles("*.dll"))
                {
                    File.Copy(fi.FullName, exlClientLibs + fi.Name, true);
                }
                foreach (var fi in (new DirectoryInfo(dataPath)).GetFiles("*.protodata.bytes"))
                {
                    File.Copy(fi.FullName, exlClientData + fi.Name, true);
                }
            }
            else if (convType == ConvType.Server)
            {
                if (!Directory.Exists(exlServerLibs))
                {
                    Console.WriteLine("找不到路径: " + exlServerLibs + " 是否创建(Y/N)?");
                    string pressKey = Console.ReadLine();
                    if (pressKey.ToLower() == "y")
                    {
                        Directory.CreateDirectory(exlServerLibs);
                        if (!Directory.Exists(exlServerLibs))
                        {
                            Console.WriteLine("创建路径: " + exlServerLibs + " 失败!");
                        }
                    }
                }

                if (!Directory.Exists(exlServerData))
                {
                    Console.WriteLine("找不到路径: " + exlServerData + " 是否创建(Y/N)?");
                    string pressKey = Console.ReadLine();
                    if (pressKey.ToLower() == "y")
                    {
                        Directory.CreateDirectory(exlServerData);
                        if (!Directory.Exists(exlServerData))
                        {
                            Console.WriteLine("创建路径: " + exlServerData + " 失败!");
                        }
                    }
                }

                foreach (var fi in (new DirectoryInfo(codePath)).GetFiles("*.pb.h"))
                {
                    if (!CompareTwoFile(fi.FullName, exlServerLibs + fi.Name))
                    {
                        File.Copy(fi.FullName, exlServerLibs + fi.Name, true);
                        Console.WriteLine(string.Format("gen new file: {0}", fi.Name));
                    }
                }
                foreach (var fi in (new DirectoryInfo(codePath)).GetFiles("*.pb.cc"))
                {
                    if (!CompareTwoFile(fi.FullName, exlServerLibs + fi.Name))
                    {
                        File.Copy(fi.FullName, exlServerLibs + fi.Name, true);
                        Console.WriteLine(string.Format("gen new file: {0}", fi.Name));
                    }
                }

                foreach (var fi in (new DirectoryInfo(dataPath)).GetFiles("*.protodata.bytes"))
                {
                    File.Copy(fi.FullName, exlServerData + fi.Name, true);
                }
            }
            else if (convType == ConvType.Validate)
            {
                Console.WriteLine("\n------------------验证数据--------------------\n");
                ProtoData.ms_protoAssembly = fullLib;
                string[] fis = Directory.GetFiles(dataPath);
                foreach (string fi in fis)
                {
                    byte[]    buf = File.ReadAllBytes(fi);
                    ProtoData pd  = new ProtoData(buf);
                }
                foreach (ExcelData xd in excels)
                {
                    ProtoData pd = null;
                    ProtoData.ms_protoDatas.TryGetValue(xd.sheetName, out pd);
                    if (null != pd)
                    {
                        Console.WriteLine("验证数据: " + xd.excelName + ":" + xd.sheetName);
                        pd.Validate();
                    }
                }
            }
        }