Beispiel #1
0
        public App()
        {
            //Note: Using an external container via adapter.
            //Note: The usage pattern is the same for all supported containers.
            var container = new WindsorContainer();
            var adapter = new WindsorAdapter(container);

            CaliburnFramework
                .Configure(adapter)
                .With.Core()
                .With.PresentationFramework()
                .Start();

            //Note: Retrieve one of Caliburn's services.
            var controller = adapter.GetInstance<IConventionManager>();

            //Note: Customize the default behavior of button elements.
            controller.AddElementConvention(
                new DefaultElementConvention<Button>(
                    "MouseEnter",
                    Button.ContentProperty,
                    (b, v) => b.DataContext = v,
                    b => b.DataContext
                    )
                );

            //Note: Use the above method to add defaults for additional controls as well.
        }
Beispiel #2
0
        public static IWindsorContainer RegisterEasyNetQ(this IWindsorContainer container, Func <IServiceResolver, ConnectionConfiguration> connectionConfigurationFactory, Action <IServiceRegister> registerServices)
        {
            if (container == null)
            {
                throw new ArgumentNullException(nameof(container));
            }

            var serviceRegister = new WindsorAdapter(container);

            RabbitHutch.RegisterBus(serviceRegister, connectionConfigurationFactory, registerServices);
            return(container);
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            IContainer ioc = null;
            while (ioc == null)
            {
                Console.WriteLine("Выберите IoC контейнер: 1-MyIoC, 2-Castle Windsor, 3-Unity, 4-Autofac");
                int iocNumber;
                int.TryParse(Console.ReadLine(), out iocNumber);
                switch (iocNumber)
                {
                    case 1:
                        {
                            ioc = new MyIOCContainer();
                            break;
                        }
                    case 2:
                        {
                            ioc = new WindsorAdapter();
                            break;
                        }
                    case 3:
                        {
                            ioc = new UnityAdapter();
                            break;
                        }
                    case 4:
                        {
                            ioc = new AutofacAdapter();
                            break;
                        }
                }
                if (ioc == null)
                {
                    Console.WriteLine("Неверный ввод!!!");
                }
            }
            var logger = new NLogAdapter();
            logger.Trace(String.Format("Выбран IoC : {0}", ioc.GetType()));
            ioc.Register<IList<Person>>(new List<Person>());
            ioc.Register<IDataAccessor<Person>, ListDataAccessor<Person>>();
            var dataAccessor = ioc.Resolve<IDataAccessor<Person>>();
            dataAccessor.Insert(new Person(1, "Петров", "Петр", "Петрович", 20));
            dataAccessor.Insert(new Person(2, "Иванов", "Иван", "Иванович", 25));
            foreach (var person in dataAccessor.GetAll())
            {
                logger.Info(String.Format("В коллекцию добавлен {0}", person.ToString()));
                Console.WriteLine(person.ToString());
            }

            Console.ReadKey();
        }
Beispiel #4
0
        protected override IServiceLocator CreateContainer()
        {
            _guyWire = ApplicationConfiguration.GetGuyWire();


            // Dispatcher.BeginInvoke(()=>{  });

            var adp = new WindsorAdapter(_guyWire.SaftyGetProperty <IWindsorContainer, IContainerAccessor>(g =>
            {
                g.Container.Register(Castle.MicroKernel.Registration.Component.For(typeof(INotifyNhBuildComplete))
                                     .Instance(_guyWire).LifeStyle.Singleton);
                return(g.Container);
            }));



            return(adp);
        }
Beispiel #5
0
 protected void CreateContainer()
 {
     locatorAdapter = new WindsorAdapter(guyWire.Container);
 }
        public void Should_finalize()
        {
            adapter = null;

            GC.Collect();
            GC.WaitForPendingFinalizers();
        }
 public WindsorAdapterTests()
 {
     container = new Mock<IWindsorContainer>();
     adapter = new WindsorAdapter(container.Object);
 }
Beispiel #8
0
        /// <summary>
        ///   Applications startup event.
        /// </summary>
        /// <param name = "sender">The sender.</param>
        /// <param name = "e">The
        ///   <see cref = "System.Windows.StartupEventArgs" />
        ///   instance containing the event data.</param>
        private void ApplicationStartup(object sender, StartupEventArgs e)
        {
            var serviceLocator = new WindsorAdapter(_container);
            ServiceLocator.SetLocatorProvider(() => serviceLocator);

            _container.Register(Component
                                    .For<AbstractDemoFlow>()
                                    .ImplementedBy<DemoFlow>());

            Configuration.WindowTitle = "coulrophobia is not to be laughed at";

            Dispatcher
                .CurrentDispatcher
                .BeginInvoke(DispatcherPriority.Background,
                             (Action) (() =>
                                           {
                                               _openglRendering = new OpenglRendering();
                                               _openglRendering.Run(60);
                                               Shutdown();

                                               _container.Dispose();
                                           }));

            // Start the worker thread's message pump so that
            // queued messages are processed.
            Dispatcher.Run();
        }
Beispiel #9
0
 protected void CreateContainer()
 {
     locatorAdapter = new WindsorAdapter(guyWire.Container);
 }