/// <summary> /// <para>SwitchController를 Dictionary에 추가</para> /// </summary> public void RegisterSwitch(SwitchController switchController) { if (switchController.IsRegistered) { return; } var switchId = switchController.SwitchId; if (!_switchDataDic.TryGetValue(switchId, out var switchData)) { //스위치 데이터 생성 switchData = SwitchData.CreateSwitchData(switchId); if (switchData == null) { return; } switchData.Action = switchController.OnSwitch; _switchDataDic.Add(switchController.SwitchId, switchData); } else { _switchDataDic[switchController.SwitchId].Action += switchController.OnSwitch; } switchController.IsRegistered = true; // AddRequireUpdatingSwitchIdList(switchId); switchController.OnSwitch(switchData.CurrentResult); }
public void CancelRegisterSwitch(SwitchController switchController) { if (switchController.IsRegistered) { return; } var switchId = switchController.SwitchId; if (_switchDataDic.ContainsKey(switchId)) { _switchDataDic[switchController.SwitchId].Action -= switchController.OnSwitch; } switchController.IsRegistered = false; }