public HotfixBasicEnvironment(Assembly hotfixAssembly) { Type[] types = hotfixAssembly.GetTypes(); for (int i = 0; i < types.Length; i++) { if (types[i].BaseType == typeof(HotfixProcedure)) { HotfixProcedureStateAttribute hpsa = types[i].GetCustomAttribute <HotfixProcedureStateAttribute>(); if (hpsa != null) { if (hpsa.State == HotfixProcedureState.Entrance) { _entranceProcedure = types[i]; if (!_procedureInstances.ContainsKey(types[i])) { _procedureInstances.Add(types[i], Activator.CreateInstance(types[i]) as HotfixProcedure); } } else if (hpsa.State == HotfixProcedureState.Normal) { if (!_procedureInstances.ContainsKey(types[i])) { _procedureInstances.Add(types[i], Activator.CreateInstance(types[i]) as HotfixProcedure); } } } } } foreach (KeyValuePair <Type, HotfixProcedure> procedureInstance in _procedureInstances) { procedureInstance.Value.OnInit(); } if (_entranceProcedure != null) { _currentProcedure = _procedureInstances[_entranceProcedure]; _currentProcedure.OnEnter(); } else { GlobalTools.LogError("进入热更新流程失败:未指定热更新入口流程!"); } Main.m_Hotfix.UpdateHotfixLogicEvent += UpdateHotfixLogic; }
public HotfixBasicEnvironment(Assembly hotfixAssembly) { Type[] types = hotfixAssembly.GetTypes(); for (int i = 0; i < types.Length; i++) { if (types[i].IsSubclassOf(typeof(HotfixProcedureBase))) { HotfixProcedureStateAttribute hpsa = types[i].GetCustomAttribute <HotfixProcedureStateAttribute>(); if (hpsa != null) { if (hpsa.State == HotfixProcedureState.Entrance) { _entranceProcedure = types[i]; if (!_procedureInstances.ContainsKey(types[i])) { _procedureInstances.Add(types[i], Activator.CreateInstance(types[i]) as HotfixProcedureBase); } } else if (hpsa.State == HotfixProcedureState.Normal) { if (!_procedureInstances.ContainsKey(types[i])) { _procedureInstances.Add(types[i], Activator.CreateInstance(types[i]) as HotfixProcedureBase); } } } } } foreach (var procedureInstance in _procedureInstances) { procedureInstance.Value.OnInit(); } if (_entranceProcedure != null) { _currentProcedure = _procedureInstances[_entranceProcedure]; _currentProcedure.OnEnter(); } else { throw new HTFrameworkException(HTFrameworkModule.Hotfix, "进入热更新流程失败:未指定热更新入口流程!"); } Main.m_Hotfix.UpdateHotfixLogicEvent += UpdateHotfixLogic; }