/// <summary> /// Add a build action the collection. /// </summary> /// <param name="action">The action to add.</param> /// <param name="index">The order in which the action should be executed in.</param> public void AddAction(BuildAction action, double index) { if (_buildActions.Any(e => e.Name == action.Name)) { throw new ApplicationBuildException($"There is already a build action with the same name '{action.Name}'"); } action.InvokeOrder = index; _buildActions.Add(action); Log($"Build action Added: {action.Name}"); }
/// <summary> /// Add a build action the collection and executes it after a certain action. /// </summary> /// <param name="actionToAdd">The action to add.</param> /// <param name="targetActionName">The action that this action should be executed after.</param> public void AddActionAfter(BuildAction actionToAdd, string targetActionName) { var action = _buildActions.FirstOrDefault(e => e.Name == targetActionName); if (action == null) { throw new ApplicationBuildException($"Build action '{targetActionName}' was not found."); } _buildActions.OrderBy(e => e.InvokeOrder) .Where(e => e.InvokeOrder > action.InvokeOrder) .ForEach(e => e.InvokeOrder++); AddAction(actionToAdd, action.InvokeOrder + 1); }
/// <summary> /// Add a build action the collection. /// </summary> /// <param name="action">The action to add.</param> public void AddAction(BuildAction action) { AddAction(action, action.DefaultInvokeOrder ?? Convert.ToDouble(_buildActions.Count)); }