I have a class
public class ProductionQueue
{
/// <summary>
/// Gets or sets the title.
/// </summary>
/// <value>
/// The title.
/// </value>
public string? Name { get; set; }
/// <summary>
/// Maximum capacity of the queue. Keep it null for inifinte capacity.
/// </summary>
public TimeSpan? Capacity { get; set; }
/// <summary>
/// Gets or sets the tasks.
/// </summary>
/// <value>
/// The tasks.
/// </value>
public IList<Task> Tasks { get; set; } = new List<Task>();
}
Let me just explain that the Task object also contains a variable (probably another Timespan) that contains the time to perform the task.
Is it possible to add an event, an observer or any other behaviour in my ProductionQueue to throw an exception if my Capacity is reached when I add a new task in my Task list?