static void Main(string[] args) { using (var terminal = new Terminal()) { try { Config.Current = Config.Parse(args); var service = new ApplicationServiceFactory().Create(); var listener = service.StartListener(); listener.ConnectionEstablished += (sender, e) => { string input; while ((input = terminal.RequestInput("{0}: ", Environment.UserName)) != "exit") { var response = service.SendPayload(listener, e.Connection.Identifier, input); terminal.WriteOutputLine("{0}: {1}", e.Connection.Username, response); } service.StopListener(listener); terminal.Stop(); }; terminal.Start("Waiting for connections..."); } catch (Exception ex) { terminal.WriteError(ex); } } }
static void Main(string[] args) { using (var terminal = new Terminal()) { try { Config.Current = Config.Parse(args); var service = new ApplicationServiceFactory().Create(); service.ReachServer(); } catch (Exception ex) { terminal.WriteError(ex); } } }
static void UseCronusHostWithCosmosEventStore() { var container = new Container(); var cfg = new CronusSettings(container) .UseCluster(cluster => cluster.UseAggregateRootAtomicAction(atomic => atomic.WithInMemory())) .UseContractsFromAssemblies(new[] { Assembly.GetAssembly(typeof(AccountRegistered)), Assembly.GetAssembly(typeof(UserCreated)) }); string IAA = "IAA"; var IAA_appServiceFactory = new ApplicationServiceFactory(container, IAA); cfg.UseCommandConsumer(IAA, consumer => consumer .UseRabbitMqTransport(x => x.Server = "docker-local.com") .SetNumberOfConsumerThreads(1) .WithDefaultPublishers() .UseCosmosEventStore(eventStore => eventStore .SetDocumentclient(new Uri("https://localhost:8081"), "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==") .SetThroughput(2500) .WithNewStorageIfNotExists()) .UseApplicationServices(cmdHandler => cmdHandler.RegisterHandlersInAssembly(new[] { typeof(AccountAppService).Assembly }, IAA_appServiceFactory.Create))); string COLL = "COLL"; var COLL_appServiceFactory = new ApplicationServiceFactory(container, COLL); cfg.UseCommandConsumer(COLL, consumer => consumer .UseRabbitMqTransport(x => x.Server = "docker-local.com") .SetNumberOfConsumerThreads(1) .WithDefaultPublishers() .UseCosmosEventStore(eventStore => eventStore .SetDocumentclient(new Uri("https://localhost:8081"), "C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==") .SetThroughput(2500) .WithNewStorageIfNotExists()) .UseApplicationServices(cmdHandler => cmdHandler.RegisterHandlersInAssembly(new[] { typeof(UserAppService).Assembly }, COLL_appServiceFactory.Create))); (cfg as ISettingsBuilder).Build(); host = container.Resolve <CronusHost>(); host.Start(); }
protected ApplicationServiceInvoker(ApplicationServiceFactory <TContext> serviceFactory, ApplicationServiceFilterProvider <TContext, TPipelineContext> filterProvider) { this.serviceFactory = Ensure.NotNull(serviceFactory, "serviceFactory"); this.filterProvider = Ensure.NotNull(filterProvider, "filterProvider"); }