private void SearchHotfixMethod()
        {
            Type[] types = HotfixAssembly.GetTypes();
            for (int i = 0; i < types.Length; i++)
            {
                MethodInfo[] methods = types[i].GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
                for (int j = 0; j < methods.Length; j++)
                {
                    HotfixMethodAttribute att = methods[j].GetCustomAttribute <HotfixMethodAttribute>();
                    if (att != null)
                    {
                        HotfixMethodType methodType = GetHotfixMethodType(methods[j]);
                        if (!FixedMethods[methodType].ContainsKey(att.TargetName))
                        {
                            FixedMethods[methodType].Add(att.TargetName, methods[j]);
                        }
                    }
                }
            }

            if (FixedMethods[HotfixMethodType.Invalid].Count > 0)
            {
                foreach (var item in FixedMethods[HotfixMethodType.Invalid])
                {
                    Log.Error("发现无效的热修复方法:" + item.Value.Name);
                }
                FixedMethods[HotfixMethodType.Invalid].Clear();
            }
        }
        private void HotfixDllLoadDone(TextAsset asset)
        {
            HotfixDll         = asset;
            HotfixAssembly    = Assembly.Load(HotfixDll.bytes, null);
            HotfixEnvironment = HotfixAssembly.CreateInstance("HotfixEnvironment");

            if (HotfixEnvironment == null)
            {
                throw new HTFrameworkException(HTFrameworkModule.Hotfix, "热更新初始化失败:热更新库中不存在热更新环境 HotfixEnvironment!");
            }

            SearchHotfixMethod();

            Main.m_Event.Throw <EventHotfixReady>();
        }
        void loadDll()
        {
            var types = HotfixAssembly.GetTypes();

            foreach (var type in types)
            {
                addAgent(type);
                addEvent(type);
                addTcpHandler(type);
                addHttpHandler(type);
                if (HotfixBridge == null && type.GetInterface(typeof(IHotfixBridge).FullName) != null)
                {
                    var bridge = (IHotfixBridge)Activator.CreateInstance(type);
                    if (bridge.BridgeType == Settings.Ins.ServerType)
                    {
                        HotfixBridge = bridge;
                    }
                }
            }
        }
        public Task <bool> Load(string dllVersion, bool isReload)
        {
            bool success = false;

            try
            {
                bool   writeDllVersion          = false;
                string currentAssemblyDirectory = Environment.CurrentDirectory;
                string dllPath = Path.Combine(currentAssemblyDirectory, "GeekServer.Hotfix.dll");
                if (!string.IsNullOrEmpty(dllVersion))
                {
                    var path = Path.Combine(currentAssemblyDirectory, dllVersion + "/GeekServer.Hotfix.dll");
                    if (File.Exists(path))
                    {
                        dllPath         = path;
                        writeDllVersion = true;
                    }
                    else
                    {
                        dllVersion = "org";
                    }
                }
                else
                {
                    dllVersion = "org";
                    var txtPath = Path.Combine(currentAssemblyDirectory, "dllVersion.txt");
                    if (File.Exists(txtPath))
                    {
                        var versionStr = File.ReadAllText(txtPath);
                        var path       = Path.Combine(currentAssemblyDirectory, versionStr + "/GeekServer.Hotfix.dll");
                        if (File.Exists(path))
                        {
                            dllPath    = path;
                            dllVersion = versionStr;
                        }
                    }
                }

                dllLoader = new DllLoader(dllPath);
                dllLoader.Load();
                HotfixAssembly = dllLoader.HotfixDll;

                if (!isReload)
                {
                    //依赖的dll
                    var asbArr  = AppDomain.CurrentDomain.GetAssemblies();
                    var asbList = new List <string>();
                    foreach (var asb in asbArr)
                    {
                        asbList.Add(asb.GetName().Name);
                    }
                    var refArr = HotfixAssembly.GetReferencedAssemblies();
                    foreach (var asb in refArr)
                    {
                        if (asbList.Contains(asb.Name))
                        {
                            continue;
                        }
                        var refPath = Environment.CurrentDirectory + $"/{asb.Name}.dll";
                        if (File.Exists(refPath))
                        {
                            Assembly.LoadFrom(refPath);
                        }
                    }
                }

                loadDll();

                if (writeDllVersion)
                {
                    File.WriteAllText(Path.Combine(currentAssemblyDirectory, "dllVersion.txt"), dllVersion);
                }
                LOGGER.Info("hotfix dll loaded:" + dllVersion);
                success = true;
            }
            catch (Exception e)
            {
                if (!isReload)
                {
                    throw e;
                }
                LOGGER.Info("hotfix dll init failed..." + e.ToString());
            }
            return(Task.FromResult(success));
        }