/// <summary> /// Create an object of the type identified by <see cref="Action"/>. /// </summary> /// <param name="finder">Responsible for instantiating an object of the required type</param> /// <param name="message">JSON</param> /// <param name="output">Result</param> /// <returns>True if converted; otherwise, false.</returns> public static bool TryParseFromAction(IUIMessageFinder finder, string message, out UIMessage output) { try { object temp; var converted = TryParse(typeof(UnknownMessage), message, out temp); if (!converted) { output = null; return(false); } var msgTemp = temp as UIMessage; var actionName = string.Empty; if (msgTemp != null) { actionName = msgTemp.Action; } if (string.IsNullOrWhiteSpace(actionName)) { output = null; return(false); } var actionType = finder.Find(actionName); if (actionType == null) { output = null; return(false); } object tempActionObject; var parsed = TryParse(actionType, message, out tempActionObject); var actionObject = tempActionObject as UIMessage; output = actionObject; return(parsed && actionObject != null); } catch (Exception) { output = null; return(false); } }
/// <summary> /// Start the workflow engine. /// </summary> public override void Start(IUIMessageFinder messageFinder, InspectorSocket server) { _messageFinder = messageFinder; _socket = server; _cancellationSource = new CancellationTokenSource(); _queue = new BlockingCollection <string>(); // create 1 new consumer thread if (_consumerThread == null) { Task.Run(() => Consumer()); } }
private static void InitDependencies() { if (InspectorContainer.Current == null) { throw new InvalidOperationException("The inspector container has not been initialized."); } _networkAdapter = InspectorContainer.Current.Resolve <INetworkAdapter>(); _messageFinder = InspectorContainer.Current.Resolve <IUIMessageFinder>(); _socket = InspectorContainer.Current.Resolve <InspectorSocket>(); _workflow = InspectorContainer.Current.Resolve <InspectorWorkflow>(); _typeFinder = InspectorContainer.Current.Resolve <ITypeFinder>(); _reactionRegistrar = new InspectorReactionRegistrar(_typeFinder); _pageMonitor = new PageMonitor(TimeSpan.FromSeconds(1.5), Application.Current.MainPage); }
/// <summary> /// Start the workflow. /// </summary> public abstract void Start(IUIMessageFinder messageFinder, InspectorSocket socket);