Permalink
Browse files

Implement windsor support and nuget package.

  • Loading branch information...
1 parent a0d785e commit 95b791b386dd9e78f84540fdd083b18d833a5251 @mickdelaney mickdelaney committed with ianbattersby Jun 6, 2013
View
@@ -1,5 +1,5 @@
source 'https://rubygems.org'
-gem "rubyzip", "0.9.8"
+gem "rubyzip", "0.9.9"
gem "albacore", ">=0.3.4.0"
gem "rake", ">=10.0.3.0"
View
@@ -4,12 +4,12 @@ GEM
albacore (0.3.5)
rubyzip
rake (10.1.0)
- rubyzip (0.9.8)
+ rubyzip (0.9.9)
PLATFORMS
- ruby
+ x86-mingw32
DEPENDENCIES
albacore (>= 0.3.4.0)
rake (>= 10.0.3.0)
- rubyzip (= 0.9.8)
+ rubyzip (= 0.9.9)
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
+ <metadata>
+ <id>Simple.Web.Windsor</id>
+ <version>0.0.0.0</version>
+ <authors>Mark Rendle, Ian Battersby, and Mick Delaney</authors>
+ <owners>Mark Rendle, Ian Battersby, Mick Delaney</owners>
+ <copyright>Mark Rendle, Roy Jacobs</copyright>
+ <licenseUrl>http://www.opensource.org/licenses/mit-license.php</licenseUrl>
+ <projectUrl>http://github.com/markrendle/Simple.Web</projectUrl>
+ <requireLicenseAcceptance>false</requireLicenseAcceptance>
+ <description>Castle Windsor IoC container support for Simple.Web.</description>
+ <summary>A REST-focused, object-oriented Web Framework for .NET 4.</summary>
+ <tags>simple.web</tags>
+ <dependencies>
+ <dependency id="Simple.Web" version="0.0.0.0" />
+ <dependency id="Castle.Windsor" version="3.2.1" />
+ </dependencies>
+ </metadata>
+ <files>
+ <file src="..\..\build\Simple.Web.Windsor.dll" target="lib\net40" />
+ <file src="..\..\build\Simple.Web.Windsor.*db" target="lib\net40" />
+ <file src="..\..\src\Simple.Web.Windsor\**\*.cs" target="src" />
+ </files>
+</package>
View
@@ -26,7 +26,7 @@
ENV["EnableNuGetPackageRestore"] = "true"
# Symbol server configuration
-# SYMBOL_APIURL_LOCAL = ENV["symbol_local"]
+SYMBOL_APIURL_LOCAL = ENV["symbol_local"]
SYMBOL_APIURL_REMOTE = ENV["symbol_remote"] # For nuget.org make this the same as NUGET_APIURI_REMOTE
# Paths
@@ -21,5 +21,6 @@
[assembly: InternalsVisibleTo("Simple.Web.Razor.Tests")]
[assembly: InternalsVisibleTo("Simple.Web.Routing.Tests")]
[assembly: InternalsVisibleTo("Simple.Web.StructureMap.Tests")]
+[assembly: InternalsVisibleTo("Simple.Web.Windsor.Tests")]
[assembly: InternalsVisibleTo("Simple.Web.Tests")]
[assembly: InternalsVisibleTo("Simple.Web.Xml.Tests")]
@@ -0,0 +1,3 @@
+<?xml version="1.0"?>
+<configuration>
+<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
@@ -0,0 +1,38 @@
+using System.Collections.Generic;
+using Simple.Web.CodeGeneration;
+using Xunit;
+
+namespace Simple.Web.Windsor.Tests
+{
+ public class HandlerFactoryBuilderTests
+ {
+ [Fact]
+ public void CreatesInstanceOfType()
+ {
+ var startup = new TestStartup();
+ startup.Run(SimpleWeb.Configuration, SimpleWeb.Environment);
+ var builderFactory = new HandlerBuilderFactory(SimpleWeb.Configuration);
+ var handlerFactory = builderFactory.BuildHandlerBuilder(typeof(TestHandler));
+ var handler = (TestHandler)handlerFactory(new Dictionary<string, string> { { "TestProperty", "Foo" } }).Handler;
+ Assert.Equal(Status.OK, handler.Get());
+ Assert.Equal("Foo", handler.TestProperty);
+ }
+
+ [Fact]
+ public void DisposesInstances()
+ {
+ var startup = new TestStartup();
+ startup.Run(SimpleWeb.Configuration, SimpleWeb.Environment);
+ var builderFactory = new HandlerBuilderFactory(SimpleWeb.Configuration);
+ var handlerFactory = builderFactory.BuildHandlerBuilder(typeof(TestHandler));
+
+ TestHandler handler;
+ using (var scopedHandler = handlerFactory(new Dictionary<string, string>()))
+ {
+ handler = (TestHandler) scopedHandler.Handler;
+ Assert.Equal(false, handler.IsDisposed);
+ }
+ Assert.Equal(true, handler.IsDisposed);
+ }
+ }
+}
@@ -0,0 +1,7 @@
+namespace Simple.Web.Windsor.Tests
+{
+ public interface IResult
+ {
+ Status Result { get; }
+ }
+}
@@ -0,0 +1,7 @@
+namespace Simple.Web.Windsor.Tests
+{
+ public class OkResult : IResult
+ {
+ public Status Result { get { return Status.OK; }}
+ }
+}
@@ -0,0 +1,92 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{14F8FACA-9699-4CAC-8F5C-C1171A07BE6C}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Simple.Web.Windsor.Tests</RootNamespace>
+ <AssemblyName>Simple.Web.Windsor.Tests</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
+ <RestorePackages>true</RestorePackages>
+ <TargetFrameworkProfile />
+ </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="Castle.Core, Version=3.2.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\Castle.Core.3.2.0\lib\net40-client\Castle.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="Castle.Windsor, Version=3.2.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\Castle.Windsor.3.2.1\lib\net40\Castle.Windsor.dll</HintPath>
+ </Reference>
+ <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, Version=1.9.1.1600, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\xunit.1.9.1\lib\net20\xunit.dll</HintPath>
+ </Reference>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="..\CommonAssemblyInfo.cs">
+ <Link>Properties\CommonAssemblyInfo.cs</Link>
+ </Compile>
+ <Compile Include="HandlerFactoryBuilderTests.cs" />
+ <Compile Include="IResult.cs" />
+ <Compile Include="OkResult.cs" />
+ <Compile Include="TestHandler.cs" />
+ <Compile Include="TestInstaller.cs" />
+ <Compile Include="TestStartup.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ <None Include="packages.config">
+ <SubType>Designer</SubType>
+ </None>
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Simple.Web.Windsor\Simple.Web.Windsor.csproj">
+ <Project>{1c8870a8-d935-4708-83f9-feef29b6c7ad}</Project>
+ <Name>Simple.Web.Windsor</Name>
+ </ProjectReference>
+ <ProjectReference Include="..\Simple.Web\Simple.Web.csproj">
+ <Project>{903c289d-4cae-4259-80da-79d74ce06dce}</Project>
+ <Name>Simple.Web</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.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,27 @@
+using System;
+
+namespace Simple.Web.Windsor.Tests
+{
+ public class TestHandler : IGet, IDisposable
+ {
+ readonly IResult _result;
+ public bool IsDisposed { get; set; }
+
+ public TestHandler(IResult result)
+ {
+ _result = result;
+ }
+
+ public Status Get()
+ {
+ return _result.Result;
+ }
+
+ public string TestProperty { get; set; }
+
+ public void Dispose()
+ {
+ IsDisposed = true;
+ }
+ }
+}
@@ -0,0 +1,17 @@
+using Castle.MicroKernel.Registration;
+using Castle.MicroKernel.SubSystems.Configuration;
+using Castle.Windsor;
+
+namespace Simple.Web.Windsor.Tests
+{
+ public class TestInstaller : IWindsorInstaller
+ {
+ public TestInstaller() {}
+
+ public void Install(IWindsorContainer container, IConfigurationStore store)
+ {
+ container.Register(Component.For<IResult>().ImplementedBy<OkResult>().LifestyleScoped());
+ container.Register(Component.For<TestHandler>().ImplementedBy<TestHandler>().LifestyleScoped());
+ }
+ }
+}
@@ -0,0 +1,16 @@
+using System.Collections.Generic;
+using Castle.MicroKernel.Registration;
+
+namespace Simple.Web.Windsor.Tests
+{
+ public class TestStartup : WindsorStartupBase
+ {
+ protected override IEnumerable<IWindsorInstaller> GetInstallers()
+ {
+ return new List<IWindsorInstaller>
+ {
+ new TestInstaller()
+ };
+ }
+ }
+}
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<packages>
+ <package id="Castle.Core" version="3.2.0" targetFramework="net40" />
+ <package id="Castle.Windsor" version="3.2.1" targetFramework="net40" />
+ <package id="xunit" version="1.9.1" targetFramework="net40" />
+</packages>
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{1C8870A8-D935-4708-83F9-FEEF29B6C7AD}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Simple.Web.Windsor</RootNamespace>
+ <AssemblyName>Simple.Web.Windsor</AssemblyName>
+ <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
+ <FileAlignment>512</FileAlignment>
+ <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
+ <RestorePackages>true</RestorePackages>
+ <TargetFrameworkProfile />
+ </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>..\..\build\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ <ErrorReport>prompt</ErrorReport>
+ <WarningLevel>4</WarningLevel>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="Castle.Core, Version=3.2.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\Castle.Core.3.2.0\lib\net40-client\Castle.Core.dll</HintPath>
+ </Reference>
+ <Reference Include="Castle.Windsor, Version=3.2.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\packages\Castle.Windsor.3.2.1\lib\net40\Castle.Windsor.dll</HintPath>
+ </Reference>
+ <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" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="..\CommonAssemblyInfo.cs">
+ <Link>Properties\CommonAssemblyInfo.cs</Link>
+ </Compile>
+ <Compile Include="WindsorSimpleContainer.cs" />
+ <Compile Include="WindsorStartupBase.cs" />
+ <Compile Include="WindsorSimpleContainerScope.cs" />
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="packages.config" />
+ </ItemGroup>
+ <ItemGroup>
+ <ProjectReference Include="..\Simple.Web\Simple.Web.csproj">
+ <Project>{903c289d-4cae-4259-80da-79d74ce06dce}</Project>
+ <Name>Simple.Web</Name>
+ </ProjectReference>
+ </ItemGroup>
+ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+ <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.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,20 @@
+using Castle.Windsor;
+using Simple.Web.DependencyInjection;
+
+namespace Simple.Web.Windsor
+{
+ public class WindsorSimpleContainer : ISimpleContainer
+ {
+ readonly IWindsorContainer _container;
+
+ internal WindsorSimpleContainer(IWindsorContainer container)
+ {
+ _container = container;
+ }
+
+ public ISimpleContainerScope BeginScope()
+ {
+ return new WindsorSimpleContainerScope(_container);
+ }
+ }
+}
Oops, something went wrong.

0 comments on commit 95b791b

Please sign in to comment.