Ejemplo n.º 1
0
        static void Main()
        {
            Migrate.Database("database", options: new Options().UseVersionTableName("__DatabaseVersion"));

            using (var container = new WindsorContainer())
            {
                // run Windsor installers - they're in the UnitOfWork.Installers namespace
                container.Install(FromAssembly.This());

                Configure.With(new CastleWindsorContainerAdapter(container))
                .Transport(t => t.UseMsmq("uow.test"))
                .Options(o =>
                {
                    // run the potentially failing handler last to demonstrate
                    // that the uow is not committed, even though the error
                    // happes after the insert
                    o.SpecifyOrderOfHandlers()
                    .First <InsertRowsIntoDatabase>()
                    .Then <FailSometimes>();
                })
                .Start();

                using (var timer = new Timer(1000))
                {
                    timer.Elapsed += (o, ea) => SendStringToSelf(container);
                    timer.Start();

                    Console.WriteLine("Press ENTER to quit");
                    Console.ReadLine();
                }
            }
        }