public void AddController(string key, Controller controller, bool enableController) { if (_relatedControllers.ContainsKey(key)) { Controller existingController = (Controller)_relatedControllers[key]; if (existingController == controller) { controller = (Controller)_relatedControllers[key]; } else { existingController.DisableController(); _relatedControllers[key] = controller; } } else { _relatedControllers.Add(key, controller); } if (enableController) { controller.EnableController(); } else { controller.DisableController(); } }
public void RemoveController(Controller controller) { if (_relatedControllers.ContainsValue(controller)) { controller.DisableController(); object key = GetRelatedControllerKey(controller); if (key != null) { _relatedControllers.Remove(key); } } }