public FeatureAction (XPathNavigator nav) { string val = Helpers.GetRequiredNonEmptyAttribute (nav, "type"); type = Helpers.ConvertEnum <ActionType> (val, "type"); val = Helpers.GetRequiredNonEmptyAttribute (nav, "when"); when = Helpers.ConvertEnum <ActionWhen> (val, "when"); XPathNodeIterator iter; StringBuilder sb = new StringBuilder (); switch (type) { case ActionType.Message: case ActionType.ShellScript: iter = nav.Select ("./text()"); while (iter.MoveNext ()) sb.Append (iter.Current.Value); if (type == ActionType.Message) message = sb.ToString (); else script = sb.ToString (); break; case ActionType.Exec: command = Helpers.GetRequiredNonEmptyAttribute (nav, "command"); commandArguments = Helpers.GetOptionalAttribute (nav, "commndArguments"); break; } }
/// <summary> /// Execute the specified actions in list. /// /// NOTE if execute fail do we want to stop update by returning false ? /// </summary> /// <param name="actionList">The action list.</param> /// <param name="when">The when. to execute </param> /// <returns>Bool true or false</returns> public bool Execut(List <Action> actionList, ActionWhen when) { if (actionList != null && actionList.Count > 0) { foreach (var action in actionList) { if (action.When == when) { if (action.StartStop == ActionStartStop.Start) { if (!ActionStart(action)) { return(false); } } else { if (!ActionStop(action)) { return(false); } } } return(false); } } return(false); }
public FeatureAction(XPathNavigator nav) { string val = Helpers.GetRequiredNonEmptyAttribute(nav, "type"); type = Helpers.ConvertEnum <ActionType> (val, "type"); val = Helpers.GetRequiredNonEmptyAttribute(nav, "when"); when = Helpers.ConvertEnum <ActionWhen> (val, "when"); XPathNodeIterator iter; StringBuilder sb = new StringBuilder(); switch (type) { case ActionType.Message: case ActionType.ShellScript: iter = nav.Select("./text()"); while (iter.MoveNext()) { sb.Append(iter.Current.Value); } if (type == ActionType.Message) { message = sb.ToString(); } else { script = sb.ToString(); } break; case ActionType.Exec: command = Helpers.GetRequiredNonEmptyAttribute(nav, "command"); commandArguments = Helpers.GetOptionalAttribute(nav, "commndArguments"); break; } }