예제 #1
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();
        }
예제 #2
0
 private static async Task test(MongoDomainObjectRepository repo)
 {
     SampleBo existing = await repo.Get <SampleBo>("3").FirstAsync();
 }