示例#1
0
        static void Main(string[] args)
        {
            IMongoDatabase db =
                new MongoClient("mongodb://localhost:27017/?readPreference=primary").GetDatabase("eventTests");
            var repo = new MongoDomainObjectRepository(
                new EventSourceConfiguration()
            {
                Activator = new ActivatorDomainObjectActivator()
            }, db);

            StartDenormalizer(db, typeof(Program).GetTypeInfo().Assembly);

            Console.WriteLine("next");
            Console.ReadLine();
            var bo = new SampleBo("1");

            bo.Execute();

            repo.SaveAsync(bo).Wait();
            repo.SaveAsync(bo).Wait();

            bo.Execute();
            bo.Execute();
            repo.SaveAsync(bo).Wait();

            //bo = new SampleBo("1");
            // bo.Execute();

            //   repo.SaveAsync(bo).Wait();

            //bo = new SampleBo("2");
            //bo.Execute();
            //repo.SaveAsync(bo).Wait();

            //bo = new SampleBo("3");
            //bo.Execute();
            //bo.Next();
            //repo.SaveAsync(bo).Wait();
            //bo.CommitChanges();

            //bo.Next();
            //repo.SaveAsync(bo).Wait();

            //Console.WriteLine(repo.Exists<SampleBo>("1").Result.ToString(), " - ",
            //    repo.GetVersion<SampleBo>("1").Result);
            //Console.WriteLine(repo.Exists<SampleBo>("2").Result.ToString(), " - ",
            //    repo.GetVersion<SampleBo>("2").Result);
            //Console.WriteLine(repo.Exists<SampleBo>("3").Result.ToString(), " - ",
            //    repo.GetVersion<SampleBo>("3").Result);

            //Console.WriteLine(repo.Exists<SampleBo>("4").Result.ToString());

            //test(repo).Wait();

            Console.ReadLine();
        }
示例#2
0
文件: Program.cs 项目: BoasE/BE.CQRS
        static async Task Main(string[] args)
        {
            var services = new ServiceCollection();

            ConfigureServices(services);

            var serviceProvider = services.BuildServiceProvider();

            var dto = new MyEvent()
            {
                Id = "2"
            };

            dto = new MyEvent()
            {
                Id = "3"
            };
            dto.Headers.Set(EventHeaderKeys.AggregateId, "a");
            dto.Headers.Set(EventHeaderKeys.Created, DateTime.Now);

            var repo = serviceProvider.GetRequiredService <IDomainObjectRepository>();

            var bo2 = await repo.Get <SampleBo>("53fda695-5186-4253-a495-8f989d03dbf3");

            bo2.Next();

            Console.WriteLine("next");
            Console.ReadLine();

            var bo = new SampleBo(Guid.NewGuid().ToString());

            bo.ApplyConfig(serviceProvider.GetRequiredService <EventSourceConfiguration>(),
                           serviceProvider.GetRequiredService <EventsourceDIContext>(),
                           serviceProvider.GetRequiredService <IStateEventMapping>(),
                           repo);
            bo.Execute();

            bo.Next();

            repo.SaveAsync(bo).Wait();
            repo.SaveAsync(bo).Wait();

            bo.Execute();
            bo.Execute();
            repo.SaveAsync(bo).Wait();


            Console.ReadLine();
        }
示例#3
0
        static async Task Main(string[] args)
        {
            var serviceCollection = new ServiceCollection();

            ConfigureServices(serviceCollection);

            var serviceProvider = serviceCollection.BuildServiceProvider();

            var db = serviceProvider.GetRequiredService <IMongoDatabase>();

            var cfg = new EventSourceConfiguration()
            {
                Activator      = new ActivatorDomainObjectActivator(),
                LoggerFactory  = serviceProvider.GetRequiredService <ILoggerFactory>(),
                StateActivator = new ActivatorDomainObjectActivator()
            };

            var repo = new MongoDomainObjectRepository(cfg, db);

            var bo2 = await repo.Get <SampleBo>("53fda695-5186-4253-a495-8f989d03dbf3");

            bo2.Next();

            Console.WriteLine("next");
            Console.ReadLine();

            var bo = new SampleBo(Guid.NewGuid().ToString());

            bo.ApplyConfig(cfg);
            bo.Execute();

            bo.Next();

            repo.SaveAsync(bo).Wait();
            repo.SaveAsync(bo).Wait();

            bo.Execute();
            bo.Execute();
            repo.SaveAsync(bo).Wait();

            //bo = new SampleBo("1");
            // bo.Execute();

            //   repo.SaveAsync(bo).Wait();

            //bo = new SampleBo("2");
            //bo.Execute();
            //repo.SaveAsync(bo).Wait();

            //bo = new SampleBo("3");
            //bo.Execute();
            //bo.Next();
            //repo.SaveAsync(bo).Wait();
            //bo.CommitChanges();

            //bo.Next();
            //repo.SaveAsync(bo).Wait();

            //Console.WriteLine(repo.Exists<SampleBo>("1").Result.ToString(), " - ",
            //    repo.GetVersion<SampleBo>("1").Result);
            //Console.WriteLine(repo.Exists<SampleBo>("2").Result.ToString(), " - ",
            //    repo.GetVersion<SampleBo>("2").Result);
            //Console.WriteLine(repo.Exists<SampleBo>("3").Result.ToString(), " - ",
            //    repo.GetVersion<SampleBo>("3").Result);

            //Console.WriteLine(repo.Exists<SampleBo>("4").Result.ToString());

            //test(repo).Wait();

            Console.ReadLine();
        }