示例#1
0
        private static EPDataFlowEmitter GenerateRuntimeContext(
            string engineURI,
            string statementName,
            bool audit,
            string dataflowName,
            int producerOpNum,
            string operatorPrettyPrint,
            DataFlowSignalManager dataFlowSignalManager,
            IList <ObjectBindingPair>[] targetsPerStream,
            EPDataFlowInstantiationOptions options,
            EngineImportService engineImportService)
        {
            // handle no targets
            if (targetsPerStream == null)
            {
                return(new EPDataFlowEmitterNoTarget(producerOpNum, dataFlowSignalManager));
            }

            // handle single-stream case
            if (targetsPerStream.Length == 1)
            {
                var targets = targetsPerStream[0];

                // handle single-stream single target case
                if (targets.Count == 1)
                {
                    var target = targets[0];
                    return(GetSubmitHandler(
                               engineURI, statementName, audit, dataflowName, producerOpNum, operatorPrettyPrint,
                               dataFlowSignalManager, target, options.GetExceptionHandler(), engineImportService));
                }

                var handlers = new SubmitHandler[targets.Count];
                for (var i = 0; i < handlers.Length; i++)
                {
                    handlers[i] = GetSubmitHandler(
                        engineURI, statementName, audit, dataflowName, producerOpNum, operatorPrettyPrint,
                        dataFlowSignalManager, targets[i], options.GetExceptionHandler(), engineImportService);
                }
                return(new EPDataFlowEmitter1StreamNTarget(producerOpNum, dataFlowSignalManager, handlers));
            }
            else
            {
                // handle multi-stream case
                var handlersPerStream = new SubmitHandler[targetsPerStream.Length][];
                for (var streamNum = 0; streamNum < targetsPerStream.Length; streamNum++)
                {
                    var handlers = new SubmitHandler[targetsPerStream[streamNum].Count];
                    handlersPerStream[streamNum] = handlers;
                    for (var i = 0; i < handlers.Length; i++)
                    {
                        handlers[i] = GetSubmitHandler(
                            engineURI, statementName, audit, dataflowName, producerOpNum, operatorPrettyPrint,
                            dataFlowSignalManager, targetsPerStream[streamNum][i], options.GetExceptionHandler(),
                            engineImportService);
                    }
                }
                return(new EPDataFlowEmitterNStreamNTarget(producerOpNum, dataFlowSignalManager, handlersPerStream));
            }
        }