Exemplo n.º 1
0
        public static IRemoteStreamableBinding ToBinding <TPayload>(this IQStreamable <TPayload> stream, Application cepApplication,
                                                                    Type consumerFactoryType, object configInfo, EventShape eventShape)
        {
            var factory = Activator.CreateInstance(consumerFactoryType) as ISinkFactory;

            if (factory == null)
            {
                throw new ArgumentException("Factory cannot be created or does not implement ISinkFactory");
            }

            switch (eventShape)
            {
            case EventShape.Point:
                var pointObserver = cepApplication.DefineObserver(() =>
                                                                  factory.CreatePointObserverSink <TPayload>(configInfo));
                return(stream.Bind(pointObserver));

            case EventShape.Interval:
                var intervalObserver = cepApplication.DefineObserver(() =>
                                                                     factory.CreateIntervalObserverSink <TPayload>(configInfo));
                return(stream.Bind(intervalObserver));

            case EventShape.Edge:
                var edgeObserver = cepApplication.DefineObserver(() =>
                                                                 factory.CreateEdgeObserverSink <TPayload>(configInfo));
                return(stream.Bind(edgeObserver));

            default:
                throw new ArgumentOutOfRangeException("eventShape");
            }
        }
Exemplo n.º 2
0
        static void DisplayIntervalResults <TPayload>(this Application app, IQStreamable <TPayload> resultStream)
        {
            // Define observer that formats arriving events as intervals to the console window.
            var consoleObserver = app.DefineObserver(() => Observer.Create <IntervalEvent <TPayload> >(ConsoleWriteInterval));

            // Bind resultStream stream to consoleObserver.
            var binding = resultStream.Bind(consoleObserver);

            // Run example query by creating a process from the binding we've built above.
            using (binding.Run("ExampleProcess"))
            {
                Console.WriteLine("***Hit Return to exit after viewing query output***");
                Console.WriteLine();
                Console.ReadLine();
            }
        }