Exemple #1
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            // Note: the culture used by String.Format() and CultureInfo.CurrentCulture and Binding StringFormat
            // are independant.
            // String.Format() seems to use the System locale (i.e. select language in system tray)
            // CultureInfo.CurrentCulture is locale of User - Region settings, Change location, Format tab
            // I think Binding StringFormat always uses en-US unless changed explicitly using the below:
            FrameworkElement.LanguageProperty.OverrideMetadata(typeof(FrameworkElement),
                new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));

            EventManager.RegisterClassHandler(typeof(TextBox), TextBox.PreviewMouseLeftButtonDownEvent,
                new MouseButtonEventHandler(SelectivelyIgnoreMouseButton));
            EventManager.RegisterClassHandler(typeof(TextBox), TextBox.GotKeyboardFocusEvent,
                new RoutedEventHandler(SelectAllText));
            EventManager.RegisterClassHandler(typeof(TextBox), TextBox.MouseDoubleClickEvent,
                new RoutedEventHandler(SelectAllText));

            Window w = new AppWindow();

            var container = new WindsorContainer();

            // allow collection injection
            container.Kernel.Resolver.AddSubResolver(new CollectionResolver(container.Kernel));

            // disable automatic property injection
            container.Kernel.ComponentModelBuilder.RemoveContributor(
                container.Kernel.ComponentModelBuilder.Contributors.OfType<PropertiesDependenciesModelInspector>().Single());

            container.Kernel.AddFacility<TypedFactoryFacility>();

            container.Register(Component.For<Window>().Instance(w));
            container.Register(Component.For<Dispatcher>().UsingFactoryMethod(() => w.Dispatcher));

            container.Install(FromAssembly.InDirectory(
                new AssemblyFilter(Path.GetDirectoryName(
                    Assembly.GetExecutingAssembly().Location))));

            //container.Install(
            //                new SystemInstaller(),
            //                new EnginesInstaller(),
            //                new ConnectionInstaller(),
            //                new EFModelContextFactoryInstaller(),
            //                new DialogServiceInstaller(w),
            //                //new RepositoriesInstaller(),
            //                new InterceptorsInstaller(),
            //                new MappingsCreatorInstaller(),
            //                new EntityInstaller(),
            //                new Finances.Service.ServiceInstaller(),
            //                new Finances.Persistence.EF.BootstrapInstaller(),
            //                new DomainServicesInstaller(),
            //                new ExceptionServiceInstaller(),
            //                new UtilitiesInstaller(w),

            //                new WorkspaceInstaller(),
            //                new ViewModelInstallers()
            //                );

            foreach (var handler in container.Kernel.GetAssignableHandlers(typeof(object)))
            {
                Console.Write("{0} :",handler.ComponentModel.Implementation);
                foreach (var service in handler.ComponentModel.Services)
                {
                    Console.Write(" {0}", service.Name);
                }
                Console.WriteLine();
            }

            container.Resolve<Apex>();

            container.Resolve<MappingsCreator>();

            w.DataContext = container.Resolve<IMainViewModel>();

            w.Show();
        }