public void Register(int startupCount, ActionExecutionRule executionRule, Action action, bool persistent = false) { var startupAction = new StartupAction(action, persistent); switch (executionRule) { case ActionExecutionRule.LessThan: AddAction(_actionsLessThan, startupCount, startupAction); break; case ActionExecutionRule.LessOrEquals: AddAction(_actionsLessThan, startupCount, startupAction); AddAction(_actionsEquals, startupCount, startupAction); break; case ActionExecutionRule.Equals: AddAction(_actionsEquals, startupCount, startupAction); break; case ActionExecutionRule.MoreOrEquals: AddAction(_actionsEquals, startupCount, startupAction); AddAction(_actionsMoreThan, startupCount, startupAction); break; case ActionExecutionRule.MoreThan: AddAction(_actionsMoreThan, startupCount, startupAction); break; } }
/// <summary> /// Adds an action to the given dictionary-list container. /// </summary> /// <param name="container">The dictionary container.</param> /// <param name="startupCount">The startup count key.</param> /// <param name="action">The startup action.</param> private void AddAction(Dictionary <int, List <StartupAction> > container, int startupCount, StartupAction action) { if (!container.ContainsKey(startupCount)) { container[startupCount] = new List <StartupAction>(); } container[startupCount].Add(action); }