Changeset 427
- Timestamp:
- 02/08/10 23:52:45 (6 months ago)
- Location:
- trunk/src
- Files:
-
- 4 added
- 1 removed
- 43 modified
- 1 copied
- 2 moved
-
aspnet/OpenRasta.Codecs.WebForms.Tests.Unit/OpenRasta.Codecs.WebForms.Tests.Unit.csproj (modified) (2 diffs)
-
aspnet/OpenRasta.Codecs.WebForms.Tests.Unit/dependencies.targets (added)
-
aspnet/OpenRasta.Codecs.WebForms/dependencies.targets (modified) (1 diff)
-
aspnet/OpenRasta.Hosting.AspNet/AspNetRequest.cs (modified) (3 diffs)
-
aspnet/OpenRasta.Hosting.AspNet/AspNetResponse.cs (modified) (3 diffs)
-
aspnet/OpenRasta.Hosting.AspNet/HttpInputStream.cs (modified) (2 diffs)
-
core/OpenRasta.4.5.resharper (deleted)
-
core/OpenRasta/OpenRasta.csproj.resharper (modified) (2 diffs)
-
core/core.4.5.resharper (modified) (1 diff)
-
ninject/OpenRasta.DI.Ninject.Tests.Unit/OpenRasta.DI.Ninject.Tests.Unit.csproj (modified) (2 diffs)
-
ninject/OpenRasta.DI.Ninject/OpenRasta.DI.Ninject.csproj (modified) (4 diffs)
-
ninject/ninject.sln (moved) (moved from trunk/src/ninject/OpenRasta.DI.Ninject.sln)
-
openbastard/OpenBastard.TestRunner/Environments/HttpWebRequestEnvironment.cs (modified) (1 diff)
-
openbastard/OpenBastard.TestRunner/Environments/WebRequestResponse.cs (modified) (1 diff)
-
openbastard/openbastard.sln (modified) (1 diff)
-
sharpview/OpenRasta.Codecs.SharpView.Tests.Unit/OpenRasta.Codecs.SharpView.Tests.Unit.csproj (modified) (3 diffs)
-
sharpview/OpenRasta.Codecs.SharpView.Tests.Unit/SharpView_Specification.cs (modified) (3 diffs)
-
sharpview/OpenRasta.Codecs.SharpView.Tests.Unit/dependencies.targets (copied) (copied from trunk/src/sharpview/OpenRasta.Codecs.SharpView/dependencies.targets)
-
sharpview/OpenRasta.Codecs.SharpView/OpenRasta.Codecs.SharpView.csproj (modified) (1 diff)
-
sharpview/OpenRasta.Codecs.SharpView/SourcedElementExtensions.cs (modified) (3 diffs)
-
sharpview/OpenRasta.Codecs.SharpView/Visitors/ChildScopeForEachFinder.cs (modified) (1 diff)
-
sharpview/OpenRasta.Codecs.SharpView/Visitors/ChildScopeRewriterVisitor.cs (modified) (1 diff)
-
sharpview/OpenRasta.Codecs.SharpView/Visitors/CurrentItemRewriterVisitor.cs (modified) (1 diff)
-
sharpview/OpenRasta.Codecs.SharpView/Visitors/ForEachRewriter.cs (modified) (2 diffs)
-
sharpview/OpenRasta.Codecs.SharpView/Visitors/IfRewriterVisitor.cs (modified) (1 diff)
-
sharpview/OpenRasta.Codecs.SharpView/Visitors/MemberAccessNullPropagateVisitor.cs (modified) (1 diff)
-
sharpview/OpenRasta.Codecs.SharpView/Visitors/PropertyPathForIteratorVisitor.cs (modified) (1 diff)
-
sharpview/OpenRasta.Codecs.SharpView/Visitors/ScopedForEachFinder.cs (modified) (1 diff)
-
sharpview/OpenRasta.Codecs.SharpView/Visitors/SelectHtmlPropertyPathRewriter.cs (modified) (3 diffs)
-
unity/OpenRasta.DI.Unity.4.5.resharper (added)
-
unity/OpenRasta.DI.Unity.Sample/OpenRasta.DI.Unity.Sample.csproj (modified) (1 diff)
-
unity/OpenRasta.DI.Unity.Tests.Unit/OpenRasta.DI.Unity.Tests.Unit.csproj (modified) (3 diffs)
-
unity/OpenRasta.DI.Unity.Tests.Unit/dependencies.targets (added)
-
unity/OpenRasta.DI.Unity/Extensions/CycleDetector.cs (modified) (2 diffs)
-
unity/OpenRasta.DI.Unity/Extensions/InjectionPolicies.cs (modified) (2 diffs)
-
unity/OpenRasta.DI.Unity/Extensions/Policies/ConstructorSelectorPolicy.cs (modified) (4 diffs)
-
unity/OpenRasta.DI.Unity/Extensions/Policies/CycleDetectionPolicy.cs (modified) (1 diff)
-
unity/OpenRasta.DI.Unity/Extensions/Policies/PropertySelectorPolicy.cs (modified) (5 diffs)
-
unity/OpenRasta.DI.Unity/Extensions/Policies/TypeToBeResolved.cs (modified) (1 diff)
-
unity/OpenRasta.DI.Unity/Extensions/Policies/TypeTrackerPolicy.cs (modified) (1 diff)
-
unity/OpenRasta.DI.Unity/Extensions/Strategies/CycleDetectionStrategy.cs (modified) (2 diffs)
-
unity/OpenRasta.DI.Unity/Extensions/Strategies/TypeRegistrationRequiredStrategy.cs (modified) (4 diffs)
-
unity/OpenRasta.DI.Unity/Extensions/TypeRegistrationRequired.cs (modified) (1 diff)
-
unity/OpenRasta.DI.Unity/Extensions/TypeTracker.cs (modified) (2 diffs)
-
unity/OpenRasta.DI.Unity/OpenRasta.DI.Unity.csproj (modified) (3 diffs)
-
unity/OpenRasta.DI.Unity/PerRequestLifetimeManager.cs (modified) (3 diffs)
-
unity/OpenRasta.DI.Unity/Properties/AssemblyInfo.cs (modified) (2 diffs)
-
unity/OpenRasta.DI.Unity/UnityContainerExtensions.cs (modified) (1 diff)
-
unity/OpenRasta.DI.Unity/UnityDependencyResolver.cs (modified) (7 diffs)
-
unity/OpenRasta.DI.Unity/dependencies.targets (added)
-
unity/unity.sln (moved) (moved from trunk/src/unity/OpenRasta.DI.Unity.sln)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/aspnet/OpenRasta.Codecs.WebForms.Tests.Unit/OpenRasta.Codecs.WebForms.Tests.Unit.csproj
r272 r427 36 36 <HintPath>..\..\..\lib\nunit-2.5\nunit.framework.dll</HintPath> 37 37 </Reference> 38 <Reference Include="OpenRasta, Version=2.0.0.0, Culture=neutral, PublicKeyToken=e04bf464d7caae73, processorArchitecture=MSIL">39 <SpecificVersion>False</SpecificVersion>40 <HintPath>..\..\..\bin\Release\net-35\OpenRasta.dll</HintPath>41 </Reference>42 38 <Reference Include="OpenRasta.Testing, Version=2.0.0.0, Culture=neutral, processorArchitecture=MSIL"> 43 39 <SpecificVersion>False</SpecificVersion> 44 <HintPath>..\..\..\bin\ Release\net-35\OpenRasta.Testing.dll</HintPath>40 <HintPath>..\..\..\bin\$(Configuration)\net-35\OpenRasta.Testing.dll</HintPath> 45 41 </Reference> 46 42 <Reference Include="System" /> 47 <Reference Include="System.Core">48 <RequiredTargetFramework>3.5</RequiredTargetFramework>49 </Reference>50 43 <Reference Include="System.Web" /> 51 <Reference Include="System.Xml.Linq">52 <RequiredTargetFramework>3.5</RequiredTargetFramework>53 </Reference>54 <Reference Include="System.Data.DataSetExtensions">55 <RequiredTargetFramework>3.5</RequiredTargetFramework>56 </Reference>57 44 <Reference Include="System.Data" /> 58 45 <Reference Include="System.Xml" /> … … 69 56 </ProjectReference> 70 57 </ItemGroup> 58 <ItemGroup> 59 <None Include="dependencies.targets" /> 60 </ItemGroup> 61 <Import Project="dependencies.targets" /> 71 62 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 72 63 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
trunk/src/aspnet/OpenRasta.Codecs.WebForms/dependencies.targets
r230 r427 4 4 <PropertyGroup> 5 5 <RootPath Condition="'$(RootPath)' == ''">$(MSBuildProjectDirectory)\..\..\..</RootPath> 6 7 8 6 <OpenRasta>2.0</OpenRasta> 9 7 </PropertyGroup> -
trunk/src/aspnet/OpenRasta.Hosting.AspNet/AspNetRequest.cs
r356 r427 14 14 using System.Web; 15 15 using OpenRasta.Web; 16 using OpenRasta.Web.Headers; 16 17 17 18 namespace OpenRasta.Hosting.AspNet … … 25 26 NativeContext = context; 26 27 Uri = NativeContext.Request.Url; 27 Headers = new HttpHeaderDictionary(NativeContext.Request.Headers); 28 Headers = new HttpHeaderDictionary(); 29 CopyNativeHeaders(); 28 30 29 31 // TODO: Finish off the new input stream that goes to the … … 34 36 Entity.ContentType = new MediaType(NativeContext.Request.ContentType); 35 37 CodecParameters = new List<string>(); 38 } 39 40 void CopyNativeHeaders() 41 { 42 foreach(var nativeHeader in NativeContext.Request.Headers.AllKeys) 43 { 44 Headers[nativeHeader] = NativeContext.Request.Headers[nativeHeader]; 45 } 36 46 } 37 47 -
trunk/src/aspnet/OpenRasta.Hosting.AspNet/AspNetResponse.cs
r356 r427 10 10 11 11 using System; 12 using System.Collections.Generic; 12 13 using System.Web; 13 14 using OpenRasta.DI; 14 15 using OpenRasta.Diagnostics; 15 16 using OpenRasta.Web; 17 using OpenRasta.Web.Headers; 18 using OpenRasta.Web.Headers.Entity; 16 19 17 20 namespace OpenRasta.Hosting.AspNet … … 24 27 Headers = new HttpHeaderDictionary(); 25 28 Entity = new HttpEntity(Headers, NativeContext.Response.OutputStream); 26 }27 28 public long? ContentLength29 {30 get { return Headers.ContentLength; }31 set { Headers.ContentLength = value; }32 }33 34 public string ContentType35 {36 get { return Headers.ContentType.ToString(); }37 set { Headers.ContentType = new MediaType(value); }38 29 } 39 30 … … 59 50 try 60 51 { 61 Log.WriteDebug("Writing http header {0}:{1}", header. Key, header.Value);62 NativeContext.Response.AppendHeader(header. Key, header.Value);52 Log.WriteDebug("Writing http header {0}:{1}", header.FieldName, header.FieldValue); 53 NativeContext.Response.AppendHeader(header.FieldName, header.FieldValue); 63 54 } 64 55 catch (Exception ex) -
trunk/src/aspnet/OpenRasta.Hosting.AspNet/HttpInputStream.cs
r356 r427 14 14 namespace OpenRasta.Hosting.AspNet 15 15 { 16 /* 16 17 public class HttpInputStream : Stream 17 18 { … … 69 70 } 70 71 } 72 * */ 71 73 } 72 74 -
trunk/src/core/OpenRasta/OpenRasta.csproj.resharper
r370 r427 1 1 <Configuration> 2 2 <NamespaceFolders> 3 <SkipFolder>C3ED9CCE-A140-4D0F-AE00-FBBF4CD27647/d:Codecs/d:application/d:json</SkipFolder> 3 4 <SkipFolder>C3ED9CCE-A140-4D0F-AE00-FBBF4CD27647/d:Codecs/d:application/d:octet-stream</SkipFolder> 4 5 <SkipFolder>C3ED9CCE-A140-4D0F-AE00-FBBF4CD27647/d:Codecs/d:application/d:x-www-form-urlencoded</SkipFolder> … … 10 11 <SkipFolder>C3ED9CCE-A140-4D0F-AE00-FBBF4CD27647/d:Codecs/d:text/d:plain</SkipFolder> 11 12 <SkipFolder>C3ED9CCE-A140-4D0F-AE00-FBBF4CD27647/d:Codecs/d:text</SkipFolder> 13 <SkipFolder>C3ED9CCE-A140-4D0F-AE00-FBBF4CD27647/d:Web/d:Markup/d:Controls</SkipFolder> 12 14 </NamespaceFolders> 13 15 </Configuration> -
trunk/src/core/core.4.5.resharper
r363 r427 23 23 args 24 24 localhost 25 Accessor</UserWords> 25 Accessor 26 Json 27 Queryable 28 Linq 29 tokenizers 30 Tokenizer</UserWords> 26 31 </CustomDictionary> 27 32 <CustomDictionary> -
trunk/src/ninject/OpenRasta.DI.Ninject.Tests.Unit/OpenRasta.DI.Ninject.Tests.Unit.csproj
r353 r427 46 46 <HintPath>..\..\..\lib\nunit-2.5\nunit.framework.dll</HintPath> 47 47 </Reference> 48 <Reference Include="OpenRasta, Version=2.0.1.0, Culture=neutral, PublicKeyToken=e04bf464d7caae73, processorArchitecture=MSIL">49 <SpecificVersion>False</SpecificVersion>50 <HintPath>..\..\..\bin\Release\net-35\OpenRasta.dll</HintPath>51 </Reference>52 48 <Reference Include="OpenRasta.Testing, Version=2.0.1.0, Culture=neutral, processorArchitecture=MSIL"> 53 49 <SpecificVersion>False</SpecificVersion> 54 <HintPath>..\..\..\bin\ Release\net-35\OpenRasta.Testing.dll</HintPath>50 <HintPath>..\..\..\bin\$(Configuration)\net-35\OpenRasta.Testing.dll</HintPath> 55 51 </Reference> 56 <Reference Include="OpenRasta.Tests.Unit, Version=2.0. 1.0, Culture=neutral, processorArchitecture=MSIL">52 <Reference Include="OpenRasta.Tests.Unit, Version=2.0.3.0, Culture=neutral, processorArchitecture=MSIL"> 57 53 <SpecificVersion>False</SpecificVersion> 58 <HintPath>..\..\..\bin\ Release\net-35\OpenRasta.Tests.Unit.dll</HintPath>54 <HintPath>..\..\..\bin\$(Configuration)\net-35\OpenRasta.Tests.Unit.dll</HintPath> 59 55 </Reference> 60 56 <Reference Include="System" /> 61 <Reference Include="System.Core">62 <RequiredTargetFramework>3.5</RequiredTargetFramework>63 </Reference>64 <Reference Include="System.Xml.Linq">65 <RequiredTargetFramework>3.5</RequiredTargetFramework>66 </Reference>67 <Reference Include="System.Data.DataSetExtensions">68 <RequiredTargetFramework>3.5</RequiredTargetFramework>69 </Reference>70 57 <Reference Include="System.Data" /> 71 58 <Reference Include="System.Xml" /> … … 82 69 </ProjectReference> 83 70 </ItemGroup> 71 <ItemGroup> 72 <None Include="dependencies.targets" /> 73 </ItemGroup> 84 74 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 75 <Import Project="dependencies.targets" /> 85 76 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 86 77 Other similar extension points exist, see Microsoft.Common.targets. -
trunk/src/ninject/OpenRasta.DI.Ninject/OpenRasta.DI.Ninject.csproj
r339 r427 18 18 <DebugType>full</DebugType> 19 19 <Optimize>false</Optimize> 20 <OutputPath>..\..\..\bin\vs\bin\Debug\OpenRasta.DI.Ninject\</OutputPath>21 20 <DefineConstants>DEBUG;TRACE</DefineConstants> 22 21 <ErrorReport>prompt</ErrorReport> 23 22 <WarningLevel>4</WarningLevel> 24 <DocumentationFile>..\..\..\bin\vs\bin\Debug\OpenRasta.DI.Ninject\OpenRasta.DI.Ninject.xml</DocumentationFile>25 23 <NoWarn>1591;1591</NoWarn> 26 24 </PropertyGroup> … … 28 26 <DebugType>pdbonly</DebugType> 29 27 <Optimize>true</Optimize> 30 <OutputPath>..\..\..\bin\vs\bin\Release\OpenRasta.DI.Ninject\</OutputPath>31 28 <DefineConstants>TRACE</DefineConstants> 32 29 <ErrorReport>prompt</ErrorReport> 33 30 <WarningLevel>4</WarningLevel> 34 <DocumentationFile>..\..\..\bin\vs\bin\Release\OpenRasta.DI.Ninject\OpenRasta.DI.Ninject.xml</DocumentationFile>35 31 </PropertyGroup> 36 32 <ItemGroup> … … 39 35 <HintPath>..\..\..\lib\ninject-2.0\Ninject.dll</HintPath> 40 36 </Reference> 41 <Reference Include="OpenRasta, Version=2.0.1.0, Culture=neutral, PublicKeyToken=e04bf464d7caae73, processorArchitecture=MSIL">42 <SpecificVersion>False</SpecificVersion>43 <HintPath>..\..\..\bin\Release\net-35\OpenRasta.dll</HintPath>44 </Reference>45 37 <Reference Include="System" /> 46 <Reference Include="System.Core">47 <RequiredTargetFramework>3.5</RequiredTargetFramework>48 </Reference>49 <Reference Include="System.Xml.Linq">50 <RequiredTargetFramework>3.5</RequiredTargetFramework>51 </Reference>52 <Reference Include="System.Data.DataSetExtensions">53 <RequiredTargetFramework>3.5</RequiredTargetFramework>54 </Reference>55 38 <Reference Include="System.Data" /> 56 39 <Reference Include="System.Xml" /> … … 70 53 <Compile Include="WebBinding.cs" /> 71 54 </ItemGroup> 55 <ItemGroup> 56 <None Include="dependencies.targets" /> 57 </ItemGroup> 58 <Import Project="dependencies.targets" /> 72 59 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 73 60 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
trunk/src/openbastard/OpenBastard.TestRunner/Environments/HttpWebRequestEnvironment.cs
r356 r427 58 58 try 59 59 { 60 webRequest.Headers [header.Key] = header.Value;60 webRequest.Headers.Add(header.FieldName, header.FieldValue); 61 61 } 62 62 catch (ArgumentException) -
trunk/src/openbastard/OpenBastard.TestRunner/Environments/WebRequestResponse.cs
r363 r427 5 5 using OpenRasta.Codecs; 6 6 using OpenRasta.Web; 7 using OpenRasta.Web.Headers; 7 8 8 9 namespace OpenBastard.Environments -
trunk/src/openbastard/openbastard.sln
r356 r427 11 11 EndProject 12 12 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenBastard.Hosting.Iis7.WorkerProcess-64", "OpenBastard.Hosting.Iis7.WorkerProcess-64\OpenBastard.Hosting.Iis7.WorkerProcess-64.csproj", "{F7152A67-F16E-4EE4-A39A-0450767BC5C9}" 13 EndProject 14 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{6FE34CE4-E647-4C64-AFE7-F5DF5A00B8E4}" 15 ProjectSection(SolutionItems) = preProject 16 ..\..\build\openbastard.proj = ..\..\build\openbastard.proj 17 EndProjectSection 13 18 EndProject 14 19 Global -
trunk/src/sharpview/OpenRasta.Codecs.SharpView.Tests.Unit/OpenRasta.Codecs.SharpView.Tests.Unit.csproj
r243 r427 36 36 <HintPath>..\..\..\lib\nunit-2.5\nunit.framework.dll</HintPath> 37 37 </Reference> 38 <Reference Include="OpenRasta, Version=2.0.1.0, Culture=neutral, processorArchitecture=MSIL">39 <SpecificVersion>False</SpecificVersion>40 <HintPath>..\..\..\bin\Release\net-35\OpenRasta.dll</HintPath>41 </Reference>42 38 <Reference Include="OpenRasta.Testing, Version=2.0.1.0, Culture=neutral, processorArchitecture=MSIL"> 43 39 <SpecificVersion>False</SpecificVersion> … … 45 41 </Reference> 46 42 <Reference Include="System" /> 47 <Reference Include="System.Core">48 <RequiredTargetFramework>3.5</RequiredTargetFramework>49 </Reference>50 <Reference Include="System.Xml.Linq">51 <RequiredTargetFramework>3.5</RequiredTargetFramework>52 </Reference>53 <Reference Include="System.Data.DataSetExtensions">54 <RequiredTargetFramework>3.5</RequiredTargetFramework>55 </Reference>56 43 <Reference Include="System.Data" /> 57 44 <Reference Include="System.Xml" /> … … 67 54 </ItemGroup> 68 55 <ItemGroup> 56 <None Include="dependencies.targets" /> 57 </ItemGroup> 58 <ItemGroup> 69 59 <Folder Include="Properties\" /> 70 60 </ItemGroup> 71 61 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 62 <Import Project="dependencies.targets" /> 72 63 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 73 64 Other similar extension points exist, see Microsoft.Common.targets. -
trunk/src/sharpview/OpenRasta.Codecs.SharpView.Tests.Unit/SharpView_Specification.cs
r420 r427 414 414 Expression<Func<object>> expr = () => customer.Orders.Current().Lines; 415 415 var property = new PropertyPathForIteratorVisitor().BuildPropertyPath(expr); 416 property. TypePrefix.ShouldBe("Order");417 property. TypeSuffix.ShouldBe("Lines");416 property.RootType.ShouldBe("Order"); 417 property.Path.ShouldBe("Lines"); 418 418 } 419 419 … … 424 424 Expression<Func<object>> expr = () => customer.MainOrder.Lines; 425 425 var property = new PropertyPathForIteratorVisitor().BuildPropertyPath(expr); 426 property. TypePrefix.ShouldBe("Customer");427 property. TypeSuffix.ShouldBe("MainOrder.Lines");426 property.RootType.ShouldBe("Customer"); 427 property.Path.ShouldBe("MainOrder.Lines"); 428 428 } 429 429 [Test] … … 433 433 Expression<Func<object>> expr = () => customer.Orders[0].Lines; 434 434 var property = new PropertyPathForIteratorVisitor().BuildPropertyPath(expr); 435 property. TypePrefix.ShouldBe("Customer");436 property. TypeSuffix.ShouldBe("Orders:0.Lines");435 property.RootType.ShouldBe("Customer"); 436 property.Path.ShouldBe("Orders:0.Lines"); 437 437 } 438 438 } -
trunk/src/sharpview/OpenRasta.Codecs.SharpView/OpenRasta.Codecs.SharpView.csproj
r300 r427 21 21 <ErrorReport>prompt</ErrorReport> 22 22 <WarningLevel>4</WarningLevel> 23 <DocumentationFile>..\..\bin\OpenRasta.Codecs.SharpView\OpenRasta.Codecs.SharpView.xml</DocumentationFile>24 23 </PropertyGroup> 25 24 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> -
trunk/src/sharpview/OpenRasta.Codecs.SharpView/SourcedElementExtensions.cs
r300 r427 12 12 using System.Collections; 13 13 using System.Collections.Generic; 14 using OpenRasta. Reflection;14 using OpenRasta.Binding.Path; 15 15 using OpenRasta.Web.Markup; 16 16 … … 51 51 public static IEnumerable<TResult> SelectHtml<TSource, TResult>(this IEnumerable<TSource> source, 52 52 object rootInstance, 53 PropertyPath path,53 MemberPath path, 54 54 Func<TSource, TResult> selector) 55 55 { … … 61 61 try 62 62 { 63 PropertyPath pathToAdd;63 MemberPath pathToAdd; 64 64 if (rootInstance != null) 65 65 { 66 PropertyPath rootPath = ObjectPaths.Get(rootInstance);67 pathToAdd = new PropertyPath66 MemberPath rootPath = MemberPathsContext.Get(rootInstance); 67 pathToAdd = new MemberPath 68 68 { 69 TypePrefix = rootPath.TypePrefix,70 TypeSuffix = rootPath.TypeSuffix + "." + path.TypeSuffix+ ":" + index69 RootType = rootPath.RootType, 70 Path = rootPath.Path + "." + path.Path + ":" + index 71 71 }; 72 72 } 73 73 else 74 74 { 75 pathToAdd = new PropertyPath75 pathToAdd = new MemberPath 76 76 { 77 TypePrefix = path.TypePrefix,78 TypeSuffix = path.TypeSuffix+ ":" + index77 RootType = path.RootType, 78 Path = path.Path + ":" + index 79 79 }; 80 80 } 81 ObjectPaths.Add(item, pathToAdd);81 MemberPathsContext.Add(item, pathToAdd); 82 82 yield return selector(item); 83 83 } 84 84 finally 85 85 { 86 ObjectPaths.Remove(item);86 MemberPathsContext.Remove(item); 87 87 index++; 88 88 } -
trunk/src/sharpview/OpenRasta.Codecs.SharpView/Visitors/ChildScopeForEachFinder.cs
r300 r427 1 1 using System.Linq.Expressions; 2 using OpenRasta.Reflection; 2 using OpenRasta.Binding.Path.Visitors; 3 using OpenRasta.Linq.Visitors; 3 4 4 5 namespace OpenRasta.Codecs.SharpView.Visitors -
trunk/src/sharpview/OpenRasta.Codecs.SharpView/Visitors/ChildScopeRewriterVisitor.cs
r300 r427 2 2 using System.Linq.Expressions; 3 3 using System.Reflection; 4 using OpenRasta.Reflection; 4 using OpenRasta.Binding.Path.Visitors; 5 using OpenRasta.Linq.Visitors; 5 6 6 7 namespace OpenRasta.Codecs.SharpView.Visitors -
trunk/src/sharpview/OpenRasta.Codecs.SharpView/Visitors/CurrentItemRewriterVisitor.cs
r300 r427 11 11 using System.Linq.Expressions; 12 12 using IQ; 13 using OpenRasta.Reflection; 13 using OpenRasta.Binding.Path.Visitors; 14 using OpenRasta.Linq.Visitors; 14 15 15 16 namespace OpenRasta.Codecs.SharpView.Visitors -
trunk/src/sharpview/OpenRasta.Codecs.SharpView/Visitors/ForEachRewriter.cs
r300 r427 4 4 using System.Linq.Expressions; 5 5 using System.Reflection; 6 using OpenRasta. Reflection;6 using OpenRasta.Binding.Path; 7 7 using OpenRasta.Web.Markup; 8 8 … … 54 54 nullPropagatingIterator, 55 55 Expression.Constant(null, typeof(object)), 56 Expression.Constant(null, typeof( PropertyPath)),56 Expression.Constant(null, typeof(MemberPath)), 57 57 projection); 58 58 } -
trunk/src/sharpview/OpenRasta.Codecs.SharpView/Visitors/IfRewriterVisitor.cs
r300 r427 12 12 using System.Linq; 13 13 using System.Linq.Expressions; 14 using OpenRasta. Reflection;14 using OpenRasta.Binding.Path.Visitors; 15 15 using OpenRasta.TypeSystem.ReflectionBased; 16 using OpenRasta.Linq.Visitors; 16 17 17 18 namespace OpenRasta.Codecs.SharpView.Visitors -
trunk/src/sharpview/OpenRasta.Codecs.SharpView/Visitors/MemberAccessNullPropagateVisitor.cs
r300 r427 11 11 using System; 12 12 using System.Linq.Expressions; 13 using OpenRasta. Reflection;13 using OpenRasta.Binding.Path.Visitors; 14 14 using OpenRasta.TypeSystem.ReflectionBased; 15 using OpenRasta.Linq.Visitors; 15 16 16 17 namespace OpenRasta.Codecs.SharpView.Visitors -
trunk/src/sharpview/OpenRasta.Codecs.SharpView/Visitors/PropertyPathForIteratorVisitor.cs
r300 r427 1 1 using System.Linq.Expressions; 2 2 using System.Text; 3 using OpenRasta. Reflection;3 using OpenRasta.Binding.Path.Visitors; 4 4 5 5 namespace OpenRasta.Codecs.SharpView.Visitors 6 6 { 7 public class PropertyPathForIteratorVisitor : PropertyPathVisitor7 public class PropertyPathForIteratorVisitor : MemberPathVisitor 8 8 { 9 9 protected override Expression VisitMethodCall(MethodCallExpression m) -
trunk/src/sharpview/OpenRasta.Codecs.SharpView/Visitors/ScopedForEachFinder.cs
r300 r427 1 1 using System; 2 2 using System.Linq.Expressions; 3 using OpenRasta. Reflection;3 using OpenRasta.Binding.Path.Visitors; 4 4 using OpenRasta.Web.Markup; 5 5 using OpenRasta.Web.Markup.Elements; 6 using OpenRasta.Linq.Visitors; 6 7 7 8 namespace OpenRasta.Codecs.SharpView.Visitors -
trunk/src/sharpview/OpenRasta.Codecs.SharpView/Visitors/SelectHtmlPropertyPathRewriter.cs
r300 r427 1 1 using System.Linq.Expressions; 2 using OpenRasta.Reflection; 2 using OpenRasta.Binding.Path; 3 using OpenRasta.Binding.Path.Visitors; 4 using OpenRasta.Linq.Visitors; 3 5 4 6 namespace OpenRasta.Codecs.SharpView.Visitors … … 18 20 Expression nullPropagatingIterator = new MemberAccessNullPropagateVisitor().Rewrite(iterator); 19 21 20 PropertyPathiteratorPath = CreatePropertyPath(iterator);22 var iteratorPath = CreatePropertyPath(iterator); 21 23 22 24 Expression iteratorRoot = GetIteratorRoot(iterator); … … 35 37 } 36 38 37 static PropertyPath CreatePropertyPath(Expression expression)39 static MemberPath CreatePropertyPath(Expression expression) 38 40 { 39 41 return new PropertyPathForIteratorVisitor().BuildPropertyPath(expression); -
trunk/src/unity/OpenRasta.DI.Unity.Sample/OpenRasta.DI.Unity.Sample.csproj
r387 r427 42 42 <Reference Include="OpenRasta, Version=2.0.3.0, Culture=neutral, PublicKeyToken=e04bf464d7caae73, processorArchitecture=MSIL"> 43 43 <SpecificVersion>False</SpecificVersion> 44 <HintPath>..\..\..\bin\ Release\net-35\OpenRasta.dll</HintPath>44 <HintPath>..\..\..\bin\$(Configuration)\net-35\OpenRasta.dll</HintPath> 45 45 </Reference> 46 46 <Reference Include="OpenRasta.Hosting.AspNet, Version=2.0.3.0, Culture=neutral, processorArchitecture=MSIL"> 47 47 <SpecificVersion>False</SpecificVersion> 48 <HintPath>..\..\..\bin\ Release\net-35\OpenRasta.Hosting.AspNet.dll</HintPath>48 <HintPath>..\..\..\bin\$(Configuration)\net-35\OpenRasta.Hosting.AspNet.dll</HintPath> 49 49 </Reference> 50 50 <Reference Include="System" /> -
trunk/src/unity/OpenRasta.DI.Unity.Tests.Unit/OpenRasta.DI.Unity.Tests.Unit.csproj
r387 r427 18 18 <DebugType>full</DebugType> 19 19 <Optimize>false</Optimize> 20 <OutputPath>..\..\..\bin\vs\bin\Debug\OpenRasta.DI.Unity.Tests.Unit\</OutputPath>21 20 <DefineConstants>DEBUG;TRACE</DefineConstants> 22 21 <ErrorReport>prompt</ErrorReport> 23 22 <WarningLevel>4</WarningLevel> 24 23 <TreatWarningsAsErrors>true</TreatWarningsAsErrors> 25 <DocumentationFile>26 </DocumentationFile>27 24 </PropertyGroup> 28 25 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> 29 26 <DebugType>pdbonly</DebugType> 30 27 <Optimize>true</Optimize> 31 <OutputPath>bin\Release\</OutputPath>32 28 <DefineConstants>TRACE</DefineConstants> 33 29 <ErrorReport>prompt</ErrorReport> … … 43 39 <HintPath>..\..\..\lib\nunit-2.5\nunit.framework.dll</HintPath> 44 40 </Reference> 45 <Reference Include="OpenRasta, Version=2.0.3.0, Culture=neutral, PublicKeyToken=e04bf464d7caae73, processorArchitecture=MSIL">46 <SpecificVersion>False</SpecificVersion>47 <HintPath>..\..\..\bin\Release\net-35\OpenRasta.dll</HintPath>48 </Reference>49 41 <Reference Include="OpenRasta.Testing, Version=2.0.3.0, Culture=neutral, processorArchitecture=MSIL"> 50 42 <SpecificVersion>False</SpecificVersion> 51 <HintPath>..\..\..\bin\ Release\net-35\OpenRasta.Testing.dll</HintPath>43 <HintPath>..\..\..\bin\$(Configuration)\net-35\OpenRasta.Testing.dll</HintPath> 52 44 </Reference> 53 45 <Reference Include="OpenRasta.Tests.Unit, Version=2.0.3.0, Culture=neutral, processorArchitecture=MSIL"> 54 46 <SpecificVersion>False</SpecificVersion> 55 <HintPath>..\..\..\bin\ Release\net-35\OpenRasta.Tests.Unit.dll</HintPath>47 <HintPath>..\..\..\bin\$(Configuration)\net-35\OpenRasta.Tests.Unit.dll</HintPath> 56 48 </Reference> 57 49 <Reference Include="System" /> 58 <Reference Include="System.Core">59 <RequiredTargetFramework>3.5</RequiredTargetFramework>60 </Reference>61 <Reference Include="System.Xml.Linq">62 <RequiredTargetFramework>3.5</RequiredTargetFramework>63 </Reference>64 <Reference Include="System.Data.DataSetExtensions">65 <RequiredTargetFramework>3.5</RequiredTargetFramework>66 </Reference>67 50 <Reference Include="System.Data" /> 68 51 <Reference Include="System.Xml" /> … … 78 61 </ProjectReference> 79 62 </ItemGroup> 63 <ItemGroup> 64 <None Include="dependencies.targets" /> 65 </ItemGroup> 66 <Import Project="dependencies.targets" /> 80 67 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 81 68 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
trunk/src/unity/OpenRasta.DI.Unity/Extensions/CycleDetector.cs
r387 r427 9 9 /// Adds early detection of circular references to prevent <see cref="StackOverflowException"/>s. 10 10 /// </summary> 11 class CycleDetector : UnityContainerExtension11 internal class CycleDetector : UnityContainerExtension 12 12 { 13 13 protected override void Initialize() … … 17 17 } 18 18 } 19 -
trunk/src/unity/OpenRasta.DI.Unity/Extensions/InjectionPolicies.cs
r387 r427 10 10 /// individual policies for details. 11 11 /// </summary> 12 class InjectionPolicies : UnityContainerExtension12 internal class InjectionPolicies : UnityContainerExtension 13 13 { 14 14 protected override void Initialize() … … 30 30 void ApplyPolicies(Type type) 31 31 { 32 if (type == null)32 if (type == null) 33 33 return; 34 34 -
trunk/src/unity/OpenRasta.DI.Unity/Extensions/Policies/ConstructorSelectorPolicy.cs
r389 r427 15 15 /// provided. 16 16 /// </remarks> 17 class ConstructorSelectorPolicy : IConstructorSelectorPolicy17 internal class ConstructorSelectorPolicy : IConstructorSelectorPolicy 18 18 { 19 /// <summary> 20 /// Exposes part of Unity's default policy which is marked protected. 21 /// </summary> 22 class ParameterResolver : DefaultUnityConstructorSelectorPolicy 23 { 24 public IDependencyResolverPolicy GetResolver(ParameterInfo parameterInfo) 25 { 26 return CreateResolver(parameterInfo); 27 } 28 } 29 30 readonly ParameterResolver parameterResolver = new ParameterResolver(); 19 readonly ParameterResolver _parameterResolver = new ParameterResolver(); 31 20 32 21 public SelectedConstructor SelectConstructor(IBuilderContext context) … … 47 36 { 48 37 parameters.Add(new TypeToBeResolved( 49 parameter.ParameterType,50 parameterResolver.GetResolver(parameter)));38 parameter.ParameterType, 39 _parameterResolver.GetResolver(parameter))); 51 40 } 52 41 53 42 return new SpecifiedConstructorSelectorPolicy(constructor, parameters.ToArray()) 54 43 .SelectConstructor(context); 55 }56 57 static ConstructorInfo SelectConstructor(Type target, TypeTracker typeTracker)58 {59 ConstructorInfo best = null;60 var bestScore = -1;61 62 foreach (var constructor in target.GetConstructors())63 {64 var score = Rate(constructor, typeTracker);65 66 if(score > bestScore)67 {68 best = constructor;69 bestScore = score;70 }71 }72 73 return best;74 44 } 75 45 … … 83 53 return int.MaxValue; 84 54 85 varscore = 0;55 int score = 0; 86 56 87 57 foreach (var parameter in constructor.GetParameters()) 88 58 { 89 if (parameter.IsOut || parameter.IsRetval)59 if (parameter.IsOut || parameter.IsRetval) 90 60 return -1; 91 61 … … 103 73 return score; 104 74 } 75 76 static ConstructorInfo SelectConstructor(Type target, TypeTracker typeTracker) 77 { 78 ConstructorInfo best = null; 79 int bestScore = -1; 80 81 foreach (var constructor in target.GetConstructors()) 82 { 83 int score = Rate(constructor, typeTracker); 84 85 if (score > bestScore) 86 { 87 best = constructor; 88 bestScore = score; 89 } 90 } 91 92 return best; 93 } 94 95 /// <summary> 96 /// Exposes part of Unity's default policy which is marked protected. 97 /// </summary> 98 class ParameterResolver : DefaultUnityConstructorSelectorPolicy 99 { 100 public IDependencyResolverPolicy GetResolver(ParameterInfo parameterInfo) 101 { 102 return CreateResolver(parameterInfo); 103 } 104 } 105 105 } 106 106 } -
trunk/src/unity/OpenRasta.DI.Unity/Extensions/Policies/CycleDetectionPolicy.cs
r387 r427 6 6 /// If set, indicates that cycle detection has begun for the current build operation. 7 7 /// </summary> 8 class CycleDetectionPolicy : IBuilderPolicy8 internal class CycleDetectionPolicy : IBuilderPolicy 9 9 { 10 10 } -
trunk/src/unity/OpenRasta.DI.Unity/Extensions/Policies/PropertySelectorPolicy.cs
r389 r427 14 14 /// Normally Unity only injects values for properties explicitly marked with an attribute. 15 15 /// </remarks> 16 class PropertySelectorPolicy : IPropertySelectorPolicy16 internal class PropertySelectorPolicy : IPropertySelectorPolicy 17 17 { 18 18 public IEnumerable<SelectedProperty> SelectProperties(IBuilderContext context) … … 29 29 { 30 30 // Ignore indexed properties 31 if (property.GetIndexParameters().Length > 0)31 if (property.GetIndexParameters().Length > 0) 32 32 continue; 33 33 34 34 // Ignore read only properties 35 if (!property.CanWrite)35 if (!property.CanWrite) 36 36 continue; 37 37 38 38 // Ignore properties we can't fill anyway 39 if (!typeTracker.HasDependency(property.PropertyType))39 if (!typeTracker.HasDependency(property.PropertyType)) 40 40 continue; 41 41 … … 46 46 continue; 47 47 48 policy.AddPropertyAndValue(property, new TypeToBeResolved( 49 property.PropertyType, 50 GetResolver(property))); 48 policy.AddPropertyAndValue(property, 49 new TypeToBeResolved( 50 property.PropertyType, 51 GetResolver(property))); 51 52 } 52 53 … … 57 58 { 58 59 var resolverAttributes = property 59 .GetCustomAttributes(typeof (DependencyResolutionAttribute), false)60 .GetCustomAttributes(typeof(DependencyResolutionAttribute), false) 60 61 .OfType<DependencyResolutionAttribute>() 61 62 .ToList(); … … 68 69 return resolverAttributes[0].CreateResolver(property.PropertyType); 69 70 } 70 71 71 72 // If no custom logic was provided, this resolver will call back in to Unity. Normally 72 73 // Unity would only inject into properties if it had an attribute. -
trunk/src/unity/OpenRasta.DI.Unity/Extensions/Policies/TypeToBeResolved.cs
r389 r427 8 8 /// Used by the injection policies to indicate how further dependencies will be resolved. 9 9 /// </summary> 10 class TypeToBeResolved : TypedInjectionValue10 internal class TypeToBeResolved : TypedInjectionValue 11 11 { 12 readonly IDependencyResolverPolicy resolver;12 readonly IDependencyResolverPolicy _resolver; 13 13 14 14 public TypeToBeResolved(Type parameterType, IDependencyResolverPolicy resolver) 15 15 : base(parameterType) 16 16 { 17 this. resolver = resolver;17 this._resolver = resolver; 18 18 } 19 19 20 20 public override IDependencyResolverPolicy GetResolverPolicy(Type typeToBuild) 21 21 { 22 return resolver;22 return _resolver; 23 23 } 24 24 } -
trunk/src/unity/OpenRasta.DI.Unity/Extensions/Policies/TypeTrackerPolicy.cs
r387 r427 8 8 public class TypeTrackerPolicy : IBuilderPolicy 9 9 { 10 public TypeTracker TypeTracker { get; private set; }11 12 10 public TypeTrackerPolicy(TypeTracker typeTracker) 13 11 { 14 12 TypeTracker = typeTracker; 15 13 } 14 15 public TypeTracker TypeTracker { get; private set; } 16 16 } 17 17 } -
trunk/src/unity/OpenRasta.DI.Unity/Extensions/Strategies/CycleDetectionStrategy.cs
r387 r427 8 8 /// Detects cycles in the current build operation by watching for repeated build keys. 9 9 /// </summary> 10 class CycleDetectionStrategy : BuilderStrategy10 internal class CycleDetectionStrategy : BuilderStrategy 11 11 { 12 readonly HashSet<object> previousKeys = new HashSet<object>();12 readonly HashSet<object> _previousKeys = new HashSet<object>(); 13 13 14 bool cycleDetected; 14 bool _cycleDetected; 15 16 public override void PostBuildUp(IBuilderContext context) 17 { 18 if (_cycleDetected) 19 throw new DependencyResolutionException("Circular dependency detected."); 20 } 15 21 16 22 public override void PreBuildUp(IBuilderContext context) … … 23 29 if (policy == null) 24 30 { 25 previousKeys.Clear();31 _previousKeys.Clear(); 26 32 context.Policies.SetDefault(new CycleDetectionPolicy()); 27 33 } 28 34 29 35 // If we are seeing the same build key twice it means we've followed a cycle 30 if ( previousKeys.Contains(context.OriginalBuildKey))36 if (_previousKeys.Contains(context.OriginalBuildKey)) 31 37 { 32 cycleDetected = true;38 _cycleDetected = true; 33 39 context.BuildComplete = true; 34 40 } 35 41 36 previousKeys.Add(context.BuildKey); 37 } 38 39 public override void PostBuildUp(IBuilderContext context) 40 { 41 if (cycleDetected) 42 throw new DependencyResolutionException("Circular dependency detected."); 42 _previousKeys.Add(context.BuildKey); 43 43 } 44 44 } -
trunk/src/unity/OpenRasta.DI.Unity/Extensions/Strategies/TypeRegistrationRequiredStrategy.cs
r387 r427 7 7 /// Makes sure that any types being built are actually registered in the container. 8 8 /// </summary> 9 class TypeRegistrationRequiredStrategy : BuilderStrategy9 internal class TypeRegistrationRequiredStrategy : BuilderStrategy 10 10 { 11 11 public override void PreBuildUp(IBuilderContext context) … … 21 21 var typeTracker = context.Policies.Get<TypeTrackerPolicy>(context.BuildKey).TypeTracker; 22 22 23 if (!typeTracker.HasDependency(requestedType))23 if (!typeTracker.HasDependency(requestedType)) 24 24 throw new DependencyResolutionException("Couldn't find type " + requestedType.FullName); 25 25 } … … 27 27 bool WeAreNotTheLast(IBuilderContext context) 28 28 { 29 varfoundUs = false;29 bool foundUs = false; 30 30 31 31 foreach (var strategy in context.Strategies) 32 32 { 33 if (!(strategy is TypeRegistrationRequiredStrategy))33 if (!(strategy is TypeRegistrationRequiredStrategy)) 34 34 continue; 35 35 … … 37 37 return true; 38 38 39 if (strategy == this)39 if (strategy == this) 40 40 foundUs = true; 41 41 } -
trunk/src/unity/OpenRasta.DI.Unity/Extensions/TypeRegistrationRequired.cs
r387 r427 8 8 /// Changes the default Unity behaviour so that types must be registered to be created. 9 9 /// </summary> 10 class TypeRegistrationRequired : UnityContainerExtension10 internal class TypeRegistrationRequired : UnityContainerExtension 11 11 { 12 12 protected override void Initialize() -
trunk/src/unity/OpenRasta.DI.Unity/Extensions/TypeTracker.cs
r387 r427 16 16 public class TypeTracker : UnityContainerExtension 17 17 { 18 readonly Dictionary<Type, HashSet<Type>> mappings = new Dictionary<Type, HashSet<Type>>(); 18 readonly Dictionary<Type, HashSet<Type>> _mappings = new Dictionary<Type, HashSet<Type>>(); 19 20 /// <summary> 21 /// Access the <see cref="TypeTracker"/> installed in our parent container. This is necessary because we 22 /// are only notified about types registered in our container specifically, not ones added 23 /// to parent or child container. 24 /// </summary> 25 TypeTracker Parent 26 { 27 get 28 { 29 if (Container.Parent == null) 30 return null; 31 32 return Container.Parent.TypeTracker(); 33 } 34 } 35 36 /// <summary> 37 /// Find all the possible implementations of the given type. 38 /// </summary> 39 public IEnumerable<Type> GetAllConcreteTypes(Type serviceType) 40 { 41 var types = new HashSet<Type>(); 42 43 if (_mappings.ContainsKey(serviceType)) 44 types.UnionWith(_mappings[serviceType]); 45 46 if (Parent != null) 47 types.UnionWith(Parent.GetAllConcreteTypes(serviceType)); 48 49 return types; 50 } 51 52 /// <summary> 53 /// Do we know of any implementations for the given type at all? 54 /// </summary> 55 public bool HasDependency(Type serviceType) 56 { 57 if (_mappings.ContainsKey(serviceType)) 58 return true; 59 60 if (Parent == null) 61 return false; 62 63 return Parent.HasDependency(serviceType); 64 } 65 66 /// <summary> 67 /// Do we know of a specific implementation of the given type? 68 /// </summary> 69 public bool HasDependencyImplementation(Type serviceType, Type concreteType) 70 { 71 if (_mappings.ContainsKey(serviceType)) 72 { 73 foreach (var type in _mappings[serviceType]) 74 { 75 if (type == concreteType) 76 return true; 77 } 78 } 79 80 if (Parent != null) 81 return Parent.HasDependencyImplementation(serviceType, concreteType); 82 83 return false; 84 } 19 85 20 86 protected override void Initialize() … … 40 106 typeTo = typeFrom; 41 107 42 if (! mappings.ContainsKey(typeFrom))43 mappings[typeFrom] = new HashSet<Type>();108 if (!_mappings.ContainsKey(typeFrom)) 109 _mappings[typeFrom] = new HashSet<Type>(); 44 110 45 if (!mappings.ContainsKey(typeTo))46 mappings[typeTo] = new HashSet<Type>();111 if (!_mappings.ContainsKey(typeTo)) 112 _mappings[typeTo] = new HashSet<Type>(); 47 113 48 mappings[typeFrom].Add(typeTo); 49 mappings[typeTo].Add(typeTo); 50 } 51 52 /// <summary> 53 /// Access the TypeTracker installed in our parent container. This is necesary because we 54 /// are only notified about types registered in our container specifically, not ones added 55 /// to parent or child container. 56 /// </summary> 57 TypeTracker Parent 58 { 59 get 60 { 61 if (Container.Parent == null) 62 return null; 63 64 return Container.Parent.TypeTracker(); 65 } 66 } 67 68 /// <summary> 69 /// Do we know of any implementations for the given type at all? 70 /// </summary> 71 public bool HasDependency(Type serviceType) 72 { 73 if (mappings.ContainsKey(serviceType)) 74 return true; 75 76 if(Parent == null) 77 return false; 78 79 return Parent.HasDependency(serviceType); 80 } 81 82 /// <summary> 83 /// Do we know of a specific implementation of the given type? 84 /// </summary> 85 public bool HasDependencyImplementation(Type serviceType, Type concreteType) 86 { 87 if(mappings.ContainsKey(serviceType)) 88 { 89 foreach (var type in mappings[serviceType]) 90 { 91 if(type == concreteType) 92 return true; 93 } 94 } 95 96 if (Parent != null) 97 return Parent.HasDependencyImplementation(serviceType, concreteType); 98 99 return false; 100 } 101 102 /// <summary> 103 /// Find all the possible implementations of the given type. 104 /// </summary> 105 public IEnumerable<Type> GetAllConcreteTypes(Type serviceType) 106 { 107 var types = new HashSet<Type>(); 108 109 if (mappings.ContainsKey(serviceType)) 110 types.UnionWith(mappings[serviceType]); 111 112 if(Parent != null) 113 types.UnionWith(Parent.GetAllConcreteTypes(serviceType)); 114 115 return types; 114 _mappings[typeFrom].Add(typeTo); 115 _mappings[typeTo].Add(typeTo); 116 116 } 117 117 } -
trunk/src/unity/OpenRasta.DI.Unity/OpenRasta.DI.Unity.csproj
r389 r427 18 18 <DebugType>full</DebugType> 19 19 <Optimize>false</Optimize> 20 <OutputPath>..\..\..\bin\vs\bin\Debug\OpenRasta.DI.Unity\</OutputPath>21 20 <DefineConstants>DEBUG;TRACE</DefineConstants> 22 21 <ErrorReport>prompt</ErrorReport> 23 22 <WarningLevel>4</WarningLevel> 24 23 <TreatWarningsAsErrors>true</TreatWarningsAsErrors> 25 <DocumentationFile>26 </DocumentationFile>27 24 </PropertyGroup> 28 25 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> 29 26 <DebugType>pdbonly</DebugType> 30 27 <Optimize>true</Optimize> 31 <OutputPath>bin\Release\</OutputPath>32 28 <DefineConstants>TRACE</DefineConstants> 33 29 <ErrorReport>prompt</ErrorReport> … … 43 39 <HintPath>..\..\..\lib\unity-1.2\Microsoft.Practices.Unity.dll</HintPath> 44 40 </Reference> 45 <Reference Include="OpenRasta, Version=2.0.3.0, Culture=neutral, PublicKeyToken=e04bf464d7caae73, processorArchitecture=MSIL">46 <SpecificVersion>False</SpecificVersion>47 <HintPath>..\..\..\bin\Release\net-35\OpenRasta.dll</HintPath>48 </Reference>49 41 <Reference Include="System" /> 50 <Reference Include="System.Core">51 <RequiredTargetFramework>3.5</RequiredTargetFramework>52 </Reference>53 <Reference Include="System.Xml.Linq">54 <RequiredTargetFramework>3.5</RequiredTargetFramework>55 </Reference>56 <Reference Include="System.Data.DataSetExtensions">57 <RequiredTargetFramework>3.5</RequiredTargetFramework>58 </Reference>59 42 <Reference Include="System.Data" /> 60 43 <Reference Include="System.Xml" /> 61 44 </ItemGroup> 62 45 <ItemGroup> 46 <Compile Include="..\..\CommonInfo.cs"> 47 <Link>CommonInfo.cs</Link> 48 </Compile> 63 49 <Compile Include="Extensions\Policies\CycleDetectionPolicy.cs" /> 64 50 <Compile Include="Extensions\Policies\TypeToBeResolved.cs" /> … … 77 63 <Compile Include="UnityDependencyResolver.cs" /> 78 64 </ItemGroup> 65 66 <ItemGroup> 67 <None Include="dependencies.targets" /> 68 </ItemGroup> 69 <Import Project="dependencies.targets" /> 79 70 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 80 71 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
trunk/src/unity/OpenRasta.DI.Unity/PerRequestLifetimeManager.cs
r387 r427 7 7 /// <summary> 8 8 /// This, combined with the context container management in <see cref="UnityDependencyResolver"/>, 9 /// implements OpenRasta sper request lifetime requirements. One instance of this class is used9 /// implements OpenRasta per request lifetime requirements. One instance of this class is used 10 10 /// per registered type. 11 11 /// </summary> 12 class PerRequestLifetimeManager : LifetimeManager12 internal class PerRequestLifetimeManager : LifetimeManager 13 13 { 14 readonly IDependencyResolver resolver; 15 readonly string key = Guid.NewGuid().ToString(); 14 readonly string _key = Guid.NewGuid().ToString(); 15 readonly IDependencyResolver _resolver; 16 17 public PerRequestLifetimeManager(IDependencyResolver resolver) 18 { 19 _resolver = resolver; 20 } 16 21 17 22 IContextStore ContextStore 18 23 { 19 get { return resolver.Resolve<IContextStore>(); } 20 } 21 22 public PerRequestLifetimeManager(IDependencyResolver resolver) 23 { 24 this.resolver = resolver; 24 get { return _resolver.Resolve<IContextStore>(); } 25 25 } 26 26 … … 30 30 public override object GetValue() 31 31 { 32 if (!resolver.HasDependency<IContextStore>())32 if (!_resolver.HasDependency<IContextStore>()) 33 33 throw new DependencyResolutionException("Context store not initialised."); 34 34 35 return ContextStore[key]; 35 return ContextStore[_key]; 36 } 37 38 public override void RemoveValue() 39 { 40 // Strangely required, but not used by Unity, go Microsoft! 41 throw new NotSupportedException(); 36 42 } 37 43 … … 41 47 public override void SetValue(object newValue) 42 48 { 43 ContextStore[key] = newValue; 44 } 45 46 public override void RemoveValue() 47 { 48 // Strangely required, but not used by Unity, go Microsoft! 49 throw new NotSupportedException(); 49 ContextStore[_key] = newValue; 50 50 } 51 51 } -
trunk/src/unity/OpenRasta.DI.Unity/Properties/AssemblyInfo.cs
r387 r427 1 1 using System.Reflection; 2 using System.Runtime.CompilerServices;3 2 using System.Runtime.InteropServices; 4 3 … … 6 5 // set of attributes. Change these attribute values to modify the information 7 6 // associated with an assembly. 8 [assembly: AssemblyTitle("OpenRasta .DI.Unity")]9 [assembly: AssemblyDescription(" ")]7 [assembly: AssemblyTitle("OpenRasta Unity IoC support")] 8 [assembly: AssemblyDescription("Provides support for using the Unity IoC container.")] 10 9 [assembly: AssemblyConfiguration("")] 11 [assembly: AssemblyCompany("Microsoft")]12 [assembly: AssemblyProduct("OpenRasta.DI.Unity")]13 [assembly: AssemblyCopyright("Copyright © Microsoft 2009")]14 [assembly: AssemblyTrademark("")]15 10 [assembly: AssemblyCulture("")] 16 17 // Setting ComVisible to false makes the types in this assembly not visible18 // to COM components. If you need to access a type in this assembly from19 // COM, set the ComVisible attribute to true on that type.20 [assembly: ComVisible(false)]21 22 // The following GUID is for the ID of the typelib if this project is exposed to COM23 11 [assembly: Guid("f6ef8ad1-3817-4c14-aaca-3840667c4194")] 24 25 // Version information for an assembly consists of the following four values:26 //27 // Major Version28 // Minor Version29 // Build Number30 // Revision31 //32 // You can specify all the values or you can default the Build and Revision Numbers33 // by using the '*' as shown below:34 // [assembly: AssemblyVersion("1.0.*")]35 [assembly: AssemblyVersion("1.0.0.0")]36 [assembly: AssemblyFileVersion("1.0.0.0")] -
trunk/src/unity/OpenRasta.DI.Unity/UnityContainerExtensions.cs
r387 r427 4 4 namespace OpenRasta.DI.Unity 5 5 { 6 static class UnityContainerExtensions6 internal static class UnityContainerExtensions 7 7 { 8 8 /// <summary> -
trunk/src/unity/OpenRasta.DI.Unity/UnityDependencyResolver.cs
r387 r427 4 4 using OpenRasta.DI.Unity.Extensions; 5 5 using OpenRasta.Pipeline; 6 using System.Diagnostics;7 6 8 7 namespace OpenRasta.DI.Unity … … 26 25 public class UnityDependencyResolver : DependencyResolverCore, IDependencyResolver 27 26 { 28 const string C ontextKey = "OpenRasta.DI.Unity.UnityDependencyResolver.ContextKey";27 const string CONTEXT_KEY = "OpenRasta.DI.Unity.UnityDependencyResolver.CONTEXT_KEY"; 29 28 30 29 /// <summary> … … 32 31 /// go per request but this is the one container we can rely on. 33 32 /// </summary> 34 readonly IUnityContainer container; 33 readonly IUnityContainer _container; 34 35 /// <summary> 36 /// Creates a new instance with a new root container. 37 /// </summary> 38 public UnityDependencyResolver() 39 { 40 _container = CreateContainer(); 41 } 42 43 /// <summary> 44 /// Creates a new instance as a child of the given parent container. 45 /// </summary> 46 /// <remarks> 47 /// The parent container must have the <see cref="TypeTracker"/> extension installed. 48 /// </remarks> 49 public UnityDependencyResolver(IUnityContainer parent) 50 { 51 _container = CreateChildContainer(parent); 52 } 35 53 36 54 /// <summary> … … 43 61 public IUnityContainer Container 44 62 { 45 get { return container; } 46 } 47 48 /// <summary> 49 /// Creates a new instance with a new root container. 50 /// </summary> 51 public UnityDependencyResolver() 52 { 53 container = CreateContainer(); 54 } 55 56 /// <summary> 57 /// Creates a new instance as a child of the given parent container. 58 /// </summary> 59 /// <remarks> 60 /// The parent container must have the <see cref="TypeTracker"/> extension installed. 61 /// </remarks> 62 public UnityDependencyResolver(IUnityContainer parent) 63 { 64 container = CreateChildContainer(parent); 63 get { return _container; } 64 } 65 66 public void HandleIncomingRequestProcessed() 67 { 68 if (!_container.TypeTracker().HasDependency(typeof(IContextStore))) 69 return; 70 71 // If we have a per request container, dispose and remove it 72 var context = _container.Resolve<IContextStore>(); 73 var current = (IUnityContainer)context[CONTEXT_KEY]; 74 75 if (current == null) 76 return; 77 78 current.Dispose(); 79 context[CONTEXT_KEY] = null; 80 } 81 82 public bool HasDependency(Type serviceType) 83 { 84 if (serviceType == null) 85 return false; 86 87 return OptionalContextContainer() 88 .TypeTracker() 89 .HasDependency(serviceType); 90 } 91 92 public bool HasDependencyImplementation(Type serviceType, Type concreteType) 93 { 94 if (serviceType == null) 95 throw new ArgumentNullException("serviceType"); 96 97 if (concreteType == null) 98 throw new ArgumentNullException("concreteType"); 99 100 return OptionalContextContainer() 101 .TypeTracker() 102 .HasDependencyImplementation(serviceType, concreteType); 103 } 104 105 protected override void AddDependencyCore(Type serviceType, Type concreteType, DependencyLifetime lifetime) 106 { 107 if (lifetime == DependencyLifetime.Transient) 108 { 109 // Unity registers types as transient by default. 110 _container.RegisterType(serviceType, concreteType); 111 } 112 else if (lifetime == DependencyLifetime.Singleton) 113 { 114 _container.RegisterType(serviceType, concreteType, new ContainerControlledLifetimeManager()); 115 } 116 else if (lifetime == DependencyLifetime.PerRequest) 117 { 118 OptionalContextContainer().RegisterType(serviceType, concreteType, new PerRequestLifetimeManager(this)); 119 } 120 else 121 { 122 throw new NotSupportedException("lifetime"); 123 } 124 } 125 126 protected override void AddDependencyCore(Type concreteType, DependencyLifetime lifetime) 127 { 128 AddDependencyCore(concreteType, concreteType, lifetime); 129 } 130 131 protected override void AddDependencyInstanceCore(Type serviceType, object instance, DependencyLifetime lifetime) 132 { 133 if (lifetime == DependencyLifetime.Singleton) 134 { 135 // Unity registers instances as singletons by default 136 _container.RegisterInstance(serviceType, instance); 137 } 138 else if (lifetime == DependencyLifetime.PerRequest) 139 { 140 RequiredContextContainer().RegisterInstance(serviceType, instance, new PerRequestLifetimeManager(this)); 141 } 142 else 143 { 144 throw new NotSupportedException("lifetime"); 145 } 146 } 147 148 protected override IEnumerable<TService> ResolveAllCore<TService>() 149 { 150 var types = OptionalContextContainer() 151 .TypeTracker() 152 .GetAllConcreteTypes(typeof(TService)); 153 154 var current = OptionalContextContainer(); 155 var services = new List<TService>(); 156 157 foreach (var type in types) 158 { 159 services.Add((TService)current.Resolve(type)); 160 } 161 162 return services; 163 } 164 165 protected override object ResolveCore(Type serviceType) 166 { 167 return OptionalContextContainer().Resolve(serviceType); 168 } 169 170 static IUnityContainer CreateChildContainer(IUnityContainer parent) 171 { 172 if (parent == null) 173 throw new ArgumentNullException("parent"); 174 175 if (parent.TypeTracker() == null) 176 throw new ArgumentException("Parent container does not have the TypeTracker extension installed."); 177 178 var child = parent.CreateChildContainer(); 179 Extend(child); 180 return child; 65 181 } 66 182 … … 70 186 Extend(container); 71 187 return container; 72 }73 74 static IUnityContainer CreateChildContainer(IUnityContainer parent)75 {76 if (parent == null)77 throw new ArgumentNullException("parent");78 79 if (parent.TypeTracker() == null)80 throw new ArgumentException("Parent container does not have the TypeTracker extension installed.");81 82 var child = parent.CreateChildContainer();83 Extend(child);84 return child;85 188 } 86 189 … … 93 196 } 94 197 95 public bool HasDependency(Type serviceType)96 {97 if (serviceType == null)98 return false;99 100 return OptionalContextContainer()101 .TypeTracker()102 .HasDependency(serviceType);103 }104 105 public bool HasDependencyImplementation(Type serviceType, Type concreteType)106 {107 if (serviceType == null)108 throw new ArgumentNullException("serviceType");109 110 if (concreteType == null)111 throw new ArgumentNullException("concreteType");112 113 return OptionalContextContainer()114 .TypeTracker()115 .HasDependencyImplementation(serviceType, concreteType);116 }117 118 public void HandleIncomingRequestProcessed()119 {120 if (!container.TypeTracker().HasDependency(typeof(IContextStore)))121 return;122 123 // If we have a per request container, dispose and remove it124 var context = container.Resolve<IContextStore>();125 var current = (IUnityContainer)context[ContextKey];126 127 if(current == null)128 return;129 130 current.Dispose();131 context[ContextKey] = null;132 }133 134 protected override void AddDependencyCore(Type serviceType, Type concreteType, DependencyLifetime lifetime)135 {136 if (lifetime == DependencyLifetime.Transient)137 {138 // Unity registers types as transient by default.139 container.RegisterType(serviceType, concreteType);140 }141 else if (lifetime == DependencyLifetime.Singleton)142 {143 container.RegisterType(serviceType, concreteType, new ContainerControlledLifetimeManager());144 }145 else if (lifetime == DependencyLifetime.PerRequest)146 {147 OptionalContextContainer().RegisterType(serviceType, concreteType, new PerRequestLifetimeManager(this));148 }149 else150 {151 throw new NotSupportedException("lifetime");152 }153 }154 155 protected override void AddDependencyCore(Type concreteType, DependencyLifetime lifetime)156 {157 AddDependencyCore(concreteType, concreteType, lifetime);158 }159 160 protected override void AddDependencyInstanceCore(Type serviceType, object instance, DependencyLifetime lifetime)161 {162 if (lifetime == DependencyLifetime.Singleton)163 {164 // Unity registers instances as singletons by default165 container.RegisterInstance(serviceType, instance);166 }167 else if (lifetime == DependencyLifetime.PerRequest)168 {169 RequiredContextContainer().RegisterInstance(serviceType, instance, new PerRequestLifetimeManager(this));170 }171 else172 {173 throw new NotSupportedException("lifetime");174 }175 }176 177 /// <summary>178 /// Ensures that there is a child container for the current request and returns it.179 /// </summary>180 IUnityContainer RequiredContextContainer()181 {182 if (!container.TypeTracker().HasDependency(typeof(IContextStore)))183 throw new InvalidOperationException("There is no current per request context to register in.");184 185 var context = container.Resolve<IContextStore>();186 var current = (IUnityContainer)context[ContextKey];187 188 if (current == null)189 {190 current = CreateChildContainer(container);191 context[ContextKey] = current;192 }193 194 return current;195 }196 197 198 /// <summary> 198 199 /// Returns the child container for this request if there is one, otherwise returns the … … 201 202 IUnityContainer OptionalContextContainer() 202 203 { 203 if (!container.TypeTracker().HasDependency(typeof(IContextStore))) 204 return container; 205 206 var context = container.Resolve<IContextStore>(); 207 var current = (IUnityContainer)context[ContextKey]; 208 209 return current ?? container; 210 } 211 212 protected override IEnumerable<TService> ResolveAllCore<TService>() 213 { 214 var types = OptionalContextContainer() 215 .TypeTracker() 216 .GetAllConcreteTypes(typeof (TService)); 217 218 var current = OptionalContextContainer(); 219 var services = new List<TService>(); 220 221 foreach (var type in types) 222 { 223 services.Add((TService)current.Resolve(type)); 224 } 225 226 return services; 227 } 228 229 protected override object ResolveCore(Type serviceType) 230 { 231 return OptionalContextContainer().Resolve(serviceType); 204 if (!_container.TypeTracker().HasDependency(typeof(IContextStore))) 205 return _container; 206 207 var context = _container.Resolve<IContextStore>(); 208 var current = (IUnityContainer)context[CONTEXT_KEY]; 209 210 return current ?? _container; 211 } 212 213 /// <summary> 214 /// Ensures that there is a child container for the current request and returns it. 215 /// </summary> 216 IUnityContainer RequiredContextContainer() 217 { 218 if (!_container.TypeTracker().HasDependency(typeof(IContextStore))) 219 throw new InvalidOperationException("There is no current per request context to register in."); 220 221 var context = _container.Resolve<IContextStore>(); 222 var current = (IUnityContainer)context[CONTEXT_KEY]; 223 224 if (current == null) 225 { 226 current = CreateChildContainer(_container); 227 context[CONTEXT_KEY] = current; 228 } 229 230 return current; 232 231 } 233 232 }
