private void RegisterContainerActions(IActionContainer container) { bool isFirstMenuItem = true; foreach (ActionBase action in container.Actions) { action.Changed -= new EventHandler <ActionChangedEventArgs>(Action_Changed); action.Changed += new EventHandler <ActionChangedEventArgs>(Action_Changed); if (action.Active && action.Enabled) { CustomCreateActionControlEventArgs customCreateActionControlEventArgs = new CustomCreateActionControlEventArgs(action, container); if (CustomGenerateActionControl != null) { CustomGenerateActionControl(this, customCreateActionControlEventArgs); } if (!customCreateActionControlEventArgs.Handled) { MenuActionItemBase actionObject = GenerateactionObject(action); actionObjects[action] = actionObject; if (isFirstMenuItem) { actionObject.MenuItem.SlidingBeginGroup = true; isFirstMenuItem = false; } MenuActionItemCreatedEventArgs args = new MenuActionItemCreatedEventArgs(actionObject); OnMenuactionObjectCreated(args); } } } }
/// <summary> /// Creates an instance of this action in the sqlite db for tracking status. /// </summary> /// <param name="parentContext">The parent of the action; if the parent is the Plan, ParentId = null.</param> internal void CreateInstance(IActionContainer parentContext, long planInstanceId) { PlanInstanceId = planInstanceId; long? parentId = null; if( parentContext is ActionItem ) parentId = ((ActionItem)parentContext).InstanceId; CreateInstance( parentId ); }
protected Action(Argument argument, IActionContainer container=null) { Argument = argument; Container = container; OptionStrings = new List<string>(Argument.OptionStrings ?? new string[] {}); Destination = Argument.Destination; IsRequired = Argument.IsRequired; }
private void AddScope(IActionContainer scope, SwfReader r) { scopes.Push(scope); scopeBounds.Push(r.Position + scope.CodeSize); curScope = scope; curBounds = r.Position + scope.CodeSize; curStatements = scope.Statements; }
private void RemoveScope() { scopes.Pop(); scopeBounds.Pop(); curScope = scopes.Peek(); curBounds = scopeBounds.Peek(); curStatements = scopes.Peek().Statements; }
private void Frame_TemplateChanged(object sender, EventArgs e) { IActionContainer navigationControl = FindNavigationActionContainer(); if (navigationControl != null) { SetupNavigationControl(navigationControl); } }
private void UnsubsribeActionEvents(IActionContainer container) { if (container != null) { foreach (ActionBase action in container.Actions) { action.Changed -= new EventHandler <ActionChangedEventArgs>(Action_Changed); } } }
public ActionContainer(ParserSettings parserSettings = null, IActionContainer container = null) { parserSettings = parserSettings ?? new ParserSettings(); typeFactoriesByName = new Dictionary<string, Func<string, object>>(StringComparer.InvariantCultureIgnoreCase); DefaultTypeFactory = argString => argString; AddSimpleTypeFactories(new Dictionary<string, Type> { {"int", typeof (int)}, {"uint", typeof (uint)}, {"float", typeof (float)}, {"double", typeof (double)}, {"datetime", typeof (DateTime)}, {"timespan", typeof (TimeSpan)} }); Prefixes = parserSettings.Prefixes; ConflictHandlerType = parserSettings.ConflictHandlerType; DefaultAction = "store"; actionFactories = new Dictionary<string, Func<Argument, Action>>(StringComparer.InvariantCultureIgnoreCase); RegisterActions(new Dictionary<string, Func<Argument, Action>> { {"store", arg => new StoreAction(arg, this)}, {"store_const", arg => new StoreConstAction(arg, this)}, {"store_true", arg => new StoreTrueAction(arg, this)}, {"store_false", arg => new StoreFalseAction(arg, this)}, {"append", arg => new AppendAction(arg, this)}, {"append_const", arg => new AppendConstAction(arg, this)}, {"count", arg => new CountAction(arg, this)}, {"parsers", arg => new SubParsersAction(arg, this)}, }); //check conflict resolving GetConflictHandler(); actions = new List<Action>(); optionStringActions = new Dictionary<string, Action>(StringComparer.InvariantCulture); //groups ActionGroups = new List<ArgumentGroup>(); MutuallyExclusiveGroups = new List<MutuallyExclusiveGroup>(); // determines whether an "option" looks like a negative number negativeNumberMatcher = new Regex(@"^-\d+(\.\d*)?$|^-\.\d+$"); // whether or not there are any optionals that look like negative // numbers -- uses a list so it can be shared and edited HasNegativeNumberOptionals = new List<bool>(); Container = container ?? this; }
protected override void SetupNavigationControl(IActionContainer container) { NavigationActionContainer navigationActionContainer = (NavigationActionContainer)container; NavBarNavigationControl navBar = navigationActionContainer.NavigationControl as NavBarNavigationControl; if (navBar != null) { navBar.ActiveGroupChanged += navBar_ActiveGroupChanged; } TreeListNavigationControl treeList = navigationActionContainer.NavigationControl as TreeListNavigationControl; if (treeList != null) { treeList.FocusedNodeChanged += treeList_FocusedNodeChanged; } }
public AppendAction(Argument argument, IActionContainer container) : base(argument, container) { }
public SubParsersAction(Argument argument, IActionContainer container) : base(argument, container) { subParsers = new SortedDictionary<string, IArgumentParser>(StringComparer.InvariantCulture); }
public StoreTrueAction(Argument argument, IActionContainer container) : base(argument,container) { }
void ProcessRecursive(IActionContainer parentContext, SecurityContext parentSecurityContext, ActionItem actionGroup, List <ActionItem> actions, ExecuteResult parentResult, Dictionary <string, string> dynamicData, bool dryRun, Func <SecurityContext, ActionItem, Dictionary <string, string>, object, bool, ExecuteResult> executeHandlerMethod) { if (WantsStopOrPause()) { return; } parentContext.EnsureInitialized(); //queryStatus provides the inbound value to ExecuteCase evaluation; it's the ExecuteCase comparison value. //queryStatus is carried downward through successive subtree executions. StatusType queryStatus = parentResult.Status; #region actionGroup if (actionGroup != null && (((actionGroup.ExecuteCase & parentResult.Status) == actionGroup.ExecuteCase) || (actionGroup.ExecuteCase == StatusType.Any))) { actionGroup.EnsureInitialized(); #region actionGroup-forEach if ((actionGroup.HasParameters && actionGroup.Parameters.HasForEach) || (actionGroup.Handler.HasConfig && actionGroup.Handler.Config.HasForEach)) { List <ActionItem> resolvedParmsActionGroup = new List <ActionItem>(); ResolveConfigAndParameters(actionGroup, dynamicData, ref resolvedParmsActionGroup, parentResult.ExitData); foreach (ActionItem ai in resolvedParmsActionGroup) { ai.Parameters.ForEach = null; } actionGroup.InstanceId = ActionInstanceIdCounter++; ActionItem agclone = actionGroup.Clone(); agclone.Result = new ExecuteResult(); parentContext.ActionGroup = agclone; Parallel.ForEach(resolvedParmsActionGroup, a => // foreach( ActionItem a in resolvedParmsActionGroup ) { #if sqlite a.CreateInstance(parentContext, InstanceId); #endif a.InstanceId = ActionInstanceIdCounter++; ActionItem clone = a.Clone(); agclone.Actions.Add(clone); ExecuteResult r = executeHandlerMethod(parentSecurityContext, a, dynamicData, parentResult.ExitData, dryRun); parentContext.ActionGroup.Result.SetBranchStatusChecked(r); parentContext.Result.SetBranchStatusChecked(r); clone.Handler.Type = actionGroup.Handler.Type; clone.Handler.StartInfo = actionGroup.Handler.StartInfo; clone.Result = r; if (r.Status > queryStatus) { queryStatus = r.Status; } if (a.HasActions) { ProcessRecursive(clone, a.RunAs, a.ActionGroup, a.Actions, r, dynamicData, dryRun, executeHandlerMethod); parentContext.ActionGroup.Result.SetBranchStatusChecked(clone.Result); parentContext.Result.SetBranchStatusChecked(clone.Result); if (clone.Result.Status > queryStatus) { queryStatus = clone.Result.Status; } } }); } #endregion #region actionGroup-single else { #if sqlite actionGroup.CreateInstance(parentContext, InstanceId); #endif ResolveConfigAndParameters(actionGroup, dynamicData, parentResult.ExitData); actionGroup.InstanceId = ActionInstanceIdCounter++; ActionItem clone = actionGroup.Clone(); parentContext.ActionGroup = clone; ExecuteResult r = executeHandlerMethod(parentSecurityContext, actionGroup, dynamicData, parentResult.ExitData, dryRun); parentContext.Result.SetBranchStatusChecked(r); clone.Handler.Type = actionGroup.Handler.Type; clone.Handler.StartInfo = actionGroup.Handler.StartInfo; clone.Result = r; if (r.Status > queryStatus) { queryStatus = r.Status; } if (actionGroup.HasActions) { ProcessRecursive(clone, actionGroup.RunAs, null, actionGroup.Actions, r, dynamicData, dryRun, executeHandlerMethod); parentContext.Result.SetBranchStatusChecked(clone.Result); if (clone.Result.Status > queryStatus) { queryStatus = clone.Result.Status; } } } #endregion } #endregion #region actions IEnumerable <ActionItem> actionList = actions.Where(a => (((a.ExecuteCase & queryStatus) == a.ExecuteCase) || (a.ExecuteCase == StatusType.Any))); List <ActionItem> resolvedParmsActions = new List <ActionItem>(); Parallel.ForEach(actionList, a => // foreach( ActionItem a in actionList ) ResolveConfigAndParameters(a, dynamicData, ref resolvedParmsActions, parentResult.ExitData) ); Parallel.ForEach(resolvedParmsActions, a => // foreach( ActionItem a in resolvedParmsActions ) { #if sqlite a.CreateInstance(parentContext, InstanceId); #endif a.InstanceId = ActionInstanceIdCounter++; ActionItem clone = a.Clone(); parentContext.Actions.Add(clone); ExecuteResult r = a.Result; if (r?.Status != StatusType.Failed) { r = executeHandlerMethod(parentSecurityContext, a, dynamicData, parentResult.ExitData, dryRun); } parentContext.Result.SetBranchStatusChecked(r); clone.Handler.Type = a.Handler.Type; clone.Handler.StartInfo = a.Handler.StartInfo; clone.Result = r; if (a.HasActions) { ProcessRecursive(clone, a.RunAs, a.ActionGroup, a.Actions, r, dynamicData, dryRun, executeHandlerMethod); parentContext.Result.SetBranchStatusChecked(clone.Result); } }); #endregion }
public AppendConstAction(Argument argument, IActionContainer container) : base(argument, container) { valueCount = new ValueCount(0); }
protected abstract void SetupNavigationControl(IActionContainer container);
private void UnsubsribeActionEvents(IActionContainer container) { if (container != null) { foreach (ActionBase action in container.Actions) { action.Changed -= new EventHandler<ActionChangedEventArgs>(Action_Changed); } } }
private void RegisterContainerActions(IActionContainer container) { bool isFirstMenuItem = true; foreach (ActionBase action in container.Actions) { action.Changed -= new EventHandler<ActionChangedEventArgs>(Action_Changed); action.Changed += new EventHandler<ActionChangedEventArgs>(Action_Changed); if (action.Active && action.Enabled) { CustomCreateActionControlEventArgs customCreateActionControlEventArgs = new CustomCreateActionControlEventArgs(action, container); if (CustomGenerateActionControl != null) { CustomGenerateActionControl(this, customCreateActionControlEventArgs); } if (!customCreateActionControlEventArgs.Handled) { MenuActionItemBase actionObject = GenerateactionObject(action); actionObjects[action] = actionObject; if (isFirstMenuItem) { actionObject.MenuItem.SlidingBeginGroup = true; isFirstMenuItem = false; } MenuActionItemCreatedEventArgs args = new MenuActionItemCreatedEventArgs(actionObject); OnMenuactionObjectCreated(args); } } } }
public ArgumentGroup(IActionContainer container) : base(container: container) { GroupActions = new List<Action>(); }