예제 #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
                .ConfigureCore(adapter) //Note: Set the container.
                .WithPresentationFramework()
                .Start();

            //Note: Retrieve one of Caliburn's services.
            var controller = container.Resolve<IRoutedMessageController>();

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

            //Note: Use the above method to add defaults for additional controls as well.
        }
예제 #2
0
        /// <summary>
        /// Creates the container.
        /// </summary>
        /// <returns></returns>
        protected IContainer CreateContainer()
        {
            container = new WindsorContainer();
            var windsorAdapter = new WindsorAdapter(container);

            SetupContainer();

            return windsorAdapter;
        }
예제 #3
0
파일: App.xaml.cs 프로젝트: Mrding/Ribbon
        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;
        }
예제 #4
0
        protected override void OnStartup(StartupEventArgs e)
        {
            InitializeComponent();
            log4net.Config.XmlConfigurator.Configure();
            var container = new WindsorContainer(new XmlInterpreter());
            container.Register(Component.For<IApplication>().Instance(this));
            container.Register(Component.For<IQueueManagerCache>()
                .ImplementedBy<QueueManagerCache>()
                .LifeStyle.Singleton);
            container.Register(Component.For<IQueueRepository>()
                .ImplementedBy<LocalQueueRepository>()
                .LifeStyle.Transient);
            container.Register(Component.For<IMessageRepository>()
                .ImplementedBy<LocalMessageRepository>()
                .LifeStyle.Transient);

            var adapter = new WindsorAdapter(container);
            CaliburnApplication
                .ConfigureCore(adapter)
                .WithAssemblies(Assembly.GetExecutingAssembly())
                .WithActions()
                .WithRoutedUIMessaging()
                .StartApplication();

            var views = (from a in GetType().Assembly.GetTypes()
                         let attributes = a.GetCustomAttributes(typeof(ViewAttribute), false)
                         where attributes.Any()
                         select attributes).SelectMany(at => at.Select(a => ((ViewAttribute)a).ViewType));

            container.Register(
                AllTypes.From(views)
                .Where(t => true).Configure(registration => registration.LifeStyle.Is(LifestyleType.Transient))
                );

            ServiceLocator.Current.GetInstance<IApplicationController>().Initialize();

            base.OnStartup(e);
        }