/// <summary> /// Removes all configuration related to a recipe and propagates /// this change to neighbouring stations. /// </summary> /// <param name="recipe"></param> protected void RemoveRecipeConfigurations(Recipe recipe) { var obsoleteRoles = (from role in AllocatedRoles where role.Recipe == recipe select role) .ToArray(); // collect roles before underlying collection is modified var affectedNeighbours = (from role in obsoleteRoles select role.PreCondition.Port) .Concat(from role in obsoleteRoles select role.PostCondition.Port) .Distinct() .Where(neighbour => neighbour != null); foreach (var role in obsoleteRoles) { AllocatedRoles.Remove(role); } foreach (var neighbour in affectedNeighbours) { neighbour.RemoveRecipeConfigurations(recipe); } }
public virtual void Configure(Role role) { AllocatedRoles.Add(role); }