private static IContainer CreateContainer() { var baseDirectory = AppDomain.CurrentDomain.BaseDirectory; var container = ContainerExtensions.CreateDefaultContainer(false); container.Register <IResourceManager>( xx => new DefaultResourceManager( true, Path.GetFullPath(Path.Combine(baseDirectory, "..", "..", "..", "etc")), Path.GetFullPath(Path.Combine(baseDirectory, "..", "..", "..", "..", "etc")), Path.GetFullPath(Path.Combine(baseDirectory, "..", "..", "..", "..", "..", "etc"))), Lifespan.Singleton); SupportEventTypeFactory.RegisterSingleton(container); SupportExprNodeFactory.RegisterSingleton(container); SupportDatabaseService.RegisterSingleton(container); SupportJoinResultNodeFactory.RegisterSingleton(container); container .InitializeDefaultServices() .InitializeDatabaseDrivers() .RegisterDatabaseDriver(typeof(DbDriverPgSQL)); return(container); }
public static EPServiceProvider GetProvider( string providerURI) { return(GetProvider( ContainerExtensions.CreateDefaultContainer(), providerURI)); }
public void TestNestedProperties() { var container = ContainerExtensions.CreateDefaultContainer(); var configuration = new Configuration(container); configuration.AddEventType <Figure>(); var ep = EPServiceProviderManager.GetProvider(container, "testNestedProperties", configuration); var ul = new SupportUpdateListener(); ep.EPAdministrator.CreateEPL("select * from Figure").Events += ul.Update; var source = new AdapterInputSource("regression/nestedProperties.csv"); var spec = new CSVInputAdapterSpec(source, "Figure"); var adapter = new CSVInputAdapter(_container, ep, spec); adapter.Start(); Assert.IsTrue(ul.IsInvoked()); var e = ul.AssertOneGetNewAndReset(); var f = (Figure)e.Underlying; Assert.AreEqual(1, f.Point.X); }
public void SetUp() { var container = ContainerExtensions.CreateDefaultContainer() .InitializeDefaultServices() .InitializeDatabaseDrivers(); var configuration = new Configuration(container); configuration.EngineDefaults.Threading.IsInternalTimerEnabled = false; configuration.AddEventType("MarketDataEvent", typeof(MarketDataEvent).FullName); configuration.EngineDefaults.EventMeta.ClassPropertyResolutionStyle = PropertyResolutionStyle.CASE_INSENSITIVE; _epService = EPServiceProviderManager.GetProvider(container, "TestTicksPerSecondStatement", configuration); _epService.Initialize(); _epService.EPRuntime.SendEvent(new CurrentTimeEvent(0)); TicksPerSecondStatement.Create(_epService.EPAdministrator); var stmt = TicksFalloffStatement.Create(_epService.EPAdministrator); _listener = new SupportUpdateListener(); stmt.Events += _listener.Update; // Use external clocking for the test _epService.EPRuntime.SendEvent(new TimerControlEvent(TimerControlEvent.ClockTypeEnum.CLOCK_EXTERNAL)); }
public void Run() { var container = ContainerExtensions.CreateDefaultContainer() .InitializeDefaultServices() .InitializeDatabaseDrivers(); // load config - this defines the XML event types to be processed var configFile = "esper.examples.cfg.xml"; var url = container.ResourceManager().ResolveResourceURL(configFile); var config = new Configuration(container); config.Configure(url); // get engine instance var epService = EPServiceProviderManager.GetProvider(container, engineURI, config); // set up statement var rfidStmt = RFIDTagsPerSensorStmt.Create(epService.EPAdministrator); rfidStmt.Events += LogRate; // Send events var eventCount = 0; while (eventCount < numEvents) { SendEvent(epService.EPRuntime); eventCount++; } }
public void TestIt() { var stmtText = "insert into ThroughputPerFeed " + " select feed, count(*) as cnt " + "from " + typeof(FeedEvent).FullName + ".win:time_batch(1 sec) " + "group by feed"; var container = ContainerExtensions.CreateDefaultContainer() .InitializeDefaultServices() .InitializeDatabaseDrivers(); var configuration = new Configuration(container); configuration.EngineDefaults.EventMeta.ClassPropertyResolutionStyle = PropertyResolutionStyle.CASE_INSENSITIVE; EPServiceProviderManager.PurgeDefaultProvider(); var engine = EPServiceProviderManager.GetDefaultProvider(configuration); var stmt = engine.EPAdministrator.CreateEPL(stmtText); stmt.Events += DisplayEvents; /* * while(true) * { * FeedEvent event; * event = new FeedEvent(FeedEnum.FEED_A, "IBM", 70); * engine.GetEPRuntime().SendEvent(event); * event = new FeedEvent(FeedEnum.FEED_B, "IBM", 70); * engine.GetEPRuntime().SendEvent(event); * } */ }
public void SetUp() { var container = ContainerExtensions.CreateDefaultContainer() .InitializeDefaultServices() .InitializeDatabaseDrivers(); var configuration = new Configuration(container); configuration.Runtime.Threading.IsInternalTimerEnabled = false; configuration.Common.AddEventType("MarketDataEvent", typeof(MarketDataEvent).FullName); configuration.Common.EventMeta.ClassPropertyResolutionStyle = PropertyResolutionStyle.CASE_INSENSITIVE; _runtime = EPRuntimeProvider.GetRuntime("TestTicksPerSecondStatement", configuration); _runtime.Initialize(); _runtime.EventService.AdvanceTime(0); TicksPerSecondStatement.Create(_runtime); var stmt = TicksFalloffStatement.Create(_runtime); _listener = new SupportUpdateListener(); stmt.Events += _listener.Update; // Use external clocking for the test _runtime.EventService.ClockExternal(); }
public void Adds_Options() { // ReSharper disable once InvokeAsExtensionMethod ContainerExtensions.AddOptions(_container); _container.Verify(VerificationOption.VerifyAndDiagnose); }
public void TestNestedProperties() { var container = ContainerExtensions.CreateDefaultContainer(); var configuration = new Configuration(container); configuration.Common.AddEventType(typeof(Figure)); var runtime = EPRuntimeProvider.GetRuntime("testNestedProperties", configuration); var ul = new SupportUpdateListener(); var stmt = CompileUtil.CompileDeploy(runtime, "select * from Figure").Statements[0]; stmt.Events += ul.Update; var source = new AdapterInputSource(_container, "regression/nestedProperties.csv"); var spec = new CSVInputAdapterSpec(source, "Figure"); var adapter = new CSVInputAdapter(runtime, spec); adapter.Start(); Assert.IsTrue(ul.IsInvoked()); var e = ul.AssertOneGetNewAndReset(); var f = (Figure)e.Underlying; Assert.AreEqual(1, f.Point.X); }
public void SetUp() { var container = ContainerExtensions.CreateDefaultContainer() .InitializeDefaultServices() .InitializeDatabaseDrivers(); var configuration = new Configuration(container); configuration.EngineDefaults.EventMeta.ClassPropertyResolutionStyle = PropertyResolutionStyle.CASE_INSENSITIVE; configuration.AddEventType("StockTick", typeof(StockTick).FullName); _epService = EPServiceProviderManager.GetProvider(container, "TestStockTickerRSI", configuration); _epService.Initialize(); _stockListener = new RSIStockTickerListener(_epService, PERIOD); _expressionText = "every tick=StockTick(stockSymbol='" + SYMBOL + "')"; //_expressionText = "every tick1=StockTick(stockSymbol='GOOG') -> tick2=StockTick(stockSymbol='GOOG')"; _factory = _epService.EPAdministrator.CreatePattern(_expressionText); _factory.Events += _stockListener.Update; var rsiEvent = typeof(RSIEvent).FullName; var viewExpr = "select * from " + rsiEvent + ".win:length(1)"; _rsiListener = new RSIListener(); _factory = _epService.EPAdministrator.CreateEPL(viewExpr); _factory.Events += _rsiListener.Update; _rsiListener.Reset(); }
/// <summary> /// Runs this instance. /// </summary> public void Run() { var container = ContainerExtensions.CreateDefaultContainer(); // Configure engine with event names to make the statements more readable. // This could also be done in a configuration file. var configuration = new Configuration(container); configuration.AddEventType("TxnEventA", typeof(TxnEventA).FullName); configuration.AddEventType("TxnEventB", typeof(TxnEventB).FullName); configuration.AddEventType("TxnEventC", typeof(TxnEventC).FullName); // Get engine instance EPServiceProvider epService = EPServiceProviderManager.GetProvider(container, _engineURI, configuration); // We will be supplying timer events externally. // We will assume that each bucket arrives within a defined period of time. epService.EPRuntime.SendEvent(new TimerControlEvent(TimerControlEvent.ClockTypeEnum.CLOCK_EXTERNAL)); // Set up statement for listening to combined events var combinedEventStmt = CombinedEventStmt.Create(epService.EPAdministrator); combinedEventStmt.Events += LogCombinedEvents; // Set up statements for realtime summary latency data - overall totals and totals per customer and per supplier RealtimeSummaryStmt realtimeSummaryStmt = new RealtimeSummaryStmt(epService.EPAdministrator); realtimeSummaryStmt.TotalsStatement.Events += LogSummaryTotals; realtimeSummaryStmt.CustomerStatement.Events += (sender, e) => LogSummaryGroup("customerId", e); realtimeSummaryStmt.SupplierStatement.Events += (sender, e) => LogSummaryGroup("supplierId", e); // Set up statement for finding missing events var findMissingEventStmt = FindMissingEventStmt.Create(epService.EPAdministrator); findMissingEventStmt.Events += FindMissingEvent; // The feeder to feed the engine var feeder = new FeederOutputStream(epService.EPRuntime); // Generate transactions var source = new TransactionEventSource(_numTransactions); var output = new ShuffledBucketOutput(source, feeder, _bucketSize); // Feed events if (_continuousSimulation) { while (true) { output.Output(); Thread.Sleep(5000); // Send a batch every 5 seconds } } else { output.Output(); } }
public void ShouldWorkForNullInstances() { var container = new Container(); ContainerExtensions.Inject(container, new TestClass()); container.Inject <TestClass2>(null); var instance = container.Resolve <TestClass3>(); }
public void Init(int sleepListenerMillis) { var container = ContainerExtensions.CreateDefaultContainer(); var configuration = new Configuration(container); configuration.Common.EventMeta.ClassPropertyResolutionStyle = PropertyResolutionStyle.CASE_INSENSITIVE; configuration.Common.AddEventType("Market", typeof(MarketData)); _runtime = EPRuntimeProvider.GetRuntime("benchmark", configuration); _marketDataSender = _runtime.EventService.GetEventSender("Market"); _sleepMillis = sleepListenerMillis; }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.AddAuthentication(OpenIdConnectDefaults.AuthenticationScheme) .AddMicrosoftIdentityWebApp(Configuration.GetSection("AzureAdB2C")); services.AddControllersWithViews() .AddMicrosoftIdentityUI(); services.AddAuthorization(options => { // By default, all incoming requests will be authorized according to the default policy //options.FallbackPolicy = options.DefaultPolicy; }); services.AddScoped <ISideBySideDiffBuilder, SideBySideDiffBuilder>(); services.AddScoped <IDiffer, Differ>(); services.AddBlazoredToast(); services.AddBootstrapCss(); services.AddTransient <IValidator <FollowCommandViewModel>, FollowCommandViewModelValidator>(); services.AddSingleton <RandomProvider>(); services.AddSingleton <TimeProvider>(); services.AddSingleton <Scheduler>(); services.AddScoped <Dexie>(); services.AddScoped <DeckAppender>(); services.AddScoped <MetaFactory>(); services.AddScoped <UserProvider>(); services.AddScoped <IClock>(_ => NodaTime.SystemClock.Instance); var(context, cache) = ContainerExtensions.getEquinoxContextAndCache(Configuration); var deckAppender = ContainerExtensions.Deck.appender(context, cache); services.AddSingleton(deckAppender); services.AddSingleton(ContainerExtensions.PublicTemplate.appender(context, cache)); services.AddSingleton(ContainerExtensions.User.appender(context, cache)); services.AddSingleton(ContainerExtensions.Example.appender(context, cache)); services.AddSingleton(ContainerExtensions.Stack.appender(context, cache)); services.AddSingleton(ContainerExtensions.UserSaga.appender(context, cache, deckAppender)); services.AddSingleton <IKeyValueStore>(new TableClient(Configuration.GetConnectionString("AzureTableStorage"), "CardOverflow")); services.AddSingleton <KeyValueStore>(); services.AddSingleton <IElasticClient>(Elsea.ClientModule.create("CardOverflow", new Uri(Configuration.GetConnectionString("ElasticSearchUri")))); services.AddSingleton <Api.Elsea.IClient, Api.Elsea.Client>(); services.AddSingleton <NoCQS.User>(); services.AddFileReaderService(options => options.InitializeOnFirstCall = true); // medTODO what does this do? services.AddRazorPages(); services.AddServerSideBlazor() .AddMicrosoftIdentityConsentHandler(); services.AddSingleton <WeatherForecastService>(); services.AddHttpClient <UserContentHttpClient>(); services.RegisterCommonStuff(Configuration); services.AddHsts(options => { options.Preload = true; options.IncludeSubDomains = true; options.MaxAge = TimeSpan.FromMinutes(5); // highTODO https://docs.microsoft.com/en-us/aspnet/core/security/enforcing-ssl?view=aspnetcore-3.1&tabs=visual-studio#http-strict-transport-security-protocol-hsts For production environments that are implementing HTTPS for the first time, set the initial HstsOptions.MaxAge to a small value using one of the TimeSpan methods. Set the value from hours to no more than a single day in case you need to revert the HTTPS infrastructure to HTTP. After you're confident in the sustainability of the HTTPS configuration, increase the HSTS max-age value; a commonly used value is one year. }); }
public void ShouldWorkForTheDefaultType() { var container = new Container(); var testClass = new TestClass(); ContainerExtensions.Inject(container, testClass); var instance = container.Resolve <TestClass>(); Assert.AreSame(testClass, instance); }
public void ShouldThrowExceptionWhenNullContainerPassed() { // Arrange var container = default(Container); #pragma warning disable 8604 Action action = () => ContainerExtensions.AddAutoMapper(container, _ => { }); #pragma warning restore 8604 // Act & Assert action.Should().Throw <ArgumentNullException>(); }
public virtual void SetUp() { var container = ContainerExtensions.CreateDefaultContainer(); var configuration = new Configuration(container); configuration.EngineDefaults.EventMeta.ClassPropertyResolutionStyle = PropertyResolutionStyle.CASE_INSENSITIVE; configuration.AddEventType("TxnEventA", typeof(TxnEventA).FullName); configuration.AddEventType("TxnEventB", typeof(TxnEventB).FullName); configuration.AddEventType("TxnEventC", typeof(TxnEventC).FullName); epService = EPServiceProviderManager.GetProvider(container, "TestStmtBase", configuration); epService.Initialize(); }
public void Init(int sleepListenerMillis) { var container = ContainerExtensions.CreateDefaultContainer(); Configuration configuration = new Configuration(container); configuration.EngineDefaults.EventMeta.ClassPropertyResolutionStyle = PropertyResolutionStyle.CASE_INSENSITIVE; configuration.AddEventType("Market", typeof(MarketData)); EPServiceProvider epService = EPServiceProviderManager.GetProvider("benchmark", configuration); epAdministrator = epService.EPAdministrator; epRuntime = epService.EPRuntime; sleepMillis = sleepListenerMillis; }
public static EPServiceProvider GetDefaultProvider( Configuration configuration) { var container = configuration.Container; if (container == null) { container = ContainerExtensions.CreateDefaultContainer(); } return(GetProvider( container, EPServiceProviderConstants.DEFAULT_ENGINE_URI, configuration)); }
/// <summary> /// Setup the esper. /// </summary> static void SetupEsper() { _container = ContainerExtensions.CreateDefaultContainer(); var configuration = new Configuration(_container); configuration.Common.AddEventType(typeof(BidData)); configuration.Compiler.Expression.IsUdfCache = true; configuration.Runtime.Logging.IsEnableExecutionDebug = false; configuration.Runtime.Logging.IsEnableTimerDebug = false; configuration.Runtime.MetricsReporting.IsEnableMetricsReporting = false; configuration.Runtime.MetricsReporting.IsThreading = false; _runtime = EPRuntimeProvider.GetDefaultRuntime(configuration); }
public void SetUp() { var container = ContainerExtensions.CreateDefaultContainer() .InitializeDefaultServices() .InitializeDatabaseDrivers(); var configuration = new Configuration(container); configuration.Common.EventMeta.ClassPropertyResolutionStyle = PropertyResolutionStyle.CASE_INSENSITIVE; _runtime = EPRuntimeProvider.GetDefaultRuntime(configuration); _sender = _runtime.EventService.GetEventSender(typeof(OperationMeasurement).FullName); new ErrorRateMonitor(); }
public void CreateUserCommandWithLettersInPhoneShouldFail() { var command = new CreateUserCommand(); command.Email = "*****@*****.**"; command.Login = "******"; command.MobilePhone = "9988887777"; command.Name = "teste"; command.Password = "******"; command.Phone = "776666b5555"; var validator = ContainerExtensions.GetInstance <IValidator>(); var errors = validator.Validate(command); Assert.AreEqual(1, errors.Count()); }
public void SetUp() { var container = ContainerExtensions.CreateDefaultContainer() .InitializeDefaultServices() .InitializeDatabaseDrivers(); var configuration = new Configuration(container); configuration.EngineDefaults.EventMeta.ClassPropertyResolutionStyle = PropertyResolutionStyle.CASE_INSENSITIVE; EPServiceProviderManager.PurgeDefaultProvider(); var epService = EPServiceProviderManager.GetDefaultProvider(configuration); new ErrorRateMonitor(); _runtime = epService.EPRuntime; }
private void SelectWeapon() { WeaponPrototype.Elements[] elements = currentElements .Where(e => e.HasValue) .Select(e => e.Value).ToArray(); foreach (WeaponPrototype weapon in weapons) { if (ContainerExtensions.ScrambledEquals(elements, weapon.ElementCombination)) { // Cleanup old selected weapon ChangeWeapon(weapon); break; } } }
public void ValidCreateUserCommandShouldSucceed() { var command = new CreateUserCommand(); command.Email = "*****@*****.**"; command.Login = "******"; command.MobilePhone = "+ 55888 7777"; command.Name = "teste"; command.Password = "******"; command.Phone = "+5588 8877 77"; var validator = ContainerExtensions.GetInstance <IValidator>(); var errors = validator.Validate(command); Assert.AreEqual(0, errors.Count()); }
public void ShouldRemoveInstances2() { var container = new Container(); var class1 = new ClassA1(); var class2 = new ClassA1(); ContainerExtensions.Inject(container, class1); container.RemoveAllRegistrationsAndInstancesOf <ClassA1>(); ContainerExtensions.Inject(container, class2); var classA1 = container.Resolve <ClassA1>(); Assert.AreSame(class2, classA1); }
public static EPServiceProvider GetProvider( string providerURI, Configuration configuration) { var container = configuration.Container; if (container == null) { container = ContainerExtensions.CreateDefaultContainer(); } return(GetProvider( container, providerURI, configuration)); }
public virtual void SetUp() { var container = ContainerExtensions.CreateDefaultContainer(); var configuration = new Configuration(container); configuration.Common.EventMeta.ClassPropertyResolutionStyle = PropertyResolutionStyle.CASE_INSENSITIVE; configuration.Common.AddEventType("TxnEventA", typeof(TxnEventA)); configuration.Common.AddEventType("TxnEventB", typeof(TxnEventB)); configuration.Common.AddEventType("TxnEventC", typeof(TxnEventC)); _runtime = EPRuntimeProvider.GetRuntime("TestStmtBase", configuration); _runtime.Initialize(); _eventService = _runtime.EventService; }
public void Run() { var container = ContainerExtensions.CreateDefaultContainer(false) .InitializeDefaultServices() .InitializeDatabaseDrivers(); var configuration = new Configuration(container); configuration.Common.AddEventType("PriceLimit", typeof(PriceLimit)); configuration.Common.AddEventType("StockTick", typeof(StockTick)); Log.Info("Setting up EPL"); var runtime = EPRuntimeProvider.GetRuntime(_engineURI, configuration); runtime.Initialize(); var eventService = runtime.EventService; new StockTickerMonitor(runtime, new StockTickerResultListener()); Log.Info("Generating test events: 1 million ticks, ratio 2 hits, 100 stocks"); var generator = new StockTickerEventGenerator(); var stream = generator.MakeEventStream(1000000, 500000, 100, 25, 30, 48, 52, false); Log.Info("Generating " + stream.Count + " events"); Log.Info("Sending " + stream.Count + " limit and tick events"); foreach (var @event in stream) { eventService.SendEventBean(@event, @event.GetType().Name); if (_continuousSimulation) { try { Thread.Sleep(200); } catch (ThreadInterruptedException e) { Log.Debug("Interrupted", e); break; } } } Log.Info("Done."); }
public void Run() { Log.Info("Setting up engine instance."); var container = ContainerExtensions.CreateDefaultContainer(); var config = new Configuration(container); config.Common.EventMeta.DefaultEventRepresentation = EventUnderlyingType.MAP; // use Map-type events for testing config.Compiler.AddPlugInVirtualDataWindow("sample", "samplevdw", typeof(SampleVirtualDataWindowFactory).FullName); config.Common.AddEventType(typeof(SampleTriggerEvent)); config.Common.AddEventType(typeof(SampleJoinEvent)); config.Common.AddEventType(typeof(SampleMergeEvent)); var runtime = EPRuntimeProvider.GetRuntime("LargeExternalDataExample", config); // First: Create an event type for rows of the external data - here the example use a Map-based event and any of the other types (POJO, XML) can be used as well. // Populate event property names and types. // Note: the type must match the data returned by virtual data window indexes. CompileDeploy(runtime, "create schema SampleEvent as (key1 string, key2 string, value1 int, value2 double)"); Log.Info("Creating named window with virtual."); // Create Named Window holding SampleEvent instances CompileDeploy(runtime, "create window MySampleWindow.sample:samplevdw() as SampleEvent"); // Example subquery Log.Info("Running subquery example."); RunSubquerySample(runtime); // Example joins Log.Info("Running join example."); RunJoinSample(runtime); // Sample FAF Log.Info("Running fire-and-forget query example."); RunSampleFireAndForgetQuery(runtime); // Sample On-Merge Log.Info("Running on-merge example."); RunSampleOnMerge(runtime); // Cleanup Log.Info("Destroying engine instance, sample completed successfully."); runtime.Destroy(); }