/// <summary> /// Inserts the specified actions into this model in the specified order. /// </summary> /// <param name="actions">The actions to insert.</param> public void InsertActions(IAction[] actions) { foreach (IAction action in actions) { InsertAction(action); } }
// REGISTATION public static void Register(IAction instance) { if (FindInstance(instance.ID) == null) { _repository.Register(instance); } }
/// <summary> /// Central method to add and execute a new action. /// </summary> /// <param name="existingAction">An action to be recorded in the buffer and executed</param> public void RecordAction(IAction existingAction) { if (existingAction == null) { throw new ArgumentNullException( "ActionManager.RecordAction: the existingAction argument is null"); } // make sure we're not inside an Undo or Redo operation CheckNotRunningBeforeRecording(existingAction); // if we don't want to record actions, just run and forget it if (ExecuteImmediatelyWithoutRecording && existingAction.CanExecute()) { existingAction.Execute(); return; } // Check if we're inside a transaction that is being recorded ITransaction currentTransaction = RecordingTransaction; if (currentTransaction != null) { // if we're inside a transaction, just add the action to the transaction's list currentTransaction.AccumulatingAction.Add(existingAction); if (!currentTransaction.IsDelayed) { existingAction.Execute(); } } else { RunActionDirectly(existingAction); } }
public void AddAction(IAction action) { lock (_actions) { _actions.Enqueue(action); } }
private DenyResult[] GetDenyActions(ISubject subject, IAction[] actions, ISecurityObjectId objectId, ISecurityObjectProvider securityObjProvider) { var denyActions = new List<DenyResult>(); if (actions == null) actions = new IAction[0]; if (subject == null) { denyActions = actions.Select(a => new DenyResult(a, null, null)).ToList(); } else if (subject is ISystemAccount && subject.ID == Constants.CoreSystem.ID) { // allow all } else { ISubject denySubject = null; IAction denyAction = null; foreach (var action in actions) { var allow = azManager.CheckPermission(subject, action, objectId, securityObjProvider, out denySubject, out denyAction); if (!allow) { denyActions.Add(new DenyResult(action, denySubject, denyAction)); break; } } } return denyActions.ToArray(); }
public static void SetProperties(IAction action) { foreach (PropertyInfo pi in action.GetType().GetProperties()) { object[] propertyAttributes = pi.GetCustomAttributes(typeof(ActionPropertyAttribute), false); if (propertyAttributes.Length == 1) { if (action.Fields.ContainsKey(pi.Name)) { pi.SetValue(action, Convert.ChangeType(ValueStringEvaluator.Evaluate(action.Fields[pi.Name], action.ParentBuildFile), pi.PropertyType), null); action.Fields.Remove(pi.Name); } else { ActionPropertyAttribute apa = (ActionPropertyAttribute)propertyAttributes[0]; if (apa.IsRequired) throw new ActionPropertyNotSetException(action, pi, "The value for a required property was not set."); } } } EvaluateFields(action); }
ActionInfo get(IAction action) { lock (lockObj) { return actionStore[ID].Actions.FirstOrDefault( a => a.Order == action.Order && a.IsLast); } }
public static void AddAction(IAction action) { lock (m_actionQueue) { m_actionQueue.Enqueue(action); } }
/// <summary> /// Sets the tooltip text on the specified item, from the specified action. /// </summary> /// <param name="item"></param> /// <param name="action"></param> internal static void SetTooltipText(ToolStripItem item, IAction action) { var actionTooltip = action.Tooltip; if (string.IsNullOrEmpty(actionTooltip)) actionTooltip = (action.Label ?? string.Empty).Replace("&", ""); var clickAction = action as IClickAction; if (clickAction == null || clickAction.KeyStroke == XKeys.None) { item.ToolTipText = actionTooltip; return; } var keyCode = clickAction.KeyStroke & XKeys.KeyCode; var builder = new StringBuilder(); builder.Append(actionTooltip); if (keyCode != XKeys.None) { if (builder.Length > 0) builder.AppendLine(); builder.AppendFormat("{0}: ", SR.LabelKeyboardShortcut); builder.Append(XKeysConverter.Format(clickAction.KeyStroke)); } item.ToolTipText = builder.ToString(); }
protected override void OnProcess(IAction action) { BrowserAction pageAction = action as BrowserAction; webBrowser.Navigate(pageAction.Url); LoggerManager.Debug(action.AutomationActionData); }
internal static string FormatErrorMessage(ISubject subject, IAction[] actions, ISubject[] denySubjects, IAction[] denyActions) { if (subject == null) throw new ArgumentNullException("subject"); if (actions == null || actions.Length == 0) throw new ArgumentNullException("actions"); if (denySubjects == null || denySubjects.Length == 0) throw new ArgumentNullException("denySubjects"); if (denyActions == null || denyActions.Length == 0) throw new ArgumentNullException("denyActions"); if (actions.Length != denySubjects.Length || actions.Length != denyActions.Length) throw new ArgumentException(); string reasons = ""; for (int i = 0; i < actions.Length; i++) { string reason = ""; if (denySubjects[i] != null && denyActions[i] != null) reason = String.Format("{0}:{1} access denied {2}.", actions[i].Name, (denySubjects[i] is IRole ? "role:" : "") + denySubjects[i].Name, denyActions[i].Name ); else reason = String.Format("{0}: access denied.", actions[i].Name); if (i != actions.Length - 1) reason += ", "; reasons += reason; } string sactions = ""; Array.ForEach(actions, action => { sactions += action.ToString() + ", "; }); string message = String.Format( "\"{0}\" access denied \"{1}\". Cause: {2}.", (subject is IRole ? "role:" : "") + subject.Name, sactions, reasons ); return message; }
public static ImmutableArray<Todo> TodosReducer(ImmutableArray<Todo> previousState, IAction action) { if (action is AddTodoAction) { return AddTodoReducer(previousState, (AddTodoAction)action); } if (action is ClearCompletedTodosAction) { return ClearCompletedTodosReducer(previousState, (ClearCompletedTodosAction)action); } if (action is CompleteAllTodosAction) { return CompleteAllTodosReducer(previousState, (CompleteAllTodosAction)action); } if (action is CompleteTodoAction) { return CompleteTodoReducer(previousState, (CompleteTodoAction)action); } if (action is DeleteTodoAction) { return DeleteTodoReducer(previousState, (DeleteTodoAction)action); } return previousState; }
public override IActionResult Execute(object pSouce, IAction pAction) { if (pAction is LoadAction) { return ExecuteToChildren(new LoadAction(this)); } var startReadAction = pAction as StartReadAction; if (startReadAction != null) { return StartRead(startReadAction); } var selectItemAction = pAction as SelectItemAction; if (selectItemAction != null) { try { SelectItem(selectItemAction); } catch (InvalidOperationException ex) { //TODO: manage exception: log it and show any information to the user? SelectedChapter = null; } } var startReadSelectedChapterAction = pAction as StartReadSelectedChapterAction; if (startReadSelectedChapterAction != null) { return StartReadSelectedChapter(startReadSelectedChapterAction); } return base.Execute(pSouce, pAction); }
public static ApplicationState ReduceApplicationState(ApplicationState state, IAction action) { return new ApplicationState { Repositories = ReduceRepositories(state.Repositories, action) }; }
public void Add(IAction action) { if(action.GetType() == typeof(SelectionAction) && firstSelectionAction == null) firstSelectionAction = (SelectionAction)action; else if (action.GetType() == typeof(BiomeAction) && firstBiomeAction == null) firstBiomeAction = (BiomeAction)action; else if (action.GetType() == typeof(PopulateAction) && firstPopulateAction == null) firstPopulateAction = (PopulateAction)action; //ensure the first action of each type isn't lost when the redo stack is emptied if(firstSelectionAction != null && action != firstSelectionAction && redoStack.Contains(firstSelectionAction)) { redoStack.Remove(firstSelectionAction); undoStack.AddLast(firstSelectionAction); } if (firstBiomeAction != null && action != firstBiomeAction && redoStack.Contains(firstBiomeAction)) { redoStack.Remove(firstBiomeAction); undoStack.AddLast(firstBiomeAction); } if (firstPopulateAction != null && action != firstPopulateAction && redoStack.Contains(firstPopulateAction)) { redoStack.Remove(firstPopulateAction); undoStack.AddLast(firstPopulateAction); } action.PreviousAction = GetPreviousAction(undoStack.Last, action.GetType()); undoStack.AddLast(action); foreach (IAction a in redoStack) a.Dispose(); redoStack.Clear(); }
public CallAction( Guid ownerId, MemberInfo[] propertiesPath, MethodInfo methodInfo, IAction[] parameters ) { this._propertiesPath = propertiesPath; this._ownerId = ownerId; this._parameters = parameters; this._methodInfo = methodInfo; }
public static IEnumerable<IActionResult> ExecuteToChildren( IManager pManager, IAction pAction, bool pCheckSource) { ArgumentsValidation.NotNull(pManager, "pManager"); ArgumentsValidation.NotNull(pAction, "pAction"); var result = new List<IActionResult>(); var children = pManager.GetChildren(); if (children != null) { var checkedChildren = children.Where(x => !pCheckSource || !ReferenceEquals(x, pAction.GetSource())); foreach (var child in checkedChildren) { var r = child.Execute(pManager, pAction); if (r == null || r is NotAvailableActionResult) { continue; } result.Add(r); } } return new ReadOnlyCollection<IActionResult>(result); }
public void Notify(IAction a) { foreach (IObserver observer in _observers) { observer.DoAction(a); } }
// Use this for initialization void Start() { rBody = GetComponent<Rigidbody2D>(); //sGround = GetComponent<StayGrounded>(); groundCheck = GetComponentInChildren<IsGrounded>(); iCont = GetComponent<InputController>(); IAction[] attachedActions = GetComponents<IAction>(); for (int i = 0; i < attachedActions.Length; i++) { if (attachedActions[i].IsAttack()) specialAttack = attachedActions[i]; else specialDefense = attachedActions[i]; } GameObject go = GameObject.FindGameObjectWithTag("Baton"); if (go != null) crown = go.transform; startLocation = transform.position; renderers = new List<SpriteRenderer>(); renderers.AddRange(GetComponentsInChildren<SpriteRenderer>()); renderers.Add(GetComponent<SpriteRenderer>()); colliders = new List<Collider2D>(); colliders.AddRange(GetComponentsInChildren<Collider2D>()); colliders.AddRange(GetComponents<Collider2D>()); aController = GetComponent<Animator>(); crownLocation = transform.FindChild("CrownLocation"); GetComponentInChildren<TankGun>().playerID = playerID; movementSpeed *= Manager.instance.moveMultiplier; explosionParticles = transform.FindChild("player explosion").GetComponent<ParticleSystem>(); jumpParticles = transform.FindChild("Jump poof").GetComponent<ParticleSystem>(); dustParticles = transform.FindChild("dust poof").GetComponent<ParticleSystem>(); }
/// <summary> /// Initializes a new MDPSuccessorState. /// </summary> /// <param name="action">Action to the state.</param> /// <param name="cost">Cost of the transition state.</param> /// <param name="state">Transition state.</param> /// <param name="reward">Reward value.</param> public MDPSuccessorState(IAction action, double cost, IMDPState state, double reward) { this.Action = action; this.Cost = cost; this.State = state; this.Reward = reward; }
/// <summary> /// Registers a possible action /// </summary> /// <param name="action">The action to register</param> private static void RegisterAction(IAction action) { if(action == null) throw new ArgumentException("Action can't be null!","action"); m_actions.Add(action); }
protected override void OnProcess(IAction action) { base.OnProcess(action); HtmlElement element = this.GetData(action) as HtmlElement; if (element == null) { LoggerManager.Error("Element Not Found"); throw new ElementNoFoundException("Element Not Found", action); } LoggerManager.Debug(action.AutomationActionData); ClickAction clickAction = action as ClickAction; if (clickAction == null) { return; } if (clickAction.Click) { LoggerManager.Debug("Trigger Click"); this.Call<HtmlElement>(Click, element); } if (clickAction.ClickNew) { LoggerManager.Debug("Trigger ClickNew"); this.Call<HtmlElement>(ClickNew, element); } if (clickAction.MouseClick) { LoggerManager.Debug("Trigger MouseClick"); this.Call<HtmlElement>(MouseClick, element); } }
public TimeMachineState Execute(TimeMachineState previousState, IAction action) { if(action is ResumeTimeMachineAction) { return previousState .WithIsPaused(false) .WithStates(previousState.States.Take(previousState.Position + 1).ToImmutableList()) .WithActions(previousState.Actions.Take(previousState.Position).ToImmutableList()); } if(action is PauseTimeMachineAction) { return previousState .WithIsPaused(true); } if(action is SetTimeMachinePositionAction) { return previousState .WithPosition(((SetTimeMachinePositionAction)action).Position) .WithIsPaused(true); } if (previousState.IsPaused) { return previousState; } var innerState = _reducer(previousState.States.Last(), action); return previousState .WithStates(previousState.States.Add(innerState)) .WithActions(previousState.Actions.Add(action)) .WithPosition(previousState.Position + 1); }
public RollerShutter( ComponentId id, IRollerShutterEndpoint endpoint, ITimerService timerService, ISchedulerService schedulerService, ISettingsService settingsService) : base(id) { if (id == null) throw new ArgumentNullException(nameof(id)); if (endpoint == null) throw new ArgumentNullException(nameof(endpoint)); if (schedulerService == null) throw new ArgumentNullException(nameof(schedulerService)); if (settingsService == null) throw new ArgumentNullException(nameof(settingsService)); _endpoint = endpoint; _schedulerService = schedulerService; settingsService.CreateSettingsMonitor<RollerShutterSettings>(Id, s => Settings = s); timerService.Tick += (s, e) => UpdatePosition(e); _startMoveUpAction = new Action(() => SetState(RollerShutterStateId.MovingUp)); _turnOffAction = new Action(() => SetState(RollerShutterStateId.Off)); _startMoveDownAction = new Action(() => SetState(RollerShutterStateId.MovingDown)); endpoint.Stop(HardwareParameter.ForceUpdateState); }
public void Append (IAction action) { if (action == null) throw new ArgumentNullException ("action"); actions.Add (action); }
public void AddAction(IAction action) { string ID = action.ID; System.Windows.Forms.MenuItem menuItem = new System.Windows.Forms.MenuItem(ID); menuItem.Click += new System.EventHandler(this.MainWindow_ActionSelect); menuItem.Tag = action; System.Windows.Forms.MenuItem menuMain = this.menuItemActions; if (menuMain == null) { LoggerFactory.Default.Log("Could not register IAction in IDE", action.EffectiveID); return; }; string category = action.Category; if ((category == "") || (category == null)) { menuMain.MenuItems.Add(menuItem); } else { System.Windows.Forms.MenuItem categoryItem = findCategoryMenu(menuMain, category); if (categoryItem == null) { categoryItem = new System.Windows.Forms.MenuItem(category); menuMain.MenuItems.Add(categoryItem); } addSortedActionInCategory(categoryItem, menuItem); } }
public Automation WithActionIfConditionsNotFulfilled(IAction action) { if (action == null) throw new ArgumentNullException(nameof(action)); ActionsIfNotFulfilled.Add(action); return this; }
public void Add(IAction action, string tag = "") { if (!m_actions.ContainsKey (tag)) m_actions [tag] = new Queue<IAction> (); m_actions[tag].Enqueue(action); }
public IPlugin ChoosePluginForAction(IAction action) { var capable = Plugins.Where(plugin => plugin.CanHandle(action)); // pretty dumb selection logic for now, pass in ranking preferences later return capable.FirstOrDefault(); }
protected override void OnProcess(IAction action) { base.OnProcess(action); LoggerManager.Debug(action.AutomationActionData); TextAction textAction = action as TextAction; HtmlElement element = GetData(action) as HtmlElement; if (element == null) { LoggerManager.Error("Element Not Found"); throw new ElementNoFoundException("Element Not Found", action); } string value = null; if (!string.IsNullOrEmpty(textAction.Attrbute)) { value = element.GetAttribute(textAction.Attrbute); } if (!string.IsNullOrEmpty(textAction.AttrbuteRegex)) { Match match = Regex.Match(value, textAction.AttrbuteRegex, RegexOptions.IgnoreCase); if (match.Success) { value = match.Groups[1].Value; } } this.SaveData<string>(textAction.TextSaveKey, value); }
public override bool Matches(IAction action) { return(action.Action == Activity.GauntletApprentice); }
public void SelectionChanged(IAction action, ISelection selection) { }
public void Run(IAction action) { }
private static void DoAction(IAction action, TfsTeamProjectCollection tpc) { action.Execute(tpc); }
public AppState Invoke(AppState state, IAction action) { return(state ?? new AppState()); }
/// <summary> /// Accepts an accumulation and a value and returns a new accumulation. /// </summary> /// <param name="state">A state object</param> /// <param name="action">An action object</param> /// <returns>A new state object</returns> public TState Invoke(TState state, IAction action) { return(reducers.Aggregate(state, (currentState, reducer) => reducer.Invoke(currentState, action))); }
public override bool Matches(IAction action) { return(action.Action == Activity.DistillVis); }
public override bool Matches(IAction action) { return(action.Action == Activity.FindVisSource && ((FindVisSource)action).Aura == this.Aura); }
public override bool Matches(IAction action) { return(action.Action == Activity.LongevityRitual); }
public abstract bool Matches(IAction action);
public override bool Matches(IAction action) { return(action.Action == Activity.RefineLaboratory); }
public override bool Matches(IAction action) { return(action.Action == Activity.FindAura); }
/// <summary> /// NOT Thread safe, must be set before EnqueueAction /// </summary> /// <param name="nextActor"></param> /// <param name="nextAction"></param> public void RunOnFinish(IActor nextActor, IAction nextAction) { nextAct = new Tuple <IActor, IAction>(nextActor, nextAction); }
public override bool Matches(IAction action) { return(action.Action == Activity.WriteLabText); }
public CompositeAction AddAction(IAction action) { this.actionsList.Add(action); return(this); }
public void Set(string key, IAction action) { }
public QueueActionContext(IAction action, Action <bool> callback) : this(action) { ThirdCallback = callback; }
public Action(IAction <TContext> action) { this.action = action; }
public QueueActionContext(IAction action, Action <IResult> callback) : this(action) { FirstCallback = callback; }
public QueueActionContext(IAction action, System.Action callback) : this(action) { FourthCallback = callback; }
public IAction Dispatch(IAction action) { return(_dispatcher.Invoke(action)); }
public QueueActionContext(IAction action, Action <IResult, bool> callback) : this(action) { SecondCallback = callback; }
/// <summary> /// Prepare new action to run on this object /// </summary> public void EnqueueAction(IAction action) { actionQueue.EnqueueAction(action); }
public abstract GlobalState Reduce(GlobalState state, IAction action);
/// <see cref="IMiddleware.MayDispatchAction(IAction)"/> public override bool MayDispatchAction(IAction action) { return(SequenceNumberOfCurrentState == SequenceNumberOfLatestState); }
public void Add(IAction action) { actions.Add(action); }
public AudioMsgWithNode(IAction node) : base((int)AudioEvent.PlayNode) { Node = node; }
public virtual IActionFuture PushAction(IAction action) { action.OnActionEvent += _outerListener; _queue.AddLast(action); return(this); }
protected override void ProcessMsg(int key, QMsg msg) { switch (msg.EventID) { case (int)AudioEvent.SoundSwitch: AudioMsgWithBool soundSwitchMsg = msg as AudioMsgWithBool; IsSoundOn = soundSwitchMsg.on; break; case (int)AudioEvent.MusicSwitch: AudioMsgWithBool musicSwitchMsg = msg as AudioMsgWithBool; IsMusicOn = musicSwitchMsg.on; if (!IsMusicOn) { StopMusic(); } break; case (int)AudioEvent.PlayMusic: Debug.LogFormat("play music msg: {0}, is musicOn: {1}", AudioEvent.PlayMusic.ToString(), MusicOn); PlayMusic(msg as AudioMusicMsg); break; case (int)AudioEvent.StopMusic: StopMusic(); break; case (int)AudioEvent.PlaySound: AudioSoundMsg audioSoundMsg = msg as AudioSoundMsg; PlaySound(audioSoundMsg); break; case (int)AudioEvent.PlayVoice: PlayVoice(msg as AudioVoiceMsg); break; case (int)AudioEvent.StopVoice: StopVoice(); break; case (int)AudioEvent.PlayNode: IAction msgPlayNode = (msg as AudioMsgWithNode).Node; StartCoroutine(msgPlayNode.Execute()); break; case (int)AudioEvent.AddRetainAudio: AddRetainAudioMsg addRetainAudioMsg = msg as AddRetainAudioMsg; AddRetainAudio(addRetainAudioMsg.AudioName); break; case (int)AudioEvent.RemoveRetainAudioAudio: RemoveRetainAudioMsg removeRetainAudioMsg = msg as RemoveRetainAudioMsg; RemoveRetainAudio(removeRetainAudioMsg.AudioName); break; case (int)AudioEvent.PauseMusic: PauseMusic(); break; case (int)AudioEvent.ResumeMusic: ResumeMusic(); break; } }
public IAction Add(IAction action) { return(_taskServiceConvertorFactory.CreateAction(Instance.Add(action.Instance))); }