public void Configure(IApplicationBuilder app)
        {
            app.UseStaticFiles();

            var endpoint   = new IPEndPoint(IPAddress.Loopback, 1113);
            var connection = EventStoreConnection.Create(endpoint);

            connection.ConnectAsync().Wait();
            var factory    = new AggregateFactory();
            var repository = new GesRepository(connection, factory);

            app.UseServices(services =>
            {
                services.AddMvc();

                services.AddSingleton <IUniqueKeyGenerator, UniqueKeyGenerator>();
                services.AddInstance <IRepository>(repository);
                services.AddTransient <RecipeApplicationService>();
            });

            // Add MVC to the request pipeline
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}/{id?}",
                    defaults: new { controller = "Home", action = "Index" });

                routes.MapRoute(
                    name: "api",
                    template: "{controller}/{id?}");
            });
        }
 public T Create <T>()
 {
     if (typeof(T) == typeof(TaskApplicationService))
     {
         var idGenerator = new IdGenerator();
         var factory     = new AggregateFactory();
         var connection  = new EventStoreConnectionFactory().Create("TaskManager");
         var repository  = new GesRepository(connection, factory);
         var service     = new TaskApplicationService(repository, idGenerator);
         return((T)(object)service);
     }
     throw new InvalidOperationException("Unknown application service");
 }