Commit 2028f88

mo <email@solidware.ca>
2011-03-17 02:47:18
replaced utility and infrastructure project with commons library.
1 parent 4f4f5b5
product/desktop.ui/bootstrappers/AutofacDependencyRegistry.cs
@@ -1,6 +1,6 @@
 using System.Collections.Generic;
 using Autofac;
-using infrastructure.container;
+using gorilla.infrastructure.container;
 
 namespace desktop.ui.bootstrappers
 {
product/desktop.ui/bootstrappers/Bootstrapper.cs
@@ -7,9 +7,9 @@ using desktop.ui.handlers;
 using desktop.ui.handlers.orm;
 using desktop.ui.presenters;
 using desktop.ui.views;
-using infrastructure.container;
-using infrastructure.threading;
-using utility;
+using gorilla.infrastructure.container;
+using gorilla.infrastructure.threading;
+using gorilla.utility;
 
 namespace desktop.ui.bootstrappers
 {
product/desktop.ui/bootstrappers/ConfigureMappings.cs
@@ -2,7 +2,7 @@ using System;
 using System.Collections.Generic;
 using desktop.ui.handlers.domain;
 using desktop.ui.presenters;
-using utility;
+using gorilla.utility;
 
 namespace desktop.ui.bootstrappers
 {
product/desktop.ui/bootstrappers/DefaultMapper.cs
@@ -1,5 +1,4 @@
-using System;
-using utility;
+using gorilla.utility;
 
 namespace desktop.ui.bootstrappers
 {
product/desktop.ui/bootstrappers/NeedsShutdown.cs
@@ -1,4 +1,4 @@
-using utility;
+using gorilla.utility;
 
 namespace desktop.ui.bootstrappers
 {
product/desktop.ui/bootstrappers/NeedStartup.cs
@@ -1,4 +1,4 @@
-using utility;
+using gorilla.utility;
 
 namespace desktop.ui.bootstrappers
 {
product/desktop.ui/eventing/SynchronizedEventAggregator.cs
@@ -2,7 +2,7 @@ using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Threading;
-using utility;
+using gorilla.utility;
 
 namespace desktop.ui.eventing
 {
product/desktop.ui/handlers/domain/Entity.cs
@@ -1,5 +1,5 @@
 using System;
-using utility;
+using gorilla.utility;
 
 namespace desktop.ui.handlers.domain
 {
product/desktop.ui/handlers/domain/Person.cs
@@ -1,4 +1,4 @@
-using utility;
+using gorilla.utility;
 
 namespace desktop.ui.handlers.domain
 {
product/desktop.ui/handlers/orm/InMemoryDatabase.cs
@@ -1,7 +1,7 @@
 using System;
 using System.Collections.Generic;
 using desktop.ui.handlers.domain;
-using utility;
+using gorilla.utility;
 using System.Linq;
 
 namespace desktop.ui.handlers.orm
product/desktop.ui/handlers/FindAllFamilyHandler.cs
@@ -1,7 +1,7 @@
 using desktop.ui.handlers.domain;
 using desktop.ui.handlers.orm;
 using desktop.ui.presenters;
-using utility;
+using gorilla.utility;
 
 namespace desktop.ui.handlers
 {
product/desktop.ui/presenters/AddFamilyMemberPresenter.cs
@@ -1,5 +1,5 @@
 using System;
-using utility;
+using gorilla.utility;
 
 namespace desktop.ui.presenters
 {
product/desktop.ui/presenters/PersonDetails.cs
@@ -1,5 +1,5 @@
 using System;
-using utility;
+using gorilla.utility;
 
 namespace desktop.ui.presenters
 {
product/desktop.ui/presenters/SelectedFamilyMemberPresenter.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using desktop.ui.eventing;
 using desktop.ui.events;
-using utility;
+using gorilla.utility;
 
 namespace desktop.ui.presenters
 {
product/desktop.ui/presenters/WpfCommandBuilder.cs
@@ -1,4 +1,4 @@
-using infrastructure.container;
+using gorilla.infrastructure.container;
 
 namespace desktop.ui.presenters
 {
product/desktop.ui/views/ShellWIndow.xaml.cs
@@ -1,7 +1,7 @@
 using System;
 using System.Collections.Generic;
 using System.Windows;
-using utility;
+using gorilla.utility;
 
 namespace desktop.ui.views
 {
product/desktop.ui/desktop.ui.csproj
@@ -39,6 +39,12 @@
     <Reference Include="Autofac">
       <HintPath>..\..\thirdparty\autofac\Autofac.dll</HintPath>
     </Reference>
+    <Reference Include="gorilla.infrastructure">
+      <HintPath>..\..\thirdparty\commons\gorilla.infrastructure.dll</HintPath>
+    </Reference>
+    <Reference Include="gorilla.utility">
+      <HintPath>..\..\thirdparty\commons\gorilla.utility.dll</HintPath>
+    </Reference>
     <Reference Include="System" />
     <Reference Include="System.Data" />
     <Reference Include="System.Drawing" />
@@ -198,16 +204,6 @@
     <Resource Include="views\images\cancel.png" />
     <Resource Include="views\images\save.png" />
   </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\infrastructure\infrastructure.csproj">
-      <Project>{CC006EB6-4E3C-4497-B8CC-5CAF54E40113}</Project>
-      <Name>infrastructure</Name>
-    </ProjectReference>
-    <ProjectReference Include="..\utility\utility.csproj">
-      <Project>{39B95E47-DA9C-4C80-A395-515600C55D4B}</Project>
-      <Name>utility</Name>
-    </ProjectReference>
-  </ItemGroup>
   <ItemGroup />
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
product/desktop.ui/InMemoryServiceBus.cs
@@ -1,7 +1,7 @@
 using System;
 using desktop.ui.handlers;
-using infrastructure.container;
-using utility;
+using gorilla.infrastructure.container;
+using gorilla.utility;
 
 namespace desktop.ui
 {
product/desktop.ui/Observable.cs
@@ -1,7 +1,7 @@
 using System;
 using System.ComponentModel;
 using System.Linq.Expressions;
-using utility;
+using gorilla.utility;
 
 namespace desktop.ui
 {
product/desktop.ui/Program.cs
@@ -4,7 +4,7 @@ using System.Windows;
 using System.Windows.Threading;
 using desktop.ui.bootstrappers;
 using desktop.ui.views;
-using infrastructure.logging;
+using gorilla.infrastructure.logging;
 
 namespace desktop.ui
 {
product/desktop.ui/WPFPresenterFactory.cs
@@ -1,4 +1,4 @@
-using infrastructure.container;
+using gorilla.infrastructure.container;
 
 namespace desktop.ui
 {
product/infrastructure/infrastructure.csproj
@@ -88,12 +88,6 @@
       <SubType>Component</SubType>
     </Compile>
   </ItemGroup>
-  <ItemGroup>
-    <ProjectReference Include="..\utility\utility.csproj">
-      <Project>{39B95E47-DA9C-4C80-A395-515600C55D4B}</Project>
-      <Name>utility</Name>
-    </ProjectReference>
-  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.
product/specs/Create.cs
@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using Rhino.Mocks;
+
+namespace specs
+{
+    static class Create
+    {
+        static public T dependency<T>() where T : class
+        {
+            return An<T>();
+        }
+
+        static public Stub an<Stub>() where Stub : class
+        {
+            return An<Stub>();
+        }
+
+        static ItemToStub An<ItemToStub>() where ItemToStub : class
+        {
+            var type = typeof (ItemToStub);
+            if (type.IsClass)
+            {
+                var constructors =
+                    type.GetConstructors(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
+                if (constructors.Any(x => x.GetParameters().Length == 0))
+                    return MockRepository.GenerateMock<ItemToStub>();
+
+                return
+                    MockRepository.GenerateMock<ItemToStub>(
+                        get_parameters_for(get_greediest_constructor_from(constructors)).ToArray());
+            }
+            return MockRepository.GenerateMock<ItemToStub>();
+        }
+
+        static IEnumerable<object> get_parameters_for(ConstructorInfo constructor)
+        {
+            return constructor
+                .GetParameters()
+                .Select(x =>
+                {
+                    if (x.ParameterType.IsValueType)
+                        return Activator.CreateInstance(x.ParameterType);
+                    if (x.ParameterType.IsSealed) return null;
+                    return MockRepository.GenerateStub(x.ParameterType);
+                });
+        }
+
+        static ConstructorInfo get_greediest_constructor_from(IEnumerable<ConstructorInfo> constructors)
+        {
+            return constructors.OrderBy(x => x.GetParameters().Count()).Last();
+        }
+    }
+}
\ No newline at end of file
product/specs/specs.csproj
@@ -52,7 +52,7 @@
   <ItemGroup>
     <Compile Include="Mocking.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="The.cs" />
+    <Compile Include="Create.cs" />
   </ItemGroup>
   <ItemGroup>
     <ProjectReference Include="..\desktop.ui\desktop.ui.csproj">
product/specs/The.cs
@@ -1,12 +0,0 @@
-using Rhino.Mocks;
-
-namespace specs
-{
-    static class The
-    {
-        public static T dependency<T>() where T : class
-        {
-            return MockRepository.GenerateMock<T>();
-        }
-    }
-}
\ No newline at end of file
thirdparty/commons/gorilla.infrastructure.dll
Binary file
thirdparty/commons/gorilla.utility.dll
Binary file
studio.sln
@@ -5,10 +5,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "desktop.ui", "product\deskt
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "specs", "product\specs\specs.csproj", "{B10E4560-2546-4A11-B2D1-5505BFCDDCC9}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "infrastructure", "product\infrastructure\infrastructure.csproj", "{CC006EB6-4E3C-4497-B8CC-5CAF54E40113}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "utility", "product\utility\utility.csproj", "{39B95E47-DA9C-4C80-A395-515600C55D4B}"
-EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -39,26 +35,6 @@ Global
 		{B10E4560-2546-4A11-B2D1-5505BFCDDCC9}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
 		{B10E4560-2546-4A11-B2D1-5505BFCDDCC9}.Release|Mixed Platforms.Build.0 = Release|Any CPU
 		{B10E4560-2546-4A11-B2D1-5505BFCDDCC9}.Release|x86.ActiveCfg = Release|Any CPU
-		{CC006EB6-4E3C-4497-B8CC-5CAF54E40113}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{CC006EB6-4E3C-4497-B8CC-5CAF54E40113}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{CC006EB6-4E3C-4497-B8CC-5CAF54E40113}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
-		{CC006EB6-4E3C-4497-B8CC-5CAF54E40113}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
-		{CC006EB6-4E3C-4497-B8CC-5CAF54E40113}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{CC006EB6-4E3C-4497-B8CC-5CAF54E40113}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{CC006EB6-4E3C-4497-B8CC-5CAF54E40113}.Release|Any CPU.Build.0 = Release|Any CPU
-		{CC006EB6-4E3C-4497-B8CC-5CAF54E40113}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
-		{CC006EB6-4E3C-4497-B8CC-5CAF54E40113}.Release|Mixed Platforms.Build.0 = Release|Any CPU
-		{CC006EB6-4E3C-4497-B8CC-5CAF54E40113}.Release|x86.ActiveCfg = Release|Any CPU
-		{39B95E47-DA9C-4C80-A395-515600C55D4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{39B95E47-DA9C-4C80-A395-515600C55D4B}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{39B95E47-DA9C-4C80-A395-515600C55D4B}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
-		{39B95E47-DA9C-4C80-A395-515600C55D4B}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
-		{39B95E47-DA9C-4C80-A395-515600C55D4B}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{39B95E47-DA9C-4C80-A395-515600C55D4B}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{39B95E47-DA9C-4C80-A395-515600C55D4B}.Release|Any CPU.Build.0 = Release|Any CPU
-		{39B95E47-DA9C-4C80-A395-515600C55D4B}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
-		{39B95E47-DA9C-4C80-A395-515600C55D4B}.Release|Mixed Platforms.Build.0 = Release|Any CPU
-		{39B95E47-DA9C-4C80-A395-515600C55D4B}.Release|x86.ActiveCfg = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE