Commit 3b3c64c

mokhan <mokhan@ce5e1baf-6525-42e4-a1b2-857ea38da20a>
2009-03-20 21:19:42
starting to work on autofac.
git-svn-id: https://svn.xp-dev.com/svn/mokhan-mo.money@88 ce5e1baf-6525-42e4-a1b2-857ea38da20a
1 parent b1a32ff
Changed files (3)
trunk
product
MyMoney
Infrastructure
Container
proxies
trunk/product/MyMoney/Infrastructure/Container/Autofac/AutofacDependencyRegistry.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using Autofac;
+
+namespace MoMoney.Infrastructure.Container.Autofac
+{
+    internal class AutofacDependencyRegistry : IDependencyRegistry
+    {
+        readonly IContainer container;
+
+        public AutofacDependencyRegistry(IContainer container)
+        {
+            this.container = container;
+        }
+
+        public Interface get_a<Interface>()
+        {
+            return container.Resolve<Interface>();
+        }
+
+        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>();
+        }
+    }
+}
\ No newline at end of file
trunk/product/MyMoney/Infrastructure/proxies/Interceptors/MethodCallTracker.cs
@@ -38,7 +38,12 @@ namespace MoMoney.Infrastructure.proxies.Interceptors
         {
             var return_type = invocation.Method.ReturnType;
             if (return_type == typeof (void)) return;
-            invocation.ReturnValue = (return_type.IsValueType ? Activator.CreateInstance(return_type) : null);
+            invocation.ReturnValue = get_default_value_for(return_type);
+        }
+
+        static object get_default_value_for(Type return_type)
+        {
+            return (return_type.IsValueType ? Activator.CreateInstance(return_type) : null);
         }
     }
 }
\ No newline at end of file
trunk/product/MyMoney/MyMoney.csproj
@@ -39,6 +39,10 @@
       <SpecificVersion>False</SpecificVersion>
       <HintPath>..\..\build\lib\app\active.reports\ActiveReports3.dll</HintPath>
     </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>
+    </Reference>
     <Reference Include="bdddoc, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
       <SpecificVersion>False</SpecificVersion>
       <HintPath>..\..\build\lib\test\bdd.doc\bdddoc.dll</HintPath>
@@ -203,6 +207,7 @@
     <Compile Include="Infrastructure\cloning\ISerializer.cs" />
     <Compile Include="Infrastructure\cloning\Prototype.cs" />
     <Compile Include="Infrastructure\cloning\Serializer.cs" />
+    <Compile Include="Infrastructure\Container\Autofac\AutofacDependencyRegistry.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" />