private void ProcessFlowOptional(IFlowResult result, int nextLevel) { var dataType = (Type)result.Data.GetType(); var flowTasks = ResolverCache.FlowResolver .OptionalGetFlowTypesFor(dataType) .Select(x => new FlowTask(x, result.Data, nextLevel)) .ToArray(); QueueTasksAndUpdate(flowTasks); }
private void DaemonFlowEndpoint(IFlowResult result, int nextLevel) { //If the data is default (empty), just ignore it if (result.Data.GetType() == typeof(DefaultFlowResult)) { return; } //If the type of the data matches the return type, notify the Daemon's initiator via callback //Note that there may still be other flows processing which might return data if (result.Data.GetType() == typeof(TReturn)) { var returnData = (TReturn)result.Data; Callback(returnData); return; } try { //Otherwise, handle the data according to its requirements if (result.MustHandle) { ProcessFlowRequired(result, nextLevel); } else { ProcessFlowOptional(result, nextLevel); } } catch (Exception e) when(e is FlowRegistrationException || e is FactoryRegistrationException) { lock (_TaskCacheSync) { //Get all tasks and tell them to die var activeFlows = ActiveFlows.Select(x => x.Value).ToArray(); foreach (var flow in activeFlows) { flow.Die(); } } throw; } }