Exemple #1
0
        public FlowRuntime(FlowRuntimeConfiguration config, ISchedulingStrategy schedule)
        {
            // Build
            var regStream = new Register_stream();
            var regOp     = new Register_operation();
            var configOp  = new Create_activation_task();

            var flow = new Flow_asynchronously(schedule);

            var opStart = new Start_async_operations();
            var opStop  = new Stop_async_operations();

            // Bind
            _addStream      += regStream.Process;
            _addOperation   += regOp.Process;
            _addOperation   += configOp.Process;
            configOp.Result += flow.Execute;

            _process                += flow.Process;
            flow.Message            += _ => Message(_);
            flow.Result             += Pass_result_to_environment;
            flow.UnhandledException += ex =>
            {
                if (UnhandledException == null)
                {
                    throw new UnhandledFlowRuntimeException(ex);
                }
                UnhandledException(ex);
            };

            _start += opStart.Process;
            _start += flow.Start;

            _stop += flow.Stop;
            _stop += opStop.Process;

            _throttle += flow.Throttle;

            // Inject
            var streams = new List <IStream>();

            regStream.Inject(streams);

            var operations = new Dictionary <string, IOperation>();

            regOp.Inject(operations);

            flow.Inject(streams, operations);
            opStart.Inject(operations);
            opStop.Inject(operations);

            // Config
            Configure(config);

            // Run
            Start();
        }
        public FlowRuntimeConfiguration MakeDispatched()
        {
            var sync = FlowRuntimeConfiguration.DispatcherFactory();

            WrapLastOperation(op => new Operation(op.Name, (input, continueWith, unhandledException) =>
                                                  sync.Process(input,
                                                               output =>
            {
                try
                {
                    op.Implementation(output,
                                      continueWith,
                                      unhandledException);
                }
                catch (Exception ex)
                {
                    unhandledException(
                        new FlowRuntimeException(ex,
                                                 output));
                }
            })));
            return(this);
        }
 public FlowRuntimeConfiguration AddEventBasedComponent(string name, object eventBasedComponent)
 {
     _operations.Add(new EBCOperation(name, eventBasedComponent, FlowRuntimeConfiguration.DispatcherFactory(),
                                      _asyncerCache));
     return(this);
 }
Exemple #4
0
 public FlowRuntime(FlowRuntimeConfiguration config) : this(config, new Schedule_for_async_depthfirst_processing())
 {
 }
Exemple #5
0
 public void Configure(FlowRuntimeConfiguration config)
 {
     this.AddStreams(config.Streams);
     this.AddOperations(config.Operations);
 }