static string GetModuleByName(string name)
        {
            Type[] types = ReflectTool.GetTypes();

            for (int i = 0; i < types.Length; i++)
            {
                if (typeof(CsharpProtocolInterface).IsAssignableFrom(types[i]) &&
                    GetModuleName(types[i], false) == name
                    )
                {
                    return(types[i].FullName);
                }
            }

            throw new Exception("GetModuleByName Fail ! " + name);
        }
        static bool GetExitsModule(string name)
        {
            Type[] types = ReflectTool.GetTypes();

            for (int i = 0; i < types.Length; i++)
            {
                if (typeof(CsharpProtocolInterface).IsAssignableFrom(types[i]) &&
                    GetModuleName(types[i], false) == name
                    )
                {
                    return(true);
                }
            }

            return(false);
        }
        static Type GetAimStructType(string name)
        {
            Type[] types = ReflectTool.GetTypes();

            for (int i = 0; i < types.Length; i++)
            {
                if (typeof(IProtocolStructInterface).IsAssignableFrom(types[i]) &&
                    types[i].Name.ToLower() == name.ToLower()
                    )
                {
                    return(types[i]);
                }
            }

            return(null);
        }
        static void GenerateList()
        {
            msgList.Clear();

            Type[] types = ReflectTool.GetTypes();

            for (int i = 0; i < types.Length; i++)
            {
                if (typeof(IProtocolMessageInterface).IsAssignableFrom(types[i]) &&
                    types[i] != typeof(IProtocolMessageInterface) &&
                    types[i] != typeof(CsharpProtocolInterface) &&
                    !types[i].IsAbstract
                    )
                {
                    msgList.Add(types[i]);
                }

                if (typeof(IProtocolMessageInterface).IsAssignableFrom(types[i]) &&
                    types[i].IsAbstract

                    )
                {
                    ModuleList.Add(types[i]);
                }
            }

            //进行排序
            msgList.Sort(sort);

            StructList.Clear();

            for (int i = 0; i < types.Length; i++)
            {
                if (typeof(IProtocolStructInterface).IsAssignableFrom(types[i]) &&
                    types[i] != typeof(IProtocolStructInterface)
                    )
                {
                    StructList.Add(types[i]);
                }
            }
        }
        static string GeneratePrototalList()
        {
            string content = "";
            int    index   = 1;

            List <Type> ModuleList = new List <Type>();

            Type[] types = ReflectTool.GetTypes();

            for (int i = 0; i < types.Length; i++)
            {
                if (typeof(IProtocolMessageInterface).IsAssignableFrom(types[i]) &&
                    types[i] != typeof(IProtocolMessageInterface) &&
                    types[i] != typeof(CsharpProtocolInterface) &&
                    types[i].IsAbstract &&
                    GetIsModule(types[i])
                    )
                {
                    ModuleList.Add(types[i]);
                }
            }

            ModuleList.Sort(sort);

            //无模块消息
            {
                int           count    = 0;
                List <string> nameList = new List <string>();

                for (int i = 0; i < msgList.Count; i++)
                {
                    if (GetModuleName(msgList[i], true) == null)
                    {
                        string nameTmp = GenerateProtocolName(msgList[i]);

                        if (!nameList.Contains(nameTmp))
                        {
                            nameList.Add(nameTmp);
                        }
                    }
                }

                for (int i = 0; i < nameList.Count; i++)
                {
                    content += i + "," + nameList[i] + "\n";

                    count++;

                    if (count >= c_modMaxMessageCount)
                    {
                        throw new Exception("无模块下的消息超过了 " + c_modMaxMessageCount + " !");
                    }
                }
            }

            for (int i = 0; i < ModuleList.Count; i++)
            {
                int           count    = 0;
                List <string> nameList = new List <string>();

                if (i != 0)
                {
                    content += "\n";
                }

                //生成模块头
                object[] objs = ModuleList[i].GetCustomAttributes(typeof(ModuleAttribute), true);

                if (objs.Length == 0)
                {
                    throw new Exception(ModuleList[i] + " 必须要有 Module 特性 !");
                }

                ModuleAttribute mod = (ModuleAttribute)objs[0];
                index    = mod.MessageCode;
                content += index + "," + mod.ModuleName + "\n";
                index    = index * c_modMaxMessageCount + 1;

                for (int j = 0; j < msgList.Count; j++)
                {
                    if (msgList[j].IsSubclassOf(ModuleList[i]))
                    {
                        string nameTmp = GenerateProtocolName(msgList[j]);
                        if (!nameList.Contains(nameTmp))
                        {
                            nameList.Add(nameTmp);
                        }
                    }
                }

                for (int j = 0; j < nameList.Count; j++)
                {
                    content += index++ + "," + nameList[j] + "\n";

                    count++;

                    if (count >= c_modMaxMessageCount)
                    {
                        throw new Exception(mod.ModuleName + "模块下的消息超过了 " + c_modMaxMessageCount + " !");
                    }
                }
            }

            return(content);
        }