Ejemplo n.º 1
0
        public static void Main()
        {
            var containerConfig = ContainerConfiguration.CreateFromAssembly(typeof(Program).Assembly, initializeAutoMapper: true);
            var container       = ServiceProvisioningInitializer.CreateContainer(containerConfig);

            container.GetInstance <IConsoleCommandsStartupService>().Start();
        }
Ejemplo n.º 2
0
        protected override void OnStartup(StartupEventArgs e)
        {
            var appAssembly = typeof(App).Assembly;

            var containerConfig = ContainerConfiguration.CreateFromAssembly(appAssembly);

            _container = ServiceProvisioningInitializer.CreateContainer(containerConfig);

            var fileSystem       = _container.GetService <IFileSystem>();
            var assemblyBasePath = typeof(App).Assembly.GetBasePath();
            var iconPath         = fileSystem.Path.Combine(assemblyBasePath, "Infrastructure", "Assets", "App.ico");

            var notifyIcon = new NotifyIcon
            {
                Text    = "Windows Buddies",
                Icon    = new Icon(iconPath),
                Visible = true,
            };

            var toolStripItemFactory = _container.GetService <IToolStripItemFactory>();
            var toolStripItems       = toolStripItemFactory.CreateAll();

            notifyIcon.ContextMenuStrip = new ContextMenuStrip();
            notifyIcon.ContextMenuStrip.Items.AddRange(toolStripItems);
        }
Ejemplo n.º 3
0
        public IIntegrationTestContext Build()
        {
            var container = ServiceProvisioningInitializer.CreateContainer(
                _containerConfig,
                _serviceDescriptors);

            return(new IntegrationTestContext(container));
        }
Ejemplo n.º 4
0
        public static async Task StartAppAsync(WpfAppConfiguration config, Action <IServiceLocator> afterInitializedCallback = null)
        {
            WpfAppRegistryCollection.WpfAssembly = config.WpfAssembly;

            var containerConfig = ContainerConfiguration.CreateFromAssembly(config.WpfAssembly, initializeAutoMapper: true);
            var container       = ServiceProvisioningInitializer.CreateContainer(containerConfig);

            var initService = container.GetInstance <IAppInitializationServant>();
            await initService.StartAppAsync(config, afterInitializedCallback);
        }
        public void InitializingContainer_FromContainerConfig_CreatesContainer()
        {
            // Arrange
            var containerConfig = new ContainerConfiguration(
                typeof(ServiceProvisioningInitializerUnitTests).Assembly,
                "Mmu");

            // Act
            var actualContainer = ServiceProvisioningInitializer.CreateContainer(containerConfig);

            // Assert
            Assert.That(actualContainer, Is.Not.Null);
        }
        public void InitializingContainer_FromContainerConfig_CallsRegistries()
        {
            // Arrange
            var containerConfig = new ContainerConfiguration(
                typeof(ServiceProvisioningInitializerUnitTests).Assembly,
                "Mmu");

            // Act
            ServiceProvisioningInitializer.CreateContainer(containerConfig);

            // Assert
            Assert.That(MockRegistry.WasCalled, Is.True);
        }
Ejemplo n.º 7
0
        protected override void OnStartup(StartupEventArgs e)
        {
            var containerConfig = ContainerConfiguration.CreateFromAssembly(typeof(App).Assembly, initializeAutoMapper: true);
            var container       = ServiceProvisioningInitializer.CreateContainer(containerConfig);

            var assemblyBasePath = typeof(App).Assembly.GetBasePath();
            var iconPath         = Path.Combine(assemblyBasePath, "Infrastructure", "Assets", "App.ico");

            var window = container.GetInstance <MainWindow>();

            window.Icon = new BitmapImage(new Uri(iconPath));

            window.ShowDialog();
        }
        public void InitializingContainer_WithOverridenServiceDescriptors_UsesOverridenServiceDescriptors()
        {
            // Arrange
            var containerConfig = new ContainerConfiguration(
                typeof(ServiceProvisioningInitializerUnitTests).Assembly,
                "Mmu");

            var mockIndividualService = Mock.Of <IIndividualService>();
            var serviceDescriptors    = new List <ServiceDescriptor>
            {
                new ServiceDescriptor(typeof(IIndividualService), mockIndividualService)
            };

            // Act
            var actualContainer         = ServiceProvisioningInitializer.CreateContainer(containerConfig, serviceDescriptors);
            var actualIndividualService = actualContainer.GetInstance <IIndividualService>();

            // Assert
            Assert.That(actualIndividualService, Is.Not.Null);
            Assert.That(actualIndividualService, Is.EqualTo(mockIndividualService));
        }