public void when_creating_an_aggregate_repository()
        {
            var connection = new EventStore.ClientAPI.EventStoreConnection(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1113));

            var repo = new EventStore.CommonDomain.Persistence.EventStoreRepository(connection,
                new Aggregate_Factory(), new ConflictDetector(), new My_Serializer());
        }
        static void Main(string[] args)
        {
            var mre = new ManualResetEvent(false);

            var connection = new EventStore.ClientAPI.EventStoreConnection(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1113));


            var pub = new Event_Publisher(connection, "storeId");
            pub.Reset();
            pub.Start();

            Console.ReadLine();
            //mre.WaitOne();
            return;

            try
            {

                connection.SubscribeToAllStreamsAsync((ev, pos) =>
                {
                    Console.WriteLine("{0} : {1}, {2}",ev.EventNumber, ev.EventType, ev.EventStreamId);
                    Console.ReadLine();
                }, () => { });

                mre.WaitOne();

            }
            catch (Exception ex)
            {
            }
        }
        public void when_creating_a_saga_repository()
        {
            var connection = new EventStore.ClientAPI.EventStoreConnection(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1113));

            var repository = new EventStore.CommonDomain.Persistence.SagaEventStoreRepository_v1(connection, 
                new My_Serializer(), new Saga_Factory());
        }
        public void when_asking_for_an_aggregate()
        {
            var connection = new EventStore.ClientAPI.EventStoreConnection(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1113));
           
            var repo = new EventStore.CommonDomain.Persistence.EventStoreRepository(connection, new Aggregate_Factory(), new ConflictDetector(), new My_Serializer());

            var id = Guid.NewGuid() + "";
            var ar = repo.GetById<MyAggregate>(id);
        }
        public void when_asking_for_a_saga()
        {
            var connection = new EventStore.ClientAPI.EventStoreConnection(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1113));

            var repository = new EventStore.CommonDomain.Persistence.SagaEventStoreRepository_v1(connection,
                new My_Serializer(), new Saga_Factory());

            var id = Guid.NewGuid() + "";
            var ar = repository.GetById<MySaga>(id);
        }
        public void read_all_events()
        {
            var connection = new EventStore.ClientAPI.EventStoreConnection(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1113));

            try
            {
               
                //var events = connection.ReadEventStreamForward("$all", 0, int.MaxValue);
                var events = connection.ReadAllEventsForward(ClientAPI.Position.Start, 2);
                var next = events.Position;

                var ev2 = connection.ReadAllEventsForward(next, 2);
            }
            catch (Exception ex)
            { 
            }
        }
        public void when_saving_update_aggregate()
        {
            var connection = new EventStore.ClientAPI.EventStoreConnection(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1113));
       
            var repository = new EventStore.CommonDomain.Persistence.EventStoreRepository(connection, 
                new Aggregate_Factory(), new ConflictDetector(), new My_Serializer());

            var id = Guid.NewGuid() + "";
            var ar = repository.GetById<MyAggregate>(id);

            ar.Do_Something(id);
            
            repository.Save(ar, Guid.NewGuid(), null);



            repository = new EventStore.CommonDomain.Persistence.EventStoreRepository(connection, 
                new Aggregate_Factory(), new ConflictDetector(), new My_Serializer());

            ar = repository.GetById<MyAggregate>(id);
        }
        public void subscribe_to_all_events()
        {
            var connection = new EventStore.ClientAPI.EventStoreConnection(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 1113));

            try
            {

                connection.SubscribeToAllStreamsAsync((ev, pos) => 
                {
                    
                }, () => { });

                
                
            }
            catch (Exception ex)
            {
            }
        }