public static NamedAction GetActionKey(Args arguments, NamedAction defaultAction) { NamedAction actionKey = arguments.IsDefault ? defaultAction : arguments.GetActionKey(); return actionKey; }
private void AddCallbackInternal(CallbackType type, Action action) { NamedAction namedAction = new NamedAction(); // Give that shit a name so we can refer to it in profiler. #if UNITY_EDITOR namedAction.Name = action.Target != null? action.Target.GetType().ToString() + "." + action.Method.ToString() : action.Method.ToString(); #endif namedAction.Action = action; CallbackCollection callbackCollection = collections[type]; // Check if it's already been added, should never be the case so avoiding the overhead in build. #if UNITY_EDITOR if (callbackCollection.ActionDictionary.ContainsKey(action)) { Debug.LogErrorFormat("Failed to add callback '{0}' to CallbackEvent '{1}' because it is already added.", namedAction.Name, type.ToString()); return; } #endif callbackCollection.ActionList.Add(namedAction); callbackCollection.ActionDictionary.Add(action, namedAction); }
internal override Action Clone(IDocumentEssential owner) { PDFDictionary dict = new PDFDictionary(); dict.AddItem("Type", new PDFName("Action")); dict.AddItem("S", new PDFName("Named")); IPDFObject n = _dictionary["N"]; if (n != null) { dict.AddItem("N", n.Clone()); } NamedAction action = new NamedAction(dict, owner); IPDFObject next = _dictionary["Next"]; if (next != null) { for (int i = 0; i < Next.Count; ++i) { action.Next.Add(Next[i]); } } return(action); }
public static NamedAction GetActionKey(Args arguments, NamedAction defaultAction) { NamedAction actionKey = arguments.IsDefault ? defaultAction : arguments.GetActionKey(); return(actionKey); }
private Type _winForm; /// <summary> /// Initializes a new instance of the <see cref="RunnerConfigurator"/> class. /// </summary> private RunnerConfigurator() { _winServiceSettings = new WinServiceSettings(); _credentials = Credentials.LocalSystem; _serviceConfigurators = new List <Func <IService> >(); _runnerAction = NamedAction.Console; _winForm = typeof(ServiceConsole); }
private void AddCallbackInternal(CallbackType type, Action action) { if (type == CallbackType.UPDATE) { if (!Instance.updateActions.Contains(action)) { Instance.updateActions.Add(action); return; } } if (type == CallbackType.FIXED_UPDATE) { if (!Instance.fixedUpdateActions.Contains(action)) { Instance.fixedUpdateActions.Add(action); return; } } if (type == CallbackType.LATE_UPDATE) { if (!Instance.lateUpdateActions.Contains(action)) { Instance.lateUpdateActions.Add(action); return; } } //FIXME current system is 2 x slower possibly because of garbage being created //in ProcessCallbacks() return; NamedAction namedAction = new NamedAction(); // Give that shit a name so we can refer to it in profiler. #if UNITY_EDITOR namedAction.Name = action.Target != null? action.Target.GetType().ToString() + "." + action.Method.ToString() : action.Method.ToString(); #endif namedAction.Action = action; CallbackCollection callbackCollection = collections[type]; // Check if it's already been added, should never be the case so avoiding the overhead in build. #if UNITY_EDITOR if (callbackCollection.ActionDictionary.ContainsKey(action)) { Debug.LogErrorFormat("Failed to add callback '{0}' to CallbackEvent '{1}' because it is already added.", namedAction.Name, type.ToString()); return; } #endif callbackCollection.ActionList.Add(namedAction); callbackCollection.ActionDictionary.Add(action, namedAction); }
void Update() { lock (ActionWaitingList) { Queue <NamedAction> TempQueue = new Queue <NamedAction>(); while (ActionWaitingList.Count > 0) { NamedAction CurrentAction = ActionWaitingList.Dequeue(); try { if (CurrentAction != null) { if (CurrentAction.AnimationID > 0) { if (CurrentAnimationID > 0 && CurrentAnimationID != CurrentAction.AnimationID) { TempQueue.Enqueue(CurrentAction); continue; } //} else { // if (CurrentAnimationID == 0) { // WaitingAnimation.Remove(CurrentAction.AnimationID); // } // CurrentAnimationID = CurrentAction.AnimationID; //} } if (!CurrentAction.Name.Equals(string.Empty)) { // PLogger.Log("执行操作 " + CurrentAction.ToString()); } bool ActionCompleted = false; PThread.Async(() => { PThread.Delay(0.5f); if (!ActionCompleted) { PLogger.Log("操作异常:" + CurrentAction.ToString()); throw new TimeoutException("UI操作超时"); } }); CurrentAction.Action(); ActionCompleted = true; } } catch (Exception e) { PLogger.Log("操作 " + CurrentAction.ToString() + " 发生错误"); PLogger.Log(e.ToString()); } } while (TempQueue.Count > 0) { ActionWaitingList.Enqueue(TempQueue.Dequeue()); } } }
private void ProcessCallbacks(CallbackCollection collection) { List <NamedAction> callbackList = collection.ActionList; // Iterate backwards so we can remove at O(1) while still iterating the rest. int startCount = callbackList.Count; int count = startCount; for (int i = count - 1; i >= 0; --i) { NamedAction namedAction = callbackList[i]; Action callback = namedAction.Action; if (namedAction.WaitingForRemove) { // When removing from a list, everything else will shift to fill in the gaps. // To avoid this, we swap this item to the back of the list. // At the end of iteration, we remove the items marked for removal from the back (can be multiple) so no other memory has to shift. NamedAction last = callbackList[count - 1]; callbackList[count - 1] = namedAction; callbackList[i] = last; count--; continue; } #if UNITY_EDITOR Profiler.BeginSample(namedAction.Name); try { callback?.Invoke(); } catch (Exception e) { // Catch the exception so it does not break flow of all callbacks // But still log it to Unity console so we know something happened Debug.LogException(e); // Get rid of it. RemoveCallbackInternal(collection, callback); } Profiler.EndSample(); #else callback?.Invoke(); #endif } callbackList.RemoveRange(count, startCount - count); }
} /// <summary> /// Go go gadget /// </summary> public static void Host(IRunConfiguration configuration, params string[] args) { _log.Info("Starting Host"); _log.DebugFormat("Arguments: {0}", string.Join(",", args)); var a = Parser.ParseArgs(args); if (a.InstanceName != null) { configuration.WinServiceSettings.DisplayName = a.InstanceName; } NamedAction actionKey = Parser.GetActionKey(a, configuration.DefaultAction); IAction action = _actions[actionKey]; _log.DebugFormat("Running action: {0}", action); action.Do(configuration); }
public void LaunchTask(NamedAction dataContext) { dataContext.Action.Invoke(); }
private void OnTabClick(NamedAction action) { action.Execute(textBox.Controller); }
public void LaunchTask(NamedAction task) { task.Action.Invoke(); }