private void BuildApplicationObjectGraph(ContainerBuilder builder, params Assembly[] assemblies)
        {
            // Instantiate and store all controllers...
            // These must be executed in the order of dependency.  For example the RulesController requires a NewRuleController so the NewRuleController must be instantiated first.
            IContainer container = builder.Build();

            Logger = container.Resolve <ILogger>();

            foreach (Assembly assembly in assemblies)
            {
                var requiredPropertyInjections = DefaultIoCRegistrations.ProcessPropertyInjection(assembly);
                foreach (PropertyInjectionDependencyRequirement requirement in requiredPropertyInjections)
                {
                    // Some reasonably awkard Autofac usage here to allow testibility.  (Extension methods aren't easy to test)
                    IComponentRegistration registration;
                    bool success = container.ComponentRegistry.TryGetRegistration(new TypedService(requirement.DependencyRequired), out registration);
                    if (success)
                    {
                        object dependency = container.ResolveComponent(registration, Enumerable.Empty <Parameter>());
                        requirement.PropertyInjectionAssignment(dependency);
                    }
                }
            }

            // Kick it off
            ConstructUiContext(container);
            this.disposables.AddIfSomething(container.Resolve <ICredentialStore>() as IDisposable);
            ShellController = container.Resolve <ShellController>();
            ShellWindow     = new ShellWindow {
                DataContext = ShellController
            };
        }
        public void ProcessPropertyInjectionShouldThrowGivenNullAssembly()
        {
            IEnumerable <PropertyInjectionDependencyRequirement> result = DefaultIoCRegistrations.ProcessPropertyInjection(null);

            result.Any();
            Assert.Fail();
        }
        private IContainer BuildApplicationObjectGraph(ContainerBuilder builder, params Assembly[] assemblies)
        {
            // Build Application Object Graph
            var container = builder.Build();

            Logger = container.Resolve <ILogger>();

            // Ensure anything requiring property injection is assigned a value.
            foreach (Assembly assembly in assemblies)
            {
                var requiredPropertyInjections = DefaultIoCRegistrations.ProcessPropertyInjection(assembly);
                foreach (PropertyInjectionDependencyRequirement requirement in requiredPropertyInjections)
                {
                    // Some reasonably awkard Autofac usage here to allow testibility.  (Extension methods aren't easy to test)
                    IComponentRegistration registration;
                    bool success = container.ComponentRegistry.TryGetRegistration(new TypedService(requirement.DependencyRequired), out registration);
                    if (success)
                    {
                        object dependency = container.ResolveComponent(registration, Enumerable.Empty <Parameter>());
                        requirement.PropertyInjectionAssignment(dependency);
                    }
                }
            }

            ConstructUiContext(container);

            return(container);
        }
        public void ProcessPropertyInjection_ShouldBeAbleToAssignLoggerToProperty()
        {
            var logger = new FakeLogger();
            IEnumerable <PropertyInjectionDependencyRequirement> result = DefaultIoCRegistrations.ProcessPropertyInjection(GetType().Assembly);

            result.First().PropertyInjectionAssignment(logger);

            Assert.AreSame(logger, AutoRegisterWithIoCProcessorPropertyInjectionTestSource.Logger);
        }
        public void ProcessPropertyInjection_ShouldFindOnePropertyInjectionDependency()
        {
            IEnumerable <PropertyInjectionDependencyRequirement> result = DefaultIoCRegistrations.ProcessPropertyInjection(GetType().Assembly);

            Assert.AreEqual(1, result.Count());
        }
        public void ProcessPropertyInjection_ShouldFindStaticClassWithILoggerProperty()
        {
            IEnumerable <PropertyInjectionDependencyRequirement> result = DefaultIoCRegistrations.ProcessPropertyInjection(GetType().Assembly);

            Assert.AreEqual(typeof(ILogger), result.First().DependencyRequired);
        }