Commit bf8dc82
Changed files (4)
trunk
product
MyMoney
boot
container
Infrastructure
Container
trunk/product/MyMoney/boot/container/wire_up_the_container.cs
@@ -2,7 +2,6 @@ using System;
using Castle.Windsor;
using MoMoney.Infrastructure.Container.Windsor;
using MoMoney.Infrastructure.Container.Windsor.configuration;
-using MoMoney.Infrastructure.Extensions;
using MoMoney.Presentation.Model.interaction;
using MoMoney.Utility.Core;
using MoMoney.Utility.Extensions;
@@ -25,8 +24,6 @@ namespace MoMoney.boot.container
public void run()
{
- this.log().debug("initializing container");
-
Func<IWindsorContainer> container = () => new WindsorContainerFactory().create();
container = container.memorize();
@@ -40,7 +37,6 @@ namespace MoMoney.boot.container
.then(new wire_up_the_reports_in_to_the(registry))
.then(new run_mass_component_registration_in_to_the(container, specification, configuration))
.run();
- this.log().debug("finished initializing container");
}
}
}
\ No newline at end of file
trunk/product/MyMoney/Infrastructure/Container/Autofac/AutofacDependencyRegistry.cs
@@ -1,4 +1,3 @@
-using System;
using System.Collections.Generic;
using Autofac;
@@ -20,14 +19,7 @@ namespace MoMoney.Infrastructure.Container.Autofac
public IEnumerable<Interface> all_the<Interface>()
{
- foreach (var x in container.ComponentRegistrations)
- {
- foreach (var service in x.Descriptor.Services)
- {
- }
- }
- throw new NotImplementedException();
- //return container.Resolve<Interface>();
+ return container.Resolve<IEnumerable<Interface>>();
}
}
}
\ No newline at end of file
trunk/product/MyMoney/Infrastructure/Container/Autofac/AutofacSpecs.cs
@@ -0,0 +1,70 @@
+using System.Collections.Generic;
+using System.Linq;
+using Autofac;
+using Autofac.Builder;
+using Autofac.Modules;
+using developwithpassion.bdd.contexts;
+using MoMoney.Testing.spechelpers.contexts;
+using MoMoney.Testing.spechelpers.core;
+
+namespace MoMoney.Infrastructure.Container.Autofac
+{
+ public class when_trying_to_register_a_single_item_in_the_autofac_container : concerns
+ {
+ it should_resolve_that_item = () => result.should_be_an_instance_of<A>();
+
+ context c = () =>
+ {
+ builder = new ContainerBuilder();
+ builder.Register<A>().As<ITestItem>().FactoryScoped();
+ container = builder.Build();
+ };
+
+ because b = () => { result = container.Resolve<ITestItem>(); };
+
+ after_each_observation after_each = () => container.Dispose();
+
+ static ContainerBuilder builder;
+ static IContainer container;
+ static ITestItem result;
+ }
+
+ public class when_trying_to_resolve_all_the_components_that_implement_a_common_interface : concerns
+ {
+ it should_return_each_component = () =>
+ {
+ results.Count().should_be_equal_to(2);
+ results.First().should_be_an_instance_of<A>();
+ results.Skip(1).First().should_be_an_instance_of<B>();
+ };
+
+ context c = () =>
+ {
+ builder = new ContainerBuilder();
+ builder.RegisterModule(new ImplicitCollectionSupportModule());
+ builder.Register<A>().As<ITestItem>().FactoryScoped();
+ builder.Register<B>().As<ITestItem>().FactoryScoped();
+ container = builder.Build();
+ };
+
+ because b = () => { results = container.Resolve<IEnumerable<ITestItem>>(); };
+
+ after_each_observation after_each = () => container.Dispose();
+
+ static ContainerBuilder builder;
+ static IContainer container;
+ static IEnumerable<ITestItem> results;
+ }
+
+ public interface ITestItem
+ {
+ }
+
+ public class A : ITestItem
+ {
+ }
+
+ public class B : ITestItem
+ {
+ }
+}
\ No newline at end of file
trunk/product/MyMoney/MyMoney.csproj
@@ -41,7 +41,7 @@
</Reference>
<Reference Include="Autofac, Version=0.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
- <HintPath>..\..\build\lib\app\autofac\Autofac.dll</HintPath>
+ <HintPath>..\..\build\lib\app\auto.fac\Autofac.dll</HintPath>
</Reference>
<Reference Include="bdddoc, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
@@ -208,6 +208,7 @@
<Compile Include="Infrastructure\cloning\Prototype.cs" />
<Compile Include="Infrastructure\cloning\Serializer.cs" />
<Compile Include="Infrastructure\Container\Autofac\AutofacDependencyRegistry.cs" />
+ <Compile Include="Infrastructure\Container\Autofac\AutofacSpecs.cs" />
<Compile Include="Infrastructure\Container\Windsor\configuration\ApplyLoggingInterceptor.cs" />
<Compile Include="Infrastructure\Container\Windsor\configuration\ComponentExclusionSpecification.cs" />
<Compile Include="Infrastructure\Container\Windsor\configuration\ComponentExclusionSpecificationSpecs.cs" />