/* * Copyright (c) 2025 ETH Zürich, IT Services * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ using System; using System.Collections.Generic; using SafeExamBrowser.Core.Contracts.ResponsibilityModel; using SafeExamBrowser.Logging.Contracts; namespace SafeExamBrowser.Core.ResponsibilityModel { /// /// Default implementation of the . /// /// public class ResponsibilityCollection : IResponsibilityCollection { protected ILogger logger; protected Queue> responsibilities; public ResponsibilityCollection(ILogger logger, IEnumerable> responsibilities) { this.logger = logger; this.responsibilities = new Queue>(responsibilities); } public void Delegate(T task) { foreach (var responsibility in responsibilities) { try { responsibility.Assume(task); } catch (Exception e) { logger.Error($"Caught unexpected exception while '{responsibility.GetType().Name}' was assuming task '{task}'!", e); } } } } }