Permalink
Browse files

- Added Windsor with basic ControllerFactory

- Added empty XUnit test project
- Added init code for RavenDb DocStore
  • Loading branch information...
1 parent e638fae commit 937676ac56c40349cef2c4f3a702589859cbf465 @csainty csainty committed Jul 11, 2011
Showing with 60,280 additions and 4 deletions.
  1. +11 −0 HibernatingRhinos.Macto.Tests/Class1.cs
  2. +60 −0 HibernatingRhinos.Macto.Tests/HibernatingRhinos.Macto.Tests.csproj
  3. +36 −0 HibernatingRhinos.Macto.Tests/Properties/AssemblyInfo.cs
  4. +4 −0 HibernatingRhinos.Macto.Tests/packages.config
  5. +12 −0 HibernatingRhinos.Macto.sln
  6. +20 −0 HibernatingRhinos.Macto/Controllers/HomeController.cs
  7. +33 −3 HibernatingRhinos.Macto/Global.asax.cs
  8. +10 −1 HibernatingRhinos.Macto/HibernatingRhinos.Macto.csproj
  9. +24 −0 HibernatingRhinos.Macto/Infrastructure/Windsor/Installers/ControllersInstaller.cs
  10. +34 −0 HibernatingRhinos.Macto/Infrastructure/Windsor/WindsorControllerFactory.cs
  11. +5 −0 HibernatingRhinos.Macto/Views/Home/Index.cshtml
  12. +2 −0 HibernatingRhinos.Macto/packages.config
  13. +57 −0 packages/Castle.Core.2.5.2/lib/ASL - Apache Software Foundation License.txt
  14. +55 −0 packages/Castle.Core.2.5.2/lib/BreakingChanges.txt
  15. +145 −0 packages/Castle.Core.2.5.2/lib/Changes.txt
  16. +80 −0 packages/Castle.Core.2.5.2/lib/Committers.txt
  17. BIN packages/Castle.Core.2.5.2/lib/NET35/Castle.Core.dll
  18. +4,927 −0 packages/Castle.Core.2.5.2/lib/NET35/Castle.Core.xml
  19. BIN packages/Castle.Core.2.5.2/lib/NET40ClientProfile/Castle.Core.dll
  20. +4,927 −0 packages/Castle.Core.2.5.2/lib/NET40ClientProfile/Castle.Core.xml
  21. BIN packages/Castle.Core.2.5.2/lib/SL3/Castle.Core.dll
  22. +4,443 −0 packages/Castle.Core.2.5.2/lib/SL3/Castle.Core.xml
  23. BIN packages/Castle.Core.2.5.2/lib/SL4/Castle.Core.dll
  24. +4,443 −0 packages/Castle.Core.2.5.2/lib/SL4/Castle.Core.xml
  25. +8 −0 packages/Castle.Core.2.5.2/lib/releaseNotes.txt
  26. +57 −0 packages/Castle.Windsor.2.5.3/lib/ASL - Apache Software Foundation License.txt
  27. +303 −0 packages/Castle.Windsor.2.5.3/lib/BreakingChanges.txt
  28. +822 −0 packages/Castle.Windsor.2.5.3/lib/Changes.txt
  29. +80 −0 packages/Castle.Windsor.2.5.3/lib/Committers.txt
  30. BIN packages/Castle.Windsor.2.5.3/lib/NET35/Castle.Windsor.dll
  31. BIN packages/Castle.Windsor.2.5.3/lib/NET35/Castle.Windsor.pdb
  32. +7,741 −0 packages/Castle.Windsor.2.5.3/lib/NET35/Castle.Windsor.xml
  33. BIN packages/Castle.Windsor.2.5.3/lib/NET40-Client/Castle.Windsor.dll
  34. BIN packages/Castle.Windsor.2.5.3/lib/NET40-Client/Castle.Windsor.pdb
  35. +7,693 −0 packages/Castle.Windsor.2.5.3/lib/NET40-Client/Castle.Windsor.xml
  36. BIN packages/Castle.Windsor.2.5.3/lib/NET40/Castle.Windsor.dll
  37. BIN packages/Castle.Windsor.2.5.3/lib/NET40/Castle.Windsor.pdb
  38. +7,741 −0 packages/Castle.Windsor.2.5.3/lib/NET40/Castle.Windsor.xml
  39. BIN packages/Castle.Windsor.2.5.3/lib/SL3/Castle.Windsor.dll
  40. BIN packages/Castle.Windsor.2.5.3/lib/SL3/Castle.Windsor.pdb
  41. +7,027 −0 packages/Castle.Windsor.2.5.3/lib/SL3/Castle.Windsor.xml
  42. BIN packages/Castle.Windsor.2.5.3/lib/SL4/Castle.Windsor.dll
  43. BIN packages/Castle.Windsor.2.5.3/lib/SL4/Castle.Windsor.pdb
  44. +7,032 −0 packages/Castle.Windsor.2.5.3/lib/SL4/Castle.Windsor.xml
  45. +8 −0 packages/Castle.Windsor.2.5.3/lib/releaseNotes.txt
  46. +1 −0 packages/repositories.config
  47. BIN packages/xunit.1.8.0.1545/lib/xunit.dll
  48. +2,439 −0 packages/xunit.1.8.0.1545/lib/xunit.xml
@@ -0,0 +1,11 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace HibernatingRhinos.Macto.Tests
+{
+ public class Class1
+ {
+ }
+}
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>8.0.30703</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{504AD412-D340-4F44-9789-5BF98B8B4D81}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>HibernatingRhinos.Macto.Tests</RootNamespace>
+ <AssemblyName>HibernatingRhinos.Macto.Tests</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>pdbonly</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Data.DataSetExtensions" />
+ <Reference Include="Microsoft.CSharp" />
+ <Reference Include="System.Data" />
+ <Reference Include="System.Xml" />
+ <Reference Include="xunit">
+ <HintPath>..\packages\xunit.1.8.0.1545\lib\xunit.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Class1.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </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.
+ <Target Name="BeforeBuild">
+ </Target>
+ <Target Name="AfterBuild">
+ </Target>
+ -->
+</Project>
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("HibernatingRhinos.Macto.Tests")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("HibernatingRhinos.Macto.Tests")]
+[assembly: AssemblyCopyright("Copyright © 2011")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("b1b2d4d3-c247-43c9-84a8-a608ea39b2bc")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="xunit" version="1.8.0.1545" />
+</packages>
@@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HibernatingRhinos.Macto", "HibernatingRhinos.Macto\HibernatingRhinos.Macto.csproj", "{A6386D3C-60B3-4586-B7CF-222013C04C2F}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HibernatingRhinos.Macto.Tests", "HibernatingRhinos.Macto.Tests\HibernatingRhinos.Macto.Tests.csproj", "{504AD412-D340-4F44-9789-5BF98B8B4D81}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -23,6 +25,16 @@ Global
{A6386D3C-60B3-4586-B7CF-222013C04C2F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{A6386D3C-60B3-4586-B7CF-222013C04C2F}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{A6386D3C-60B3-4586-B7CF-222013C04C2F}.Release|x86.ActiveCfg = Release|Any CPU
+ {504AD412-D340-4F44-9789-5BF98B8B4D81}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {504AD412-D340-4F44-9789-5BF98B8B4D81}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {504AD412-D340-4F44-9789-5BF98B8B4D81}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+ {504AD412-D340-4F44-9789-5BF98B8B4D81}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+ {504AD412-D340-4F44-9789-5BF98B8B4D81}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {504AD412-D340-4F44-9789-5BF98B8B4D81}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {504AD412-D340-4F44-9789-5BF98B8B4D81}.Release|Any CPU.Build.0 = Release|Any CPU
+ {504AD412-D340-4F44-9789-5BF98B8B4D81}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+ {504AD412-D340-4F44-9789-5BF98B8B4D81}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+ {504AD412-D340-4F44-9789-5BF98B8B4D81}.Release|x86.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.Mvc;
+
+namespace HibernatingRhinos.Macto.Controllers
+{
+ public class HomeController : Controller
+ {
+ //
+ // GET: /Home/
+
+ public ActionResult Index()
+ {
+ return View();
+ }
+
+ }
+}
@@ -4,12 +4,14 @@
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
+using Castle.Windsor;
+using Castle.Windsor.Installer;
+using Raven.Client;
+using Raven.Client.Document;
+using HibernatingRhinos.Macto.Infrastructure.Windsor;
namespace HibernatingRhinos.Macto
{
- // Note: For instructions on enabling IIS6 or IIS7 classic mode,
- // visit http://go.microsoft.com/?LinkId=9394801
-
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterGlobalFilters(GlobalFilterCollection filters)
@@ -20,6 +22,7 @@ public static void RegisterGlobalFilters(GlobalFilterCollection filters)
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
+ routes.Ignore("favicon.ico");
routes.MapRoute(
"Default", // Route name
@@ -35,6 +38,33 @@ protected void Application_Start()
RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
+
+ CreateRavenDbDocumentStore();
+ BootstrapContainer();
+ }
+
+ protected void Application_End()
+ {
+ container.Dispose();
+ var store = Application.Get("RavenDbDocumentStore") as IDocumentStore;
+ if (store != null)
+ store.Dispose();
+ }
+
+ public static IDocumentStore DocumentStore { get { return HttpContext.Current.Application["RavenDbDocumentStore"] as IDocumentStore; } }
+ private void CreateRavenDbDocumentStore()
+ {
+ IDocumentStore store = new DocumentStore() { ConnectionStringName = "RavenDB" }.Initialize();
+ Application.Add("RavenDbDocumentStore", store);
+ }
+
+ private static IWindsorContainer container;
+ private static void BootstrapContainer()
+ {
+ container = new WindsorContainer()
+ .Install(FromAssembly.This());
+ var controllerFactory = new WindsorControllerFactory(container.Kernel);
+ ControllerBuilder.Current.SetControllerFactory(controllerFactory);
}
}
}
@@ -37,6 +37,12 @@
<Reference Include="AsyncCtpLibrary">
<HintPath>..\packages\RavenDB.1.0.0.397\lib\net40\AsyncCtpLibrary.dll</HintPath>
</Reference>
+ <Reference Include="Castle.Core">
+ <HintPath>..\packages\Castle.Core.2.5.2\lib\NET35\Castle.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="Castle.Windsor">
+ <HintPath>..\packages\Castle.Windsor.2.5.3\lib\NET40\Castle.Windsor.dll</HintPath>
+ </Reference>
<Reference Include="MissingBitsFromClientProfile">
<HintPath>..\packages\RavenDB.1.0.0.397\lib\net40\MissingBitsFromClientProfile.dll</HintPath>
</Reference>
@@ -80,9 +86,11 @@
<Reference Include="System.EnterpriseServices" />
</ItemGroup>
<ItemGroup>
+ <Compile Include="Controllers\HomeController.cs" />
<Compile Include="Global.asax.cs">
<DependentUpon>Global.asax</DependentUpon>
</Compile>
+ <Compile Include="Infrastructure\Windsor\Installers\ControllersInstaller.cs" />
<Compile Include="Models\Commands\AcceptNewInmateCommand.cs" />
<Compile Include="Models\Commands\AddCliffNoteCommand.cs" />
<Compile Include="Models\Commands\AddStickyNoteCommand.cs" />
@@ -122,6 +130,7 @@
<Compile Include="Models\Warrants\RemandWarrant.cs" />
<Compile Include="Models\Warrants\SentencingWarrant.cs" />
<Compile Include="Models\Warrants\Warrant.cs" />
+ <Compile Include="Infrastructure\Windsor\WindsorControllerFactory.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
@@ -213,7 +222,7 @@
<Content Include="Views\Shared\_Layout.cshtml" />
</ItemGroup>
<ItemGroup>
- <Folder Include="Controllers\" />
+ <Content Include="Views\Home\Index.cshtml" />
</ItemGroup>
<ItemGroup>
<Content Include="packages.config" />
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.Mvc;
+using Castle.MicroKernel.Registration;
+using Castle.MicroKernel.SubSystems.Configuration;
+using Castle.Windsor;
+using HibernatingRhinos.Macto.Controllers;
+
+namespace HibernatingRhinos.Macto.Infrastructure.Windsor.Installers
+{
+ public class ControllersInstaller : IWindsorInstaller
+ {
+ public void Install(IWindsorContainer container, IConfigurationStore store)
+ {
+ container.Register(AllTypes.FromThisAssembly()
+ .BasedOn<IController>()
+ .If(Component.IsInSameNamespaceAs<HomeController>())
+ .If(t => t.Name.EndsWith("Controller"))
+ .Configure(c => c.LifeStyle.Transient));
+ }
+ }
+}
@@ -0,0 +1,34 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Web;
+using System.Web.Mvc;
+using System.Web.Routing;
+using Castle.MicroKernel;
+
+namespace HibernatingRhinos.Macto.Infrastructure.Windsor
+{
+ public class WindsorControllerFactory : DefaultControllerFactory
+ {
+ private readonly IKernel kernel;
+
+ public WindsorControllerFactory(IKernel kernel)
+ {
+ this.kernel = kernel;
+ }
+
+ public override void ReleaseController(IController controller)
+ {
+ kernel.ReleaseComponent(controller);
+ }
+
+ protected override IController GetControllerInstance(RequestContext requestContext, Type controllerType)
+ {
+ if (controllerType == null)
+ {
+ throw new HttpException(404, string.Format("The controller for path '{0}' could not be found.", requestContext.HttpContext.Request.Path));
+ }
+ return (IController)kernel.Resolve(controllerType);
+ }
+ }
+}
@@ -0,0 +1,5 @@
+@{
+ ViewBag.Title = "Index";
+}
+
+<h2>Index</h2>
@@ -6,4 +6,6 @@
<package id="jQuery" version="1.6.2" />
<package id="Newtonsoft.Json" version="4.0.2" />
<package id="RavenDB" version="1.0.0.397" />
+ <package id="Castle.Core" version="2.5.2" />
+ <package id="Castle.Windsor" version="2.5.3" />
</packages>
Oops, something went wrong.

0 comments on commit 937676a

Please sign in to comment.