You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
|
Feb
(5) |
Mar
(9) |
Apr
(9) |
May
(4) |
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(3) |
2008 |
Jan
(11) |
Feb
(6) |
Mar
|
Apr
(16) |
May
(28) |
Jun
(13) |
Jul
(3) |
Aug
(19) |
Sep
(11) |
Oct
(37) |
Nov
(1) |
Dec
(17) |
2009 |
Jan
(16) |
Feb
(6) |
Mar
|
Apr
(6) |
May
(1) |
Jun
(10) |
Jul
(4) |
Aug
(4) |
Sep
(4) |
Oct
(8) |
Nov
(3) |
Dec
(45) |
2010 |
Jan
(8) |
Feb
(21) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2016 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(1) |
Oct
|
Nov
|
Dec
|
From: <fli...@us...> - 2010-03-08 01:03:32
|
Revision: 350 http://structuremap.svn.sourceforge.net/structuremap/?rev=350&view=rev Author: flimflan Date: 2010-03-08 01:03:25 +0000 (Mon, 08 Mar 2010) Log Message: ----------- Removing trunk source code to avoid confusion. All ongoing development is at http://github.com/structuremap/structuremap Last state of trunk is still available read-only under branches/trunk_before_github_move Added Paths: ----------- trunk/moved_to_github.txt Removed Paths: ------------- trunk/CleanUp.BAT trunk/Docs/ trunk/Icons/ trunk/LICENSE.TXT trunk/README.TXT trunk/RunBuild.BAT trunk/Source/ trunk/StructureMap.chm trunk/StructureMap.config trunk/bin/ trunk/cruise.build trunk/nunitTests.config Deleted: trunk/CleanUp.BAT =================================================================== --- trunk/CleanUp.BAT 2010-03-08 00:57:51 UTC (rev 349) +++ trunk/CleanUp.BAT 2010-03-08 01:03:25 UTC (rev 350) @@ -1,2 +0,0 @@ -bin\nant\nant.exe -buildfile:cruise.build post-clean -pause Deleted: trunk/LICENSE.TXT =================================================================== --- trunk/LICENSE.TXT 2010-03-08 00:57:51 UTC (rev 349) +++ trunk/LICENSE.TXT 2010-03-08 01:03:25 UTC (rev 350) @@ -1,194 +0,0 @@ -StructureMap - -Copyright 2004-2009 Jeremy D. Miller - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - - - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS \ No newline at end of file Deleted: trunk/README.TXT =================================================================== --- trunk/README.TXT 2010-03-08 00:57:51 UTC (rev 349) +++ trunk/README.TXT 2010-03-08 01:03:25 UTC (rev 350) @@ -1,16 +0,0 @@ -To start using StructureMap, either use the DLL's in the "deploy" folder or click on the RunBuild.BAT file to run the full NAnt build. There is a known issue with the build "sticking" on the custom NAnt tasks. If this happens, delete the copies of StructureMap.Dll and StructureMap.DeploymentTasks.Dll in the bin\NAnt folder. Look in the "build" directory for the build products. - -To enable the debugger visualizers in Visual Studio 2008, put a copy of StructureMap.dll and StructureMap.DebuggerVisualizers.dll in "<My Documents>\Visual Studio 2008\Visualizers" -**WARNING: The visualizer is very early and not well tested. You may experience issues (unhandled exceptions while using the visualizer) if the version of StructureMap.dll in your project is not the exact version in your Visualizers folder. - -A copy of the StructureMap website and documentation is in the "Docs" folder. - - -Please post any questions or bugs to the StructureMap Users mailing list: -http://groups.google.com/group/structuremap-users - - -The latest code and documentation is available on SourceForge: -http://structuremap.sourceforge.net/ - -Thanks for trying StructureMap. Deleted: trunk/RunBuild.BAT =================================================================== --- trunk/RunBuild.BAT 2010-03-08 00:57:51 UTC (rev 349) +++ trunk/RunBuild.BAT 2010-03-08 01:03:25 UTC (rev 350) @@ -1,2 +0,0 @@ -bin\nant\nant.exe -buildfile:cruise.build %* -pause Deleted: trunk/StructureMap.chm =================================================================== (Binary files differ) Deleted: trunk/StructureMap.config =================================================================== --- trunk/StructureMap.config 2010-03-08 00:57:51 UTC (rev 349) +++ trunk/StructureMap.config 2010-03-08 01:03:25 UTC (rev 350) @@ -1,99 +0,0 @@ -<!--<?xml version="1.0" encoding="utf-8" ?>--> -<StructureMap DefaultProfile="TheDefaultProfile" Id="Main"> - <Assembly Name="StructureMap.Testing.Widget" Deploy="Client, Test, Server"/> - <Assembly Name="StructureMap.Testing.Widget2" Deploy="Remote"/> - <Assembly Name="StructureMap.Testing.Widget3"/> - - - <Profile Name="TheDefaultProfile"> - <Override Type="StructureMap.Testing.Widget.GrandChild,StructureMap.Testing.Widget" DefaultKey="Todd"/> - </Profile> - - <PluginFamily Type="StructureMap.Testing.Widget.IWidget" Assembly="StructureMap.Testing.Widget" DefaultKey="Red"> - <Source Type="XmlFile" FilePath="FullTesting.XML" XPath="Widgets" NodeName="Widget"/> - <Plugin Assembly="StructureMap.Testing.Widget" Type="StructureMap.Testing.Widget.NotPluggableWidget" ConcreteKey="NotPluggable"/> - </PluginFamily> - - <!-- If no source is defined, use the default MementoSource --> - <PluginFamily Type="StructureMap.Testing.Widget.Column" Assembly="StructureMap.Testing.Widget"> - <Source Type="XmlFile" FilePath="FullTesting.XML" XPath="Columns" NodeName="Columns" /> - </PluginFamily> - - - <PluginFamily Type="StructureMap.Testing.Widget.Rule" Assembly="StructureMap.Testing.Widget" DefaultKey="Blue"> - <Interceptors> - <Interceptor Type="Singleton"></Interceptor> - </Interceptors> - - <Instance Key="Red" Type="Color"> - <Property Name="color" Value="Red" /> - </Instance> - <Instance Key="Blue" Type="Color"> - <Property Name="color" Value="Blue" /> - </Instance> - <Instance Key="Bigger" Type="GreaterThan"> - <Property Name="Attribute" Value="MyDad" /> - <Property Name="Value" Value="10" /> - </Instance> - </PluginFamily> - - <AddInstance PluginType="StructureMap.Testing.Widget.GrandChild, StructureMap.Testing.Widget" Type="Default" Key="Tommy"> - <Property Name="RightHanded" Value="true" /> - <Property Name="BirthYear" Value="1972" /> - </AddInstance> - - <AddInstance PluginType="StructureMap.Testing.Widget.GrandChild, StructureMap.Testing.Widget" Type="Default" Key="Todd"> - <Property Name="RightHanded" Value="true" /> - <Property Name="BirthYear" Value="1975" /> - </AddInstance> - - <AddInstance PluginType="StructureMap.Testing.Widget.GrandChild, StructureMap.Testing.Widget" Type="Leftie" Key="Trevor"> - <Property Name="BirthYear" Value="1979" /> - </AddInstance> - - <AddInstance PluginType="StructureMap.Testing.Widget.Child, StructureMap.Testing.Widget" Type="Default" Key="Tom"> - <Property Name="Name" Value="Tom" /> - <Property Name="MyGrandChild" Type="Leftie"> - <Property Name="BirthYear" Value="1984" /> - </Property> - </AddInstance> - - <AddInstance PluginType="StructureMap.Testing.Widget.Child, StructureMap.Testing.Widget" Type="Default" Key="Marsha"> - <Property Name="Name" Value="Marsha"/> - <Property Name="MyGrandChild" Key="Tommy"/> - </AddInstance> - - - <AddInstance PluginType="StructureMap.Testing.Widget.Child, StructureMap.Testing.Widget" Type="Default" Key="Jessica"> - <Property Name="Name" Value="Jessica"/> - <Property Name="MyGrandChild"/> - </AddInstance> - - <AddInstance PluginType="StructureMap.Testing.Widget.Child, StructureMap.Testing.Widget" Type="Default" Key="Monte"> - <Property Name="Name" Value="Monte"/> - <Property Name="MyGrandChild" Key="NotARealGrandchild"/> - </AddInstance> - - <AddInstance PluginType="StructureMap.Testing.Widget.Parent, StructureMap.Testing.Widget" Type="Default" Key="Jerry"> - <Property Name="Age" Value="72"/> - <Property Name="EyeColor" Value="Blue"/> - <Property Name="MyChild" Key="Marsha"/> - </AddInstance> - - <AddInstance PluginType="StructureMap.Testing.Widget.Parent, StructureMap.Testing.Widget" Type="Default" Key="Jackie"> - <Property Name="Age" Value="70"/> - <Property Name="EyeColor" Value="Green"/> - <Property Name="MyChild" Type="Default"> - <Property Name="Name" Value="Elizabeth"/> - <Property Name="MyGrandChild" Type="Leftie"> - <Property Name="BirthYear" Value="1992"/> - </Property> - </Property> - </AddInstance> - - <AddInstance PluginType="StructureMap.Testing.Widget.WidgetMaker, StructureMap.Testing.Widget" Type="Color" Key="Red"> - <Property Name="color" Value="Red" /> - </AddInstance> - - -</StructureMap> Deleted: trunk/cruise.build =================================================================== --- trunk/cruise.build 2010-03-08 00:57:51 UTC (rev 349) +++ trunk/cruise.build 2010-03-08 01:03:25 UTC (rev 350) @@ -1,160 +0,0 @@ -<project name="StructureMap" default="all"> - <loadtasks assembly="bin/nant/extensions/common/2.0/NAntExtensions.TeamCity.dll" /> - <property name="build.dir" value="build" /> - <property name="deployment.dir" value="source\StructureMap.Testing.DeploymentTasks\"/> - <property name="results.dir" value="results" /> - <property name="nant.dir" value="bin\nant" /> - <property name="project.version" value="2.6.2" /> - <property name="project.config" value="release" /> - <property name="archive.dir" value="archive"/> - <target name="all" depends="compile, unit-test, post-clean"/> - <target name="release" depends="compile, post-clean"/> - <target name="ci" depends="compile, unit-test, post-clean, archive" /> - - <target name="pre-clean"> - <delete dir="${build.dir}" failonerror="false" /> - <delete dir="${results.dir}" failonerror="false"/> - <delete dir="${archive.dir}" failonerror="false" /> - - <mkdir dir="${build.dir}" /> - <mkdir dir="${results.dir}" /> - <mkdir dir="${archive.dir}" /> - - <call target="cleanJunk" /> - </target> - - <target name="cleanJunk"> - <delete failonerror="false"> - <fileset basedir="."> - <include name="source/**/obj/**"/> - <include name="source/**/bin**"/> - <include name="**/_ReSharper*"/> - <include name="source/**/*.resharperoptions"/> - </fileset> - </delete> - </target> - - <target name="version" description="mark AssemblyInfo builds with the build number"> - <property name="assembly-version" value="${project.version}.0000" /> - <property name="file-version" value="${project.version}.0000" /> - <if test="${environment::variable-exists('BUILD_VCS_NUMBER_SourceForge_SVN')}"> - <property name="file-version" value="${project.version}.${environment::get-variable('BUILD_VCS_NUMBER_SourceForge_SVN')}" /> - </if> - - <echo message="Marking this build as version ${assembly-version}" /> - <tc-buildnumber build-number="${assembly-version}-${'{build.number}'}" /> - <asminfo output="Source/CommonAssemblyInfo.cs" language="CSharp"> - <imports> - <import namespace="System" /> - <import namespace="System.Reflection" /> - <import namespace="System.Runtime.InteropServices" /> - </imports> - <attributes> - <attribute type="ComVisibleAttribute" value="false" /> - <attribute type="AssemblyVersionAttribute" value="${assembly-version}" /> - <attribute type="AssemblyCopyrightAttribute" value="Copyright (c) 2003-2008, Jeremy D. Miller" /> - <attribute type="AssemblyProductAttribute" value="StructureMap" /> - <attribute type="AssemblyCompanyAttribute" value="" /> - <attribute type="AssemblyConfigurationAttribute" value="${project.config}" /> - <attribute type="AssemblyInformationalVersionAttribute" value="${file-version}" /> - <attribute type="AssemblyFileVersionAttribute" value="${file-version}" /> - </attributes> - <references> - <include name="System.dll" /> - </references> - </asminfo> - </target> - - - <target name="compile" depends="pre-clean,version"> - <exec program="${nant.settings.currentframework.frameworkdirectory}\msbuild.exe" commandline="source\StructureMap.sln /t:rebuild /p:Configuration=Release"> - </exec> - - <copy todir="${build.dir}" flatten="true" overwrite="true"> - <fileset basedir="source\"> - <include name="**\bin\${project.config}\*.dll" /> - <include name="**\bin\${project.config}\*.exe" /> - <include name="**\bin\${project.config}\*.pdb" /> - <include name="**\bin\${project.config}\*.xml" /> - <include name="**\bin\${project.config}\*.xml.actual" /> - <include name="StructureMap.Testing\*.config" /> - </fileset> - </copy> - <copy todir="${build.dir}\..\" flatten="true" overwrite="true"> - <fileset basedir="source\"> - <include name="StructureMap.Testing\StructureMap.config" /> - </fileset> - </copy> - - </target> - - - - <target name="unit-test"> - <property name="nunit-console.exe" value="bin\NUnit\nunit-console.exe" /> - - <exec program="${nunit-console.exe}" workingdir="${build.dir}"> - <arg value="StructureMap.Testing.dll" /> - </exec> - <exec program="${nunit-console.exe}" workingdir="${build.dir}"> - <arg value="StructureMap.DebuggerVisualizers.Testing.exe" /> - </exec> - - - </target> - - <target name="runDoctor"> - <echo message="Running StructureMapDoctor" /> - <copy file="source\StructureMap.Testing\TestData\ObjectMother.config" todir="build" verbose="true"/> - - - <exec - program="${build.dir}\StructureMapDoctor.exe" - workingdir="." - commandline="${build.dir}\ObjectMother.config -All"/> - - <delete file="build/ObjectMother.config" /> - - </target> - - - - <target name="post-clean"> - - <delete dir="deploy" failonerror="false" /> - <mkdir dir="deploy" /> - - <copy todir="deploy" flatten="true" overwrite="true"> - <fileset basedir="source\StructureMap.Testing\bin\${project.config}"> - <include name="StructureMap.dll" /> - <include name="StructureMap.xml" /> - <include name="StructureMap.AutoMocking.dll" /> - <include name="StructureMap.AutoMocking.xml" /> - </fileset> - </copy> - - <copy todir="deploy" file="bin\Rhino.Mocks.dll"/> - <copy todir="deploy" file="StructureMap.chm"/> - <copy todir="deploy" file="LICENSE.TXT"/> - - <copy todir="deploy" file="Source\StructureMapDoctor\bin\${project.config}\StructureMapDoctor.exe" /> - - <call target="cleanJunk" /> - </target> - - - <target name="archive" depends="version"> - <if test="${environment::variable-exists('TEAMCITY_PROJECT_NAME')}"> - <zip zipfile="${archive.dir}\StructureMap_${assembly-version}.zip"> - <fileset basedir="${build.dir}"> - <include name="*.dll" /> - <include name="*.exe" /> - <exclude name="*.xml" /> - </fileset> - </zip> - </if> - - - </target> - -</project> \ No newline at end of file Added: trunk/moved_to_github.txt =================================================================== --- trunk/moved_to_github.txt (rev 0) +++ trunk/moved_to_github.txt 2010-03-08 01:03:25 UTC (rev 350) @@ -0,0 +1,5 @@ +StructureMap has moved to github http://github.com/structuremap/structuremap + +The entire trunk history was migrated to git. +Branches were not migrated, but still exist as read-only in subversion on sourceforge. +The last state of the trunk was saved in a branch at branches/trunk_before_github_move \ No newline at end of file Deleted: trunk/nunitTests.config =================================================================== --- trunk/nunitTests.config 2010-03-08 00:57:51 UTC (rev 349) +++ trunk/nunitTests.config 2010-03-08 01:03:25 UTC (rev 350) @@ -1,13 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<configuration> - - <runtime> - <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> - <dependentAssembly> - <assemblyIdentity name="nunit.framework" publicKeyToken="96d09a1eb7f44a77" culture="Neutral" /> - <bindingRedirect oldVersion="2.2.5.0" newVersion="2.2.0.0" /> - </dependentAssembly> - </assemblyBinding> - </runtime> - -</configuration> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fli...@us...> - 2010-03-08 00:57:57
|
Revision: 349 http://structuremap.svn.sourceforge.net/structuremap/?rev=349&view=rev Author: flimflan Date: 2010-03-08 00:57:51 +0000 (Mon, 08 Mar 2010) Log Message: ----------- Storing the state of the trunk in a branch so that trunk can be wiped out to avoid confusion. All ongoing development is at http://github.com/structuremap Added Paths: ----------- branches/trunk_before_github_move/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fli...@us...> - 2010-02-11 23:12:10
|
Revision: 348 http://structuremap.svn.sourceforge.net/structuremap/?rev=348&view=rev Author: flimflan Date: 2010-02-11 23:12:03 +0000 (Thu, 11 Feb 2010) Log Message: ----------- Fixing build so that the Assembly version is not reved for every build - only the File version. This will keep different builds strongname compatible until the version is manually changed in the build file, while still providing tracability of binaries to builds. Modified Paths: -------------- trunk/cruise.build Modified: trunk/cruise.build =================================================================== --- trunk/cruise.build 2010-02-11 02:43:57 UTC (rev 347) +++ trunk/cruise.build 2010-02-11 23:12:03 UTC (rev 348) @@ -4,7 +4,7 @@ <property name="deployment.dir" value="source\StructureMap.Testing.DeploymentTasks\"/> <property name="results.dir" value="results" /> <property name="nant.dir" value="bin\nant" /> - <property name="project.version" value="2.6.1" /> + <property name="project.version" value="2.6.2" /> <property name="project.config" value="release" /> <property name="archive.dir" value="archive"/> <target name="all" depends="compile, unit-test, post-clean"/> @@ -36,8 +36,9 @@ <target name="version" description="mark AssemblyInfo builds with the build number"> <property name="assembly-version" value="${project.version}.0000" /> + <property name="file-version" value="${project.version}.0000" /> <if test="${environment::variable-exists('BUILD_VCS_NUMBER_SourceForge_SVN')}"> - <property name="assembly-version" value="${project.version}.${environment::get-variable('BUILD_VCS_NUMBER_SourceForge_SVN')}" /> + <property name="file-version" value="${project.version}.${environment::get-variable('BUILD_VCS_NUMBER_SourceForge_SVN')}" /> </if> <echo message="Marking this build as version ${assembly-version}" /> @@ -55,8 +56,8 @@ <attribute type="AssemblyProductAttribute" value="StructureMap" /> <attribute type="AssemblyCompanyAttribute" value="" /> <attribute type="AssemblyConfigurationAttribute" value="${project.config}" /> - <attribute type="AssemblyInformationalVersionAttribute" value="${assembly-version}" /> - <attribute type="AssemblyFileVersionAttribute" value="${assembly-version}" /> + <attribute type="AssemblyInformationalVersionAttribute" value="${file-version}" /> + <attribute type="AssemblyFileVersionAttribute" value="${file-version}" /> </attributes> <references> <include name="System.dll" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2010-02-11 02:44:07
|
Revision: 347 http://structuremap.svn.sourceforge.net/structuremap/?rev=347&view=rev Author: jeremydmiller Date: 2010-02-11 02:43:57 +0000 (Thu, 11 Feb 2010) Log Message: ----------- Fixing a bug with IContext.GetAllInstances<T>() Modified Paths: -------------- trunk/Source/StructureMap/BuildSession.cs trunk/Source/StructureMap.Testing/BuildSessionTester.cs trunk/Source/StructureMap.Testing/Configuration/DSL/InterceptorTesting.cs trunk/Source/StructureMap.Testing/Examples.cs trunk/Source/StructureMap.Testing/Pipeline/ContainerDisposalTester.cs trunk/Source/StructureMap.Testing/Pipeline/NestedContainerSupportTester.cs trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj trunk/Source/StructureMap.Testing.Widget3/IService.cs trunk/cruise.build Added Paths: ----------- trunk/Source/StructureMap.Testing/Bugs/EnumerableShouldGetAllValuesTester.cs Modified: trunk/Source/StructureMap/BuildSession.cs =================================================================== --- trunk/Source/StructureMap/BuildSession.cs 2010-02-10 00:14:42 UTC (rev 346) +++ trunk/Source/StructureMap/BuildSession.cs 2010-02-11 02:43:57 UTC (rev 347) @@ -119,7 +119,7 @@ public IEnumerable<T> GetAllInstances<T>() { - return forType(typeof (T)).AllInstances.Select(x => GetInstance<T>()); + return (IEnumerable<T>) forType(typeof (T)).AllInstances.Select(x => (T)CreateInstance(typeof(T), x)); } protected void clearBuildStack() Added: trunk/Source/StructureMap.Testing/Bugs/EnumerableShouldGetAllValuesTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Bugs/EnumerableShouldGetAllValuesTester.cs (rev 0) +++ trunk/Source/StructureMap.Testing/Bugs/EnumerableShouldGetAllValuesTester.cs 2010-02-11 02:43:57 UTC (rev 347) @@ -0,0 +1,44 @@ +using System.Collections.Generic; +using NUnit.Framework; +using StructureMap.Testing.Widget; +using System.Linq; + +namespace StructureMap.Testing.Bugs +{ + [TestFixture] + public class EnumerableShouldGetAllValuesTester + { + [SetUp] + public void SetUp() + { + } + + [Test] + public void ienumerable_arg_should_get_all_registered() + { + var container = new Container(x => + { + x.For<IWidget>().AddInstances(o => + { + o.Type<ColorWidget>().Ctor<string>("color").Is("red"); + o.Type<ColorWidget>().Ctor<string>("color").Is("blue"); + o.Type<ColorWidget>().Ctor<string>("color").Is("green"); + }); + }); + + container.GetInstance<ClassWithEnumerable>().Widgets.Count().ShouldEqual(3); + } + + public class ClassWithEnumerable + { + private readonly IEnumerable<IWidget> _widgets; + + public ClassWithEnumerable(IEnumerable<IWidget> widgets) + { + _widgets = widgets; + } + + public IEnumerable<IWidget> Widgets { get { return _widgets; } } + } + } +} \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/BuildSessionTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/BuildSessionTester.cs 2010-02-10 00:14:42 UTC (rev 346) +++ trunk/Source/StructureMap.Testing/BuildSessionTester.cs 2010-02-11 02:43:57 UTC (rev 347) @@ -67,7 +67,49 @@ container.GetInstance<TopClass>().Widgets.Count().ShouldEqual(4); } + [Test] + public void can_get_all_of_a_type_during_object_creation_as_generic_type() + { + var container = new Container(x => + { + x.For<IWidget>().AddInstances(o => + { + o.OfConcreteType<AWidget>(); + o.ConstructedBy(() => new ColorWidget("red")); + o.ConstructedBy(() => new ColorWidget("blue")); + o.ConstructedBy(() => new ColorWidget("green")); + }); + + x.ForConcreteType<TopClass>().Configure.OnCreation( + (c, top) => { top.Widgets = c.All<IWidget>().ToArray(); }); + }); + + container.GetInstance<TopClass>().Widgets.Count().ShouldEqual(4); + } + + + [Test] + public void can_get_all_of_a_type_by_GetAllInstances_during_object_creation_as_generic_type() + { + var container = new Container(x => + { + x.For<IWidget>().AddInstances(o => + { + o.OfConcreteType<AWidget>(); + o.ConstructedBy(() => new ColorWidget("red")); + o.ConstructedBy(() => new ColorWidget("blue")); + o.ConstructedBy(() => new ColorWidget("green")); + }); + + x.ForConcreteType<TopClass>().Configure.OnCreation( + (c, top) => { top.Widgets = c.GetAllInstances<IWidget>().ToArray(); }); + }); + + container.GetInstance<TopClass>().Widgets.Count().ShouldEqual(4); + } + + [Test] public void Get_a_unique_value_for_each_individual_buildsession() { int count = 0; Modified: trunk/Source/StructureMap.Testing/Configuration/DSL/InterceptorTesting.cs =================================================================== --- trunk/Source/StructureMap.Testing/Configuration/DSL/InterceptorTesting.cs 2010-02-10 00:14:42 UTC (rev 346) +++ trunk/Source/StructureMap.Testing/Configuration/DSL/InterceptorTesting.cs 2010-02-11 02:43:57 UTC (rev 347) @@ -150,6 +150,10 @@ public IService Inner { get { return _inner; } } + public void DoSomething() + { + throw new NotImplementedException(); + } } public class ContextRecorder Modified: trunk/Source/StructureMap.Testing/Examples.cs =================================================================== --- trunk/Source/StructureMap.Testing/Examples.cs 2010-02-10 00:14:42 UTC (rev 346) +++ trunk/Source/StructureMap.Testing/Examples.cs 2010-02-11 02:43:57 UTC (rev 347) @@ -403,6 +403,10 @@ public class RemoteService : IService { + public void DoSomething() + { + throw new NotImplementedException(); + } } public class InstanceExampleRegistry : Registry Modified: trunk/Source/StructureMap.Testing/Pipeline/ContainerDisposalTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Pipeline/ContainerDisposalTester.cs 2010-02-10 00:14:42 UTC (rev 346) +++ trunk/Source/StructureMap.Testing/Pipeline/ContainerDisposalTester.cs 2010-02-11 02:43:57 UTC (rev 347) @@ -1,5 +1,6 @@ using System; using NUnit.Framework; +using StructureMap.Testing.Widget3; namespace StructureMap.Testing.Pipeline { Modified: trunk/Source/StructureMap.Testing/Pipeline/NestedContainerSupportTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Pipeline/NestedContainerSupportTester.cs 2010-02-10 00:14:42 UTC (rev 346) +++ trunk/Source/StructureMap.Testing/Pipeline/NestedContainerSupportTester.cs 2010-02-11 02:43:57 UTC (rev 347) @@ -206,7 +206,11 @@ [Test] public void transient_service_in_the_parent_container_is_effectively_a_singleton_for_the_nested_container() { - var parent = new Container(x => { x.For<IWidget>().Use<AWidget>(); }); + var parent = new Container(x => + { + // IWidget is a "transient" + x.For<IWidget>().Use<AWidget>(); + }); IContainer child = parent.GetNestedContainer(); Modified: trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj =================================================================== --- trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2010-02-10 00:14:42 UTC (rev 346) +++ trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2010-02-11 02:43:57 UTC (rev 347) @@ -180,6 +180,7 @@ <Compile Include="BidirectionalDependencies.cs" /> <Compile Include="Bugs\AddValueDirectlyWithGenericUsage.cs" /> <Compile Include="Bugs\BuildUpBug.cs" /> + <Compile Include="Bugs\EnumerableShouldGetAllValuesTester.cs" /> <Compile Include="Bugs\FillAllPropertiesShouldWorkForAlreadyConfiguredPluginsBug.cs" /> <Compile Include="Bugs\HttpSessionNullRefBug.cs" /> <Compile Include="Bugs\IDictionaryAndXmlBugTester.cs" /> Modified: trunk/Source/StructureMap.Testing.Widget3/IService.cs =================================================================== --- trunk/Source/StructureMap.Testing.Widget3/IService.cs 2010-02-10 00:14:42 UTC (rev 346) +++ trunk/Source/StructureMap.Testing.Widget3/IService.cs 2010-02-11 02:43:57 UTC (rev 347) @@ -1,3 +1,5 @@ +using System; + namespace StructureMap.Testing.Widget3 { public interface IService : IBasicService @@ -2,2 +4,3 @@ { + void DoSomething(); } @@ -25,5 +28,10 @@ { return "ColorService: " + _color; } + + public void DoSomething() + { + throw new NotImplementedException(); + } } } \ No newline at end of file Modified: trunk/cruise.build =================================================================== --- trunk/cruise.build 2010-02-10 00:14:42 UTC (rev 346) +++ trunk/cruise.build 2010-02-11 02:43:57 UTC (rev 347) @@ -4,7 +4,7 @@ <property name="deployment.dir" value="source\StructureMap.Testing.DeploymentTasks\"/> <property name="results.dir" value="results" /> <property name="nant.dir" value="bin\nant" /> - <property name="project.version" value="2.6.2" /> + <property name="project.version" value="2.6.1" /> <property name="project.config" value="release" /> <property name="archive.dir" value="archive"/> <target name="all" depends="compile, unit-test, post-clean"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fli...@us...> - 2010-02-10 01:10:36
|
Revision: 346 http://structuremap.svn.sourceforge.net/structuremap/?rev=346&view=rev Author: flimflan Date: 2010-02-10 00:14:42 +0000 (Wed, 10 Feb 2010) Log Message: ----------- Fix bug in Registry equality. Two different instances of Registry are not considered equal. Two different instances of the same Registry derived type are considered equal. Modified Paths: -------------- trunk/Source/StructureMap/Configuration/DSL/Registry.cs trunk/Source/StructureMap.Testing/Configuration/DSL/RegistryTester.cs Modified: trunk/Source/StructureMap/Configuration/DSL/Registry.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2010-02-05 03:06:42 UTC (rev 345) +++ trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2010-02-10 00:14:42 UTC (rev 346) @@ -417,31 +417,27 @@ return (type.GetConstructor(new Type[0]) != null); } - public bool Equals(Registry obj) + public bool Equals(Registry other) { - if (ReferenceEquals(null, obj)) return false; - return GetType().Equals(obj.GetType()); + if (ReferenceEquals(null, other)) return false; + if (ReferenceEquals(this, other)) return true; + if(other.GetType() == typeof(Registry) && GetType() == typeof(Registry)) return false; + return Equals(other.GetType(), GetType()); } public override bool Equals(object obj) { if (ReferenceEquals(null, obj)) return false; if (ReferenceEquals(this, obj)) return true; - - if (obj is Registry) return false; - - - if (obj.GetType() != typeof (Registry)) return false; + if (!typeof (Registry).IsAssignableFrom(obj.GetType())) return false; return Equals((Registry) obj); } public override int GetHashCode() { - return 0; + return GetType().GetHashCode(); } - #region Nested type: BuildWithExpression - /// <summary> /// Define the constructor and setter arguments for the default T /// </summary> @@ -457,7 +453,5 @@ public SmartInstance<T> Configure { get { return _instance; } } } - - #endregion } } \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/Configuration/DSL/RegistryTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Configuration/DSL/RegistryTester.cs 2010-02-05 03:06:42 UTC (rev 345) +++ trunk/Source/StructureMap.Testing/Configuration/DSL/RegistryTester.cs 2010-02-10 00:14:42 UTC (rev 346) @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using NUnit.Framework; using StructureMap.Configuration.DSL; using StructureMap.Graph; @@ -63,20 +64,37 @@ } [Test] - public void Equals_check_true() + public void an_instance_of_the_base_registry_is_equal_to_itself() { + var registry1 = new Registry(); + + registry1.Equals((object)registry1).ShouldBeTrue(); + } + + [Test] + public void two_instances_of_the_base_registry_type_are_not_considered_equal() + { + var registry1 = new Registry(); + var registry2 = new Registry(); + + registry1.Equals((object)registry2).ShouldBeFalse(); + } + + [Test] + public void two_instances_of_a_derived_registry_type_are_considered_equal() + { var registry1 = new TestRegistry(); var registry2 = new TestRegistry(); var registry3 = new TestRegistry2(); var registry4 = new TestRegistry2(); - registry1.Equals(registry1).ShouldBeTrue(); - registry1.Equals(registry2).ShouldBeTrue(); - registry2.Equals(registry1).ShouldBeTrue(); - registry3.Equals(registry4).ShouldBeTrue(); + registry1.Equals((object)registry1).ShouldBeTrue(); + registry1.Equals((object)registry2).ShouldBeTrue(); + registry2.Equals((object)registry1).ShouldBeTrue(); + registry3.Equals((object)registry4).ShouldBeTrue(); - registry1.Equals(registry3).ShouldBeFalse(); - registry3.Equals(registry1).ShouldBeFalse(); + registry1.Equals((object)registry3).ShouldBeFalse(); + registry3.Equals((object)registry1).ShouldBeFalse(); } [Test] @@ -94,7 +112,46 @@ container.GetAllInstances<IWidget>().Count.ShouldEqual(5); } + public class MutatedWidget : IWidget + { + public void DoSomething() { } + } + + public class MutatingRegistry : Registry + { + private static int count = 0; + + public MutatingRegistry() + { + For<IWidget>().Use<AWidget>(); + + if(count++ >= 1) + { + For<IWidget>().Use<MutatedWidget>(); + } + } + } + [Test] + public void include_an_existing_registry_should_not_reevaluate_the_registry() + { + var registry1 = new Registry(); + registry1.IncludeRegistry<MutatingRegistry>(); + + var registry2 = new Registry(); + registry2.IncludeRegistry<MutatingRegistry>(); + + var container = new Container(config => + { + config.AddRegistry(registry1); + config.AddRegistry(registry2); + }); + + container.GetInstance<IWidget>().ShouldBeOfType<AWidget>(); + } + + + [Test] public void Latch_on_a_PluginGraph() { var registry2 = new TestRegistry2(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2010-02-05 03:07:04
|
Revision: 345 http://structuremap.svn.sourceforge.net/structuremap/?rev=345&view=rev Author: jeremydmiller Date: 2010-02-05 03:06:42 +0000 (Fri, 05 Feb 2010) Log Message: ----------- made a copy Modified Paths: -------------- branches/nhibernate/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs branches/nhibernate/Source/StructureMap.sln Added Paths: ----------- branches/nhibernate/ branches/nhibernate/Source/StructureMap/Graph/AssemblyScanner.cs branches/nhibernate/Source/StructureMap/Graph/IAssemblyScanner.cs branches/nhibernate/Source/StructureMap/StructureMap.csproj branches/nhibernate/Source/StructureMap.NHibernate/ branches/nhibernate/Source/StructureMap.NHibernate/NHibernateRegistry.cs branches/nhibernate/bin/FluentNHibernate/ branches/nhibernate/bin/FluentNHibernate/Antlr3.Runtime.dll branches/nhibernate/bin/FluentNHibernate/Castle.Core.dll branches/nhibernate/bin/FluentNHibernate/Castle.Core.xml branches/nhibernate/bin/FluentNHibernate/Castle.DynamicProxy2.dll branches/nhibernate/bin/FluentNHibernate/Castle.DynamicProxy2.xml branches/nhibernate/bin/FluentNHibernate/FluentNHibernate.XML branches/nhibernate/bin/FluentNHibernate/FluentNHibernate.dll branches/nhibernate/bin/FluentNHibernate/FluentNHibernate.pdb branches/nhibernate/bin/FluentNHibernate/Iesi.Collections.dll branches/nhibernate/bin/FluentNHibernate/Iesi.Collections.xml branches/nhibernate/bin/FluentNHibernate/NHibernate.ByteCode.Castle.dll branches/nhibernate/bin/FluentNHibernate/NHibernate.ByteCode.Castle.xml branches/nhibernate/bin/FluentNHibernate/NHibernate.dll branches/nhibernate/bin/FluentNHibernate/NHibernate.xml branches/nhibernate/bin/FluentNHibernate/log4net.dll branches/nhibernate/bin/FluentNHibernate/log4net.xml branches/nhibernate/cruise.build Removed Paths: ------------- branches/nhibernate/Source/StructureMap/Configuration/DSL/AssemblyScannerExtensions.cs branches/nhibernate/Source/StructureMap/Graph/AssemblyScanner.cs branches/nhibernate/Source/StructureMap/Graph/IAssemblyScanner.cs branches/nhibernate/Source/StructureMap/StructureMap.csproj branches/nhibernate/cruise.build Deleted: branches/nhibernate/Source/StructureMap/Configuration/DSL/AssemblyScannerExtensions.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/AssemblyScannerExtensions.cs 2010-02-04 23:30:20 UTC (rev 341) +++ branches/nhibernate/Source/StructureMap/Configuration/DSL/AssemblyScannerExtensions.cs 2010-02-05 03:06:42 UTC (rev 345) @@ -1,63 +0,0 @@ -using System; -using StructureMap.Configuration.DSL.Expressions; -using StructureMap.Graph; - -namespace StructureMap.Configuration.DSL -{ - /// <summary> - /// Extend the assembly scanning DSL to support the built-in registration conventions - /// </summary> - public static class AssemblyScannerExtensions - { - /// <summary> - /// Adds the DefaultConventionScanner to the scanning operations. I.e., a concrete - /// class named "Something" that implements "ISomething" will be automatically - /// added to PluginType "ISomething" - /// </summary> - public static ConfigureConventionExpression WithDefaultConventions(this IAssemblyScanner assemblyScanner) - { - var convention = new DefaultConventionScanner(); - assemblyScanner.With(convention); - return new ConfigureConventionExpression(convention); - } - - /// <summary> - /// Scans for PluginType's and Concrete Types that close the given open generic type - /// </summary> - /// <example> - /// - /// </example> - /// <param name="openGenericType"></param> - public static ConfigureConventionExpression ConnectImplementationsToTypesClosing(this IAssemblyScanner assemblyScanner, Type openGenericType) - { - var convention = new GenericConnectionScanner(openGenericType); - assemblyScanner.With(convention); - return new ConfigureConventionExpression(convention); - } - - /// <summary> - /// Automatically registers all concrete types without primitive arguments - /// against its first interface, if any - /// </summary> - public static ConfigureConventionExpression RegisterConcreteTypesAgainstTheFirstInterface(this IAssemblyScanner assemblyScanner) - { - var convention = new FirstInterfaceConvention(); - assemblyScanner.With(convention); - return new ConfigureConventionExpression(convention); - } - - /// <summary> - /// Directs the scanning to automatically register any type that is the single - /// implementation of an interface against that interface. - /// The filters apply - /// </summary> - public static ConfigureConventionExpression SingleImplementationsOfInterface(this IAssemblyScanner assemblyScanner) - { - var convention = new ImplementationMap(); - assemblyScanner.With(convention); - assemblyScanner.ModifyGraphAfterScan(convention.RegisterSingleImplementations); - return new ConfigureConventionExpression(convention); - } - - } -} \ No newline at end of file Modified: branches/nhibernate/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2010-02-04 23:30:20 UTC (rev 341) +++ branches/nhibernate/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2010-02-05 03:06:42 UTC (rev 345) @@ -205,10 +205,10 @@ /// <returns></returns> public CreatePluginFamilyExpression<PLUGINTYPE> Singleton() { - return lifecycleIs(InstanceScope.Singleton); + return LifecycleIs(InstanceScope.Singleton); } - private CreatePluginFamilyExpression<PLUGINTYPE> lifecycleIs(InstanceScope lifecycle) + public CreatePluginFamilyExpression<PLUGINTYPE> LifecycleIs(InstanceScope lifecycle) { _alterations.Add(family => family.SetScopeTo(lifecycle)); return this; @@ -220,7 +220,7 @@ /// <returns></returns> public CreatePluginFamilyExpression<PLUGINTYPE> HybridHttpOrThreadLocalScoped() { - return lifecycleIs(InstanceScope.Hybrid); + return LifecycleIs(InstanceScope.Hybrid); } /// <summary> @@ -229,7 +229,7 @@ /// <returns></returns> public CreatePluginFamilyExpression<PLUGINTYPE> HttpContextScoped() { - return lifecycleIs(InstanceScope.HttpContext); + return LifecycleIs(InstanceScope.HttpContext); } Deleted: branches/nhibernate/Source/StructureMap/Graph/AssemblyScanner.cs =================================================================== --- trunk/Source/StructureMap/Graph/AssemblyScanner.cs 2010-02-04 23:30:20 UTC (rev 341) +++ branches/nhibernate/Source/StructureMap/Graph/AssemblyScanner.cs 2010-02-05 03:06:42 UTC (rev 345) @@ -1,284 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Reflection; -using StructureMap.Configuration.DSL; -using StructureMap.TypeRules; -using StructureMap.Util; - -namespace StructureMap.Graph -{ - public class TypePool - { - private readonly Cache<Assembly, Type[]> _types = new Cache<Assembly, Type[]>(); - - public TypePool(PluginGraph graph) - { - _types.OnMissing = assembly => - { - try - { - return assembly.GetExportedTypes(); - } - catch (Exception ex) - { - graph.Log.RegisterError(170, ex, assembly.FullName); - return new Type[0]; - } - }; - } - - public IEnumerable<Type> For(IEnumerable<Assembly> assemblies, CompositeFilter<Type> filter) - { - return assemblies.SelectMany(x => _types[x].Where(filter.Matches)); - } - } - - - public class AssemblyScanner : IAssemblyScanner - { - private readonly List<Assembly> _assemblies = new List<Assembly>(); - private readonly List<IRegistrationConvention> _conventions = new List<IRegistrationConvention>(); - private readonly CompositeFilter<Type> _filter = new CompositeFilter<Type>(); - - private readonly List<Action<PluginGraph>> _postScanningActions = new List<Action<PluginGraph>>(); - private readonly List<ITypeScanner> _scanners = new List<ITypeScanner>(); - - public AssemblyScanner() - { - Convention<FamilyAttributeScanner>(); - Convention<PluggableAttributeScanner>(); - } - - public int Count { get { return _assemblies.Count; } } - - - public void Assembly(Assembly assembly) - { - if (!_assemblies.Contains(assembly)) - { - _assemblies.Add(assembly); - } - } - - public void Assembly(string assemblyName) - { - Assembly(AppDomain.CurrentDomain.Load(assemblyName)); - } - - [Obsolete("Replace ITypeScanner with IRegistrationConvention")] - public void With(ITypeScanner scanner) - { - _scanners.Fill(scanner); - } - - [Obsolete("Replace ITypeScanner with IRegistrationConvention")] - public void With<T>() where T : ITypeScanner, new() - { - _scanners.RemoveAll(scanner => scanner is T); - - ITypeScanner previous = _scanners.FirstOrDefault(scanner => scanner is T); - if (previous == null) - { - With(new T()); - } - } - - public void Convention<T>() where T : IRegistrationConvention, new() - { - IRegistrationConvention previous = _conventions.FirstOrDefault(scanner => scanner is T); - if (previous == null) - { - With(new T()); - } - } - - public void LookForRegistries() - { - Convention<FindRegistriesScanner>(); - } - - public void TheCallingAssembly() - { - Assembly callingAssembly = findTheCallingAssembly(); - - if (callingAssembly != null) - { - _assemblies.Add(callingAssembly); - } - } - - public void AssemblyContainingType<T>() - { - _assemblies.Add(typeof (T).Assembly); - } - - public void AssemblyContainingType(Type type) - { - _assemblies.Add(type.Assembly); - } - - public FindAllTypesFilter AddAllTypesOf<PLUGINTYPE>() - { - return AddAllTypesOf(typeof (PLUGINTYPE)); - } - - public FindAllTypesFilter AddAllTypesOf(Type pluginType) - { - var filter = new FindAllTypesFilter(pluginType); - With(filter); - - return filter; - } - - public void IgnoreStructureMapAttributes() - { - _conventions.RemoveAll(scanner => scanner is FamilyAttributeScanner); - _conventions.RemoveAll(scanner => scanner is PluggableAttributeScanner); - } - - - public void Exclude(Func<Type, bool> exclude) - { - _filter.Excludes += exclude; - } - - public void ExcludeNamespace(string nameSpace) - { - Exclude(type => type.IsInNamespace(nameSpace)); - } - - public void ExcludeNamespaceContainingType<T>() - { - ExcludeNamespace(typeof (T).Namespace); - } - - public void Include(Func<Type, bool> predicate) - { - _filter.Includes += predicate; - } - - public void IncludeNamespace(string nameSpace) - { - Include(type => type.IsInNamespace(nameSpace)); - } - - public void IncludeNamespaceContainingType<T>() - { - IncludeNamespace(typeof (T).Namespace); - } - - public void ExcludeType<T>() - { - Exclude(type => type == typeof (T)); - } - - public void ModifyGraphAfterScan(Action<PluginGraph> modifyGraph) - { - _postScanningActions.Add(modifyGraph); - } - - public void AssembliesFromApplicationBaseDirectory() - { - AssembliesFromApplicationBaseDirectory(a => true); - } - - public void AssembliesFromApplicationBaseDirectory(Predicate<Assembly> assemblyFilter) - { - string baseDirectory = AppDomain.CurrentDomain.BaseDirectory; - - AssembliesFromPath(baseDirectory, assemblyFilter); - string binPath = AppDomain.CurrentDomain.SetupInformation.PrivateBinPath; - if (Directory.Exists(binPath)) - { - AssembliesFromPath(binPath, assemblyFilter); - } - } - - public void AssembliesFromPath(string path) - { - AssembliesFromPath(path, a => true); - } - - public void AssembliesFromPath(string path, Predicate<Assembly> assemblyFilter) - { - IEnumerable<string> assemblyPaths = Directory.GetFiles(path) - .Where(file => - Path.GetExtension(file).Equals( - ".exe", - StringComparison.OrdinalIgnoreCase) - || - Path.GetExtension(file).Equals( - ".dll", - StringComparison.OrdinalIgnoreCase)); - - foreach (string assemblyPath in assemblyPaths) - { - Assembly assembly = null; - try - { - assembly = System.Reflection.Assembly.LoadFrom(assemblyPath); - } - catch - { - } - if (assembly != null && assemblyFilter(assembly)) Assembly(assembly); - } - } - - public void With(IRegistrationConvention convention) - { - _conventions.Fill(convention); - } - - internal void ScanForAll(PluginGraph pluginGraph) - { - var registry = new Registry(); - - pluginGraph.Types.For(_assemblies, _filter).Each( - type => - { - _scanners.Each(x => x.Process(type, pluginGraph)); - _conventions.Each(c => c.Process(type, registry)); - }); - - registry.ConfigurePluginGraph(pluginGraph); - _postScanningActions.Each(x => x(pluginGraph)); - } - - - public bool Contains(string assemblyName) - { - foreach (Assembly assembly in _assemblies) - { - if (assembly.GetName().Name == assemblyName) - { - return true; - } - } - - return false; - } - - private static Assembly findTheCallingAssembly() - { - var trace = new StackTrace(false); - - Assembly thisAssembly = System.Reflection.Assembly.GetExecutingAssembly(); - Assembly callingAssembly = null; - for (int i = 0; i < trace.FrameCount; i++) - { - StackFrame frame = trace.GetFrame(i); - Assembly assembly = frame.GetMethod().DeclaringType.Assembly; - if (assembly != thisAssembly) - { - callingAssembly = assembly; - break; - } - } - return callingAssembly; - } - } -} \ No newline at end of file Copied: branches/nhibernate/Source/StructureMap/Graph/AssemblyScanner.cs (from rev 342, trunk/Source/StructureMap/Graph/AssemblyScanner.cs) =================================================================== --- branches/nhibernate/Source/StructureMap/Graph/AssemblyScanner.cs (rev 0) +++ branches/nhibernate/Source/StructureMap/Graph/AssemblyScanner.cs 2010-02-05 03:06:42 UTC (rev 345) @@ -0,0 +1,338 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Reflection; +using StructureMap.Configuration.DSL; +using StructureMap.Configuration.DSL.Expressions; +using StructureMap.TypeRules; +using StructureMap.Util; + +namespace StructureMap.Graph +{ + public class TypePool + { + private readonly Cache<Assembly, Type[]> _types = new Cache<Assembly, Type[]>(); + + public TypePool(PluginGraph graph) + { + _types.OnMissing = assembly => + { + try + { + return assembly.GetExportedTypes(); + } + catch (Exception ex) + { + graph.Log.RegisterError(170, ex, assembly.FullName); + return new Type[0]; + } + }; + } + + public IEnumerable<Type> For(IEnumerable<Assembly> assemblies, CompositeFilter<Type> filter) + { + return assemblies.SelectMany(x => _types[x].Where(filter.Matches)); + } + } + + + public class AssemblyScanner : IAssemblyScanner + { + private readonly List<Assembly> _assemblies = new List<Assembly>(); + private readonly List<IRegistrationConvention> _conventions = new List<IRegistrationConvention>(); + private readonly CompositeFilter<Type> _filter = new CompositeFilter<Type>(); + + private readonly List<Action<PluginGraph>> _postScanningActions = new List<Action<PluginGraph>>(); + private readonly List<ITypeScanner> _scanners = new List<ITypeScanner>(); + + public AssemblyScanner() + { + Convention<FamilyAttributeScanner>(); + Convention<PluggableAttributeScanner>(); + } + + public int Count { get { return _assemblies.Count; } } + + + public void Assembly(Assembly assembly) + { + if (!_assemblies.Contains(assembly)) + { + _assemblies.Add(assembly); + } + } + + public void Assembly(string assemblyName) + { + Assembly(AppDomain.CurrentDomain.Load(assemblyName)); + } + + [Obsolete("Replace ITypeScanner with IRegistrationConvention")] + public void With(ITypeScanner scanner) + { + _scanners.Fill(scanner); + } + + [Obsolete("Replace ITypeScanner with IRegistrationConvention")] + public void With<T>() where T : ITypeScanner, new() + { + _scanners.RemoveAll(scanner => scanner is T); + + ITypeScanner previous = _scanners.FirstOrDefault(scanner => scanner is T); + if (previous == null) + { + With(new T()); + } + } + + public void Convention<T>() where T : IRegistrationConvention, new() + { + IRegistrationConvention previous = _conventions.FirstOrDefault(scanner => scanner is T); + if (previous == null) + { + With(new T()); + } + } + + public void LookForRegistries() + { + Convention<FindRegistriesScanner>(); + } + + public void TheCallingAssembly() + { + Assembly callingAssembly = findTheCallingAssembly(); + + if (callingAssembly != null) + { + _assemblies.Add(callingAssembly); + } + } + + public void AssemblyContainingType<T>() + { + _assemblies.Add(typeof (T).Assembly); + } + + public void AssemblyContainingType(Type type) + { + _assemblies.Add(type.Assembly); + } + + public FindAllTypesFilter AddAllTypesOf<PLUGINTYPE>() + { + return AddAllTypesOf(typeof (PLUGINTYPE)); + } + + public FindAllTypesFilter AddAllTypesOf(Type pluginType) + { + var filter = new FindAllTypesFilter(pluginType); + With(filter); + + return filter; + } + + public void IgnoreStructureMapAttributes() + { + _conventions.RemoveAll(scanner => scanner is FamilyAttributeScanner); + _conventions.RemoveAll(scanner => scanner is PluggableAttributeScanner); + } + + + public void Exclude(Func<Type, bool> exclude) + { + _filter.Excludes += exclude; + } + + public void ExcludeNamespace(string nameSpace) + { + Exclude(type => type.IsInNamespace(nameSpace)); + } + + public void ExcludeNamespaceContainingType<T>() + { + ExcludeNamespace(typeof (T).Namespace); + } + + public void Include(Func<Type, bool> predicate) + { + _filter.Includes += predicate; + } + + public void IncludeNamespace(string nameSpace) + { + Include(type => type.IsInNamespace(nameSpace)); + } + + public void IncludeNamespaceContainingType<T>() + { + IncludeNamespace(typeof (T).Namespace); + } + + public void ExcludeType<T>() + { + Exclude(type => type == typeof (T)); + } + + public void ModifyGraphAfterScan(Action<PluginGraph> modifyGraph) + { + _postScanningActions.Add(modifyGraph); + } + + public void AssembliesFromApplicationBaseDirectory() + { + AssembliesFromApplicationBaseDirectory(a => true); + } + + public void AssembliesFromApplicationBaseDirectory(Predicate<Assembly> assemblyFilter) + { + string baseDirectory = AppDomain.CurrentDomain.BaseDirectory; + + AssembliesFromPath(baseDirectory, assemblyFilter); + string binPath = AppDomain.CurrentDomain.SetupInformation.PrivateBinPath; + if (Directory.Exists(binPath)) + { + AssembliesFromPath(binPath, assemblyFilter); + } + } + + public void AssembliesFromPath(string path) + { + AssembliesFromPath(path, a => true); + } + + public void AssembliesFromPath(string path, Predicate<Assembly> assemblyFilter) + { + IEnumerable<string> assemblyPaths = Directory.GetFiles(path) + .Where(file => + Path.GetExtension(file).Equals( + ".exe", + StringComparison.OrdinalIgnoreCase) + || + Path.GetExtension(file).Equals( + ".dll", + StringComparison.OrdinalIgnoreCase)); + + foreach (string assemblyPath in assemblyPaths) + { + Assembly assembly = null; + try + { + assembly = System.Reflection.Assembly.LoadFrom(assemblyPath); + } + catch + { + } + if (assembly != null && assemblyFilter(assembly)) Assembly(assembly); + } + } + + public void With(IRegistrationConvention convention) + { + _conventions.Fill(convention); + } + + internal void ScanForAll(PluginGraph pluginGraph) + { + var registry = new Registry(); + + pluginGraph.Types.For(_assemblies, _filter).Each( + type => + { + _scanners.Each(x => x.Process(type, pluginGraph)); + _conventions.Each(c => c.Process(type, registry)); + }); + + registry.ConfigurePluginGraph(pluginGraph); + _postScanningActions.Each(x => x(pluginGraph)); + } + + + public bool Contains(string assemblyName) + { + foreach (Assembly assembly in _assemblies) + { + if (assembly.GetName().Name == assemblyName) + { + return true; + } + } + + return false; + } + + private static Assembly findTheCallingAssembly() + { + var trace = new StackTrace(false); + + Assembly thisAssembly = System.Reflection.Assembly.GetExecutingAssembly(); + Assembly callingAssembly = null; + for (int i = 0; i < trace.FrameCount; i++) + { + StackFrame frame = trace.GetFrame(i); + Assembly assembly = frame.GetMethod().DeclaringType.Assembly; + if (assembly != thisAssembly) + { + callingAssembly = assembly; + break; + } + } + return callingAssembly; + } + + + + /// <summary> + /// Adds the DefaultConventionScanner to the scanning operations. I.e., a concrete + /// class named "Something" that implements "ISomething" will be automatically + /// added to PluginType "ISomething" + /// </summary> + public ConfigureConventionExpression WithDefaultConventions() + { + var convention = new DefaultConventionScanner(); + With(convention); + return new ConfigureConventionExpression(convention); + } + + /// <summary> + /// Scans for PluginType's and Concrete Types that close the given open generic type + /// </summary> + /// <example> + /// + /// </example> + /// <param name="openGenericType"></param> + public ConfigureConventionExpression ConnectImplementationsToTypesClosing(Type openGenericType) + { + var convention = new GenericConnectionScanner(openGenericType); + With(convention); + return new ConfigureConventionExpression(convention); + } + + /// <summary> + /// Automatically registers all concrete types without primitive arguments + /// against its first interface, if any + /// </summary> + public ConfigureConventionExpression RegisterConcreteTypesAgainstTheFirstInterface() + { + var convention = new FirstInterfaceConvention(); + With(convention); + return new ConfigureConventionExpression(convention); + } + + /// <summary> + /// Directs the scanning to automatically register any type that is the single + /// implementation of an interface against that interface. + /// The filters apply + /// </summary> + public ConfigureConventionExpression SingleImplementationsOfInterface() + { + var convention = new ImplementationMap(); + With(convention); + ModifyGraphAfterScan(convention.RegisterSingleImplementations); + return new ConfigureConventionExpression(convention); + } + + } +} \ No newline at end of file Deleted: branches/nhibernate/Source/StructureMap/Graph/IAssemblyScanner.cs =================================================================== --- trunk/Source/StructureMap/Graph/IAssemblyScanner.cs 2010-02-04 23:30:20 UTC (rev 341) +++ branches/nhibernate/Source/StructureMap/Graph/IAssemblyScanner.cs 2010-02-05 03:06:42 UTC (rev 345) @@ -1,182 +0,0 @@ -using System; -using System.Reflection; -using StructureMap.Configuration.DSL.Expressions; - -namespace StructureMap.Graph -{ - public interface IAssemblyScanner - { - #region Designating Assemblies - - /// <summary> - /// Add an Assembly to the scanning operation - /// </summary> - /// <param name="assembly"></param> - void Assembly(Assembly assembly); - - /// <summary> - /// Add an Assembly by name to the scanning operation - /// </summary> - /// <param name="assemblyName"></param> - void Assembly(string assemblyName); - - /// <summary> - /// Add the currently executing Assembly to the scanning operation - /// </summary> - void TheCallingAssembly(); - - /// <summary> - /// Add the Assembly that contains type T to the scanning operation - /// </summary> - /// <typeparam name="T"></typeparam> - void AssemblyContainingType<T>(); - - /// <summary> - /// Add the Assembly that contains type to the scanning operation - /// </summary> - /// <param name="type"></param> - void AssemblyContainingType(Type type); - - /// <summary> - /// Sweep the designated path and add any Assembly's found in this folder to the - /// scanning operation - /// </summary> - /// <param name="path"></param> - void AssembliesFromPath(string path); - - /// <summary> - /// Sweep the designated path and add any Assembly's found in this folder to the - /// scanning operation. The assemblyFilter can be used to filter or limit the - /// Assembly's that are picked up. - /// </summary> - /// <param name="path"></param> - /// <param name="assemblyFilter"></param> - void AssembliesFromPath(string path, Predicate<Assembly> assemblyFilter); - - /// <summary> - /// Sweep the application base directory of current app domain and add any Assembly's - /// found to the scanning operation. - /// </summary> - void AssembliesFromApplicationBaseDirectory(); - - /// <summary> - /// Sweep the application base directory of current app domain and add any Assembly's - /// found to the scanning operation. The assemblyFilter can be used to filter or limit the - /// Assembly's that are picked up. - /// </summary> - void AssembliesFromApplicationBaseDirectory(Predicate<Assembly> assemblyFilter); - - #endregion - - #region Adding TypeScanners - - /// <summary> - /// Adds an ITypeScanner object to the scanning operation - /// </summary> - /// <param name="scanner"></param> - void With(ITypeScanner scanner); - - /// <summary> - /// Creates and adds a new ITypeScanner of type T to this scanning operation - /// </summary> - /// <typeparam name="T"></typeparam> - void With<T>() where T : ITypeScanner, new(); - - #endregion - - #region Other options - - /// <summary> - /// Directs the scanning operation to automatically detect and include any Registry - /// classes found in the Assembly's being scanned - /// </summary> - void LookForRegistries(); - - /// <summary> - /// Add all concrete types of the Plugin Type as Instances of Plugin Type - /// </summary> - /// <typeparam name="PLUGINTYPE"></typeparam> - FindAllTypesFilter AddAllTypesOf<PLUGINTYPE>(); - - /// <summary> - /// Add all concrete types of the Plugin Type as Instances of Plugin Type - /// </summary> - /// <param name="pluginType"></param> - FindAllTypesFilter AddAllTypesOf(Type pluginType); - - /// <summary> - /// Makes this scanning operation ignore all [PluginFamily] and [Pluggable] attributes - /// </summary> - void IgnoreStructureMapAttributes(); - - #endregion - - #region Filtering types - - /// <summary> - /// Exclude types that match the Predicate from being scanned - /// </summary> - /// <param name="exclude"></param> - void Exclude(Func<Type, bool> exclude); - - /// <summary> - /// Exclude all types in this nameSpace or its children from the scanning operation - /// </summary> - /// <param name="nameSpace"></param> - void ExcludeNamespace(string nameSpace); - - /// <summary> - /// Exclude all types in this nameSpace or its children from the scanning operation - /// </summary> - /// <typeparam name="T"></typeparam> - void ExcludeNamespaceContainingType<T>(); - - /// <summary> - /// Only include types matching the Predicate in the scanning operation. You can - /// use multiple Include() calls in a single scanning operation - /// </summary> - /// <param name="predicate"></param> - void Include(Func<Type, bool> predicate); - - /// <summary> - /// Only include types from this nameSpace or its children in the scanning operation. You can - /// use multiple Include() calls in a single scanning operation - /// </summary> - /// <param name="nameSpace"></param> - void IncludeNamespace(string nameSpace); - - /// <summary> - /// Only include types from this nameSpace or its children in the scanning operation. You can - /// use multiple Include() calls in a single scanning operation - /// </summary> - /// <typeparam name="T"></typeparam> - void IncludeNamespaceContainingType<T>(); - - /// <summary> - /// Exclude this specific type from the scanning operation - /// </summary> - /// <typeparam name="T"></typeparam> - void ExcludeType<T>(); - - // ... Other methods - - #endregion - - // ... Other methods - - /// <summary> - /// Adds a registration convention to be applied to all the types in this - /// logical "scan" operation - /// </summary> - /// <typeparam name="T"></typeparam> - void Convention<T>() where T : IRegistrationConvention, new(); - - /// <summary> - /// Adds a registration convention to be applied to all the types in this - /// logical "scan" operation - /// </summary> - void With(IRegistrationConvention convention); - - void ModifyGraphAfterScan(Action<PluginGraph> modifyGraph); - } -} \ No newline at end of file Copied: branches/nhibernate/Source/StructureMap/Graph/IAssemblyScanner.cs (from rev 342, trunk/Source/StructureMap/Graph/IAssemblyScanner.cs) =================================================================== --- branches/nhibernate/Source/StructureMap/Graph/IAssemblyScanner.cs (rev 0) +++ branches/nhibernate/Source/StructureMap/Graph/IAssemblyScanner.cs 2010-02-05 03:06:42 UTC (rev 345) @@ -0,0 +1,211 @@ +using System; +using System.Reflection; +using StructureMap.Configuration.DSL.Expressions; + +namespace StructureMap.Graph +{ + public interface IAssemblyScanner + { + #region Designating Assemblies + + /// <summary> + /// Add an Assembly to the scanning operation + /// </summary> + /// <param name="assembly"></param> + void Assembly(Assembly assembly); + + /// <summary> + /// Add an Assembly by name to the scanning operation + /// </summary> + /// <param name="assemblyName"></param> + void Assembly(string assemblyName); + + /// <summary> + /// Add the currently executing Assembly to the scanning operation + /// </summary> + void TheCallingAssembly(); + + /// <summary> + /// Add the Assembly that contains type T to the scanning operation + /// </summary> + /// <typeparam name="T"></typeparam> + void AssemblyContainingType<T>(); + + /// <summary> + /// Add the Assembly that contains type to the scanning operation + /// </summary> + /// <param name="type"></param> + void AssemblyContainingType(Type type); + + /// <summary> + /// Sweep the designated path and add any Assembly's found in this folder to the + /// scanning operation + /// </summary> + /// <param name="path"></param> + void AssembliesFromPath(string path); + + /// <summary> + /// Sweep the designated path and add any Assembly's found in this folder to the + /// scanning operation. The assemblyFilter can be used to filter or limit the + /// Assembly's that are picked up. + /// </summary> + /// <param name="path"></param> + /// <param name="assemblyFilter"></param> + void AssembliesFromPath(string path, Predicate<Assembly> assemblyFilter); + + /// <summary> + /// Sweep the application base directory of current app domain and add any Assembly's + /// found to the scanning operation. + /// </summary> + void AssembliesFromApplicationBaseDirectory(); + + /// <summary> + /// Sweep the application base directory of current app domain and add any Assembly's + /// found to the scanning operation. The assemblyFilter can be used to filter or limit the + /// Assembly's that are picked up. + /// </summary> + void AssembliesFromApplicationBaseDirectory(Predicate<Assembly> assemblyFilter); + + #endregion + + #region Adding TypeScanners + + /// <summary> + /// Adds an ITypeScanner object to the scanning operation + /// </summary> + /// <param name="scanner"></param> + void With(ITypeScanner scanner); + + /// <summary> + /// Creates and adds a new ITypeScanner of type T to this scanning operation + /// </summary> + /// <typeparam name="T"></typeparam> + void With<T>() where T : ITypeScanner, new(); + + #endregion + + #region Other options + + /// <summary> + /// Directs the scanning operation to automatically detect and include any Registry + /// classes found in the Assembly's being scanned + /// </summary> + void LookForRegistries(); + + /// <summary> + /// Add all concrete types of the Plugin Type as Instances of Plugin Type + /// </summary> + /// <typeparam name="PLUGINTYPE"></typeparam> + FindAllTypesFilter AddAllTypesOf<PLUGINTYPE>(); + + /// <summary> + /// Add all concrete types of the Plugin Type as Instances of Plugin Type + /// </summary> + /// <param name="pluginType"></param> + FindAllTypesFilter AddAllTypesOf(Type pluginType); + + /// <summary> + /// Makes this scanning operation ignore all [PluginFamily] and [Pluggable] attributes + /// </summary> + void IgnoreStructureMapAttributes(); + + #endregion + + #region Filtering types + + /// <summary> + /// Exclude types that match the Predicate from being scanned + /// </summary> + /// <param name="exclude"></param> + void Exclude(Func<Type, bool> exclude); + + /// <summary> + /// Exclude all types in this nameSpace or its children from the scanning operation + /// </summary> + /// <param name="nameSpace"></param> + void ExcludeNamespace(string nameSpace); + + /// <summary> + /// Exclude all types in this nameSpace or its children from the scanning operation + /// </summary> + /// <typeparam name="T"></typeparam> + void ExcludeNamespaceContainingType<T>(); + + /// <summary> + /// Only include types matching the Predicate in the scanning operation. You can + /// use multiple Include() calls in a single scanning operation + /// </summary> + /// <param name="predicate"></param> + void Include(Func<Type, bool> predicate); + + /// <summary> + /// Only include types from this nameSpace or its children in the scanning operation. You can + /// use multiple Include() calls in a single scanning operation + /// </summary> + /// <param name="nameSpace"></param> + void IncludeNamespace(string nameSpace); + + /// <summary> + /// Only include types from this nameSpace or its children in the scanning operation. You can + /// use multiple Include() calls in a single scanning operation + /// </summary> + /// <typeparam name="T"></typeparam> + void IncludeNamespaceContainingType<T>(); + + /// <summary> + /// Exclude this specific type from the scanning operation + /// </summary> + /// <typeparam name="T"></typeparam> + void ExcludeType<T>(); + + // ... Other methods + + #endregion + + // ... Other methods + + /// <summary> + /// Adds a registration convention to be applied to all the types in this + /// logical "scan" operation + /// </summary> + /// <typeparam name="T"></typeparam> + void Convention<T>() where T : IRegistrationConvention, new(); + + /// <summary> + /// Adds a registration convention to be applied to all the types in this + /// logical "scan" operation + /// </summary> + void With(IRegistrationConvention convention); + + void ModifyGraphAfterScan(Action<PluginGraph> modifyGraph); + + /// <summary> + /// Adds the DefaultConventionScanner to the scanning operations. I.e., a concrete + /// class named "Something" that implements "ISomething" will be automatically + /// added to PluginType "ISomething" + /// </summary> + ConfigureConventionExpression WithDefaultConventions(); + + /// <summary> + /// Scans for PluginType's and Concrete Types that close the given open generic type + /// </summary> + /// <example> + /// + /// </example> + /// <param name="openGenericType"></param> + ConfigureConventionExpression ConnectImplementationsToTypesClosing(Type openGenericType); + + /// <summary> + /// Automatically registers all concrete types without primitive arguments + /// against its first interface, if any + /// </summary> + ConfigureConventionExpression RegisterConcreteTypesAgainstTheFirstInterface(); + + /// <summary> + /// Directs the scanning to automatically register any type that is the single + /// implementation of an interface against that interface. + /// The filters apply + /// </summary> + ConfigureConventionExpression SingleImplementationsOfInterface(); + } +} \ No newline at end of file Deleted: branches/nhibernate/Source/StructureMap/StructureMap.csproj =================================================================== --- trunk/Source/StructureMap/StructureMap.csproj 2010-02-04 23:30:20 UTC (rev 341) +++ branches/nhibernate/Source/StructureMap/StructureMap.csproj 2010-02-05 03:06:42 UTC (rev 345) @@ -1,444 +0,0 @@ -<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5"> - <PropertyGroup> - <ProjectType>Local</ProjectType> - <ProductVersion>9.0.30729</ProductVersion> - <SchemaVersion>2.0</SchemaVersion> - <ProjectGuid>{3F36EA80-2F9A-4DAD-BA27-5AC6163A2EE3}</ProjectGuid> - <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> - <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> - <ApplicationIcon> - </ApplicationIcon> - <AssemblyKeyContainerName> - </AssemblyKeyContainerName> - <AssemblyName>StructureMap</AssemblyName> - <AssemblyOriginatorKeyFile>..\structuremap.snk</AssemblyOriginatorKeyFile> - <DefaultClientScript>JScript</DefaultClientScript> - <DefaultHTMLPageLayout>Grid</DefaultHTMLPageLayout> - <DefaultTargetSchema>IE50</DefaultTargetSchema> - <DelaySign>false</DelaySign> - <OutputType>Library</OutputType> - <RootNamespace>StructureMap</RootNamespace> - <RunPostBuildEvent>OnBuildSuccess</RunPostBuildEvent> - <StartupObject> - </StartupObject> - <FileUpgradeFlags> - </FileUpgradeFlags> - <UpgradeBackupLocation> - </UpgradeBackupLocation> - <SignAssembly>true</SignAssembly> - <OldToolsVersion>2.0</OldToolsVersion> - <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> - <PublishUrl>publish\</PublishUrl> - <Install>true</Install> - <InstallFrom>Disk</InstallFrom> - <UpdateEnabled>false</UpdateEnabled> - <UpdateMode>Foreground</UpdateMode> - <UpdateInterval>7</UpdateInterval> - <UpdateIntervalUnits>Days</UpdateIntervalUnits> - <UpdatePeriodically>false</UpdatePeriodically> - <UpdateRequired>false</UpdateRequired> - <MapFileExtensions>true</MapFileExtensions> - <ApplicationRevision>0</ApplicationRevision> - <ApplicationVersion>1.0.0.%2a</ApplicationVersion> - <IsWebBootstrapper>false</IsWebBootstrapper> - <UseApplicationTrust>false</UseApplicationTrust> - <BootstrapperEnabled>true</BootstrapperEnabled> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> - <OutputPath>bin\Debug\</OutputPath> - <AllowUnsafeBlocks>false</AllowUnsafeBlocks> - <BaseAddress>285212672</BaseAddress> - <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow> - <ConfigurationOverrideFile> - </ConfigurationOverrideFile> - <DefineConstants>DEBUG;TRACE</DefineConstants> - <DocumentationFile>bin\Debug\StructureMap.XML</DocumentationFile> - <DebugSymbols>true</DebugSymbols> - <FileAlignment>4096</FileAlignment> - <NoStdLib>false</NoStdLib> - <NoWarn>618,1591,1573,1711,1570</NoWarn> - <Optimize>false</Optimize> - <RegisterForComInterop>false</RegisterForComInterop> - <RemoveIntegerChecks>false</RemoveIntegerChecks> - <TreatWarningsAsErrors>false</TreatWarningsAsErrors> - <WarningLevel>4</WarningLevel> - <DebugType>full</DebugType> - <ErrorReport>prompt</ErrorReport> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> - <OutputPath>bin\Release\</OutputPath> - <AllowUnsafeBlocks>false</AllowUnsafeBlocks> - <BaseAddress>285212672</BaseAddress> - <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow> - <ConfigurationOverrideFile> - </ConfigurationOverrideFile> - <DefineConstants>TRACE</DefineConstants> - <DocumentationFile>bin\Release\StructureMap.XML</DocumentationFile> - <DebugSymbols>true</DebugSymbols> - <FileAlignment>4096</FileAlignment> - <NoStdLib>false</NoStdLib> - <NoWarn>618,1591,1573,1711,1570</NoWarn> - <Optimize>true</Optimize> - <RegisterForComInterop>false</RegisterForComInterop> - <RemoveIntegerChecks>false</RemoveIntegerChecks> - <TreatWarningsAsErrors>true</TreatWarningsAsErrors> - <WarningLevel>4</WarningLevel> - <DebugType>pdbonly</DebugType> - <ErrorReport>prompt</ErrorReport> - </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Build|AnyCPU' "> - <OutputPath>..\..\build\StructureMap\</OutputPath> - <AllowUnsafeBlocks>false</AllowUnsafeBlocks> - <BaseAddress>285212672</BaseAddress> - <CheckForOverflowUnderflow>false</CheckForOverflowUnderflow> - <ConfigurationOverrideFile> - </ConfigurationOverrideFile> - <DefineConstants>DEBUG;TRACE</DefineConstants> - <DocumentationFile>StructureMap.xml</DocumentationFile> - <DebugSymbols>true</DebugSymbols> - <FileAlignment>4096</FileAlignment> - <NoStdLib>false</NoStdLib> - <NoWarn>618, 1591</NoWarn> - <Optimize>false</Optimize> - <RegisterForComInterop>false</RegisterForComInterop> - <RemoveIntegerChecks>false</RemoveIntegerChecks> - <TreatWarningsAsErrors>false</TreatWarningsAsErrors> - <WarningLevel>4</WarningLevel> - <DebugType>full</DebugType> - <ErrorReport>prompt</ErrorReport> - </PropertyGroup> - <ItemGroup> - <Reference Include="System"> - <Name>System</Name> - </Reference> - <Reference Include="System.configuration" /> - <Reference Include="System.Core"> - <RequiredTargetFramework>3.5</RequiredTargetFramework> - </Reference> - <Reference Include="System.Data"> - <Name>System.Data</Name> - </Reference> - <Reference Include="System.Web"> - <Name>System.Web</Name> - </Reference> - <Reference Include="System.Xml"> - <Name>System.XML</Name> - </Reference> - </ItemGroup> - <ItemGroup> - <Compile Include="..\CommonAssemblyInfo.cs"> - <Link>CommonAssemblyInfo.cs</Link> - <SubType>Code</SubType> - </Compile> - <Compile Include="BuildSession.cs" /> - <Compile Include="Configuration\DSL\Expressions\GenericFamilyExpression.cs" /> - <Compile Include="Configuration\ProfileBuilder.cs" /> - <Compile Include="Diagnostics\BuildError.cs" /> - <Compile Include="Diagnostics\CharacterWidth.cs" /> - <Compile Include="Diagnostics\DividerLine.cs" /> - <Compile Include="Diagnostics\Error.cs" /> - <Compile Include="Diagnostics\ErrorCollection.cs" /> - <Compile Include="Diagnostics\GraphLog.cs" /> - <Compile Include="Diagnostics\InstanceToken.cs" /> - <Compile Include="Diagnostics\Line.cs" /> - <Compile Include="Diagnostics\TextLine.cs" /> - <Compile Include="Diagnostics\TextReportWriter.cs" /> - <Compile Include="Diagnostics\WhatDoIHaveWriter.cs" /> - <Compile Include="Exceptions\StructureMapConfigurationException.cs" /> - <Compile Include="ExplicitArgsExpression.cs" /> - <Compile Include="Graph\Constructor.cs" /> - <Compile Include="Graph\IArgumentVisitor.cs" /> - <Compile Include="Graph\IPluginFamily.cs" /> - <Compile Include="Graph\AssemblyScanner.cs" /> - <Compile Include="InstanceCache.cs" /> - <Compile Include="Interceptors\MatchedTypeInterceptor.cs" /> - <Compile Include="PipelineGraph.cs" /> - <Compile Include="Pipeline\ConfiguredInstance.cs" /> - <Compile Include="Pipeline\ConfiguredInstance.Expressions.cs" /> - <Compile Include="Pipeline\LambdaInstance.cs" /> - <Compile Include="Pipeline\DefaultInstance.cs" /> - <Compile Include="Pipeline\IConfiguredInstance.cs" /> - <Compile Include="Pipeline\ILocationPolicy.cs" /> - <Compile Include="Pipeline\Instance.cs" /> - <Compile Include="Pipeline\InstanceMementoPropertyReader.cs" /> - <Compile Include="Pipeline\ObjectInstance.cs" /> - <Compile Include="Pipeline\Profile.cs" /> - <Compile Include="Pipeline\ProfileManager.cs" /> - <Compile Include="Pipeline\PrototypeInstance.cs" /> - <Compile Include="Pipeline\ReferencedInstance.cs" /> - <Compile Include="Pipeline\UserControlInstance.cs" /> - <Compile Include="Properties\AssemblyInfo.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Attributes\DefaultConstructorAttribute.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="InstanceScope.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Attributes\PluggableAttribute.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Attributes\PluginFamilyAttribute.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Attributes\SetterPropertyAttribute.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Attributes\ValidationMethodAttribute.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Configuration\ConfigurationConstants.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Configuration\ConfigurationParser.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Configuration\ConfigurationParserBuilder.cs" /> - <Compile Include="Configuration\DSL\Expressions\CreatePluginFamilyExpression.cs" /> - <Compile Include="Configuration\DSL\ExpressionValidator.cs" /> - <Compile Include="Pipeline\ExplicitArguments.cs" /> - <Compile Include="Configuration\DSL\Expressions\ProfileExpression.cs" /> - <Compile Include="Configuration\DSL\Registry.cs" /> - <Compile Include="Configuration\FamilyParser.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Configuration\IGraphBuilder.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Configuration\GraphBuilder.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Configuration\ProfileAndMachineParser.cs" /> - <Compile Include="Configuration\StructureMapConfigurationSection.cs" /> - <Compile Include="Configuration\XmlConstants.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Exceptions\InstancePropertyValueException.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Exceptions\MissingPluginFamilyException.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Exceptions\StructureMapException.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Graph\GenericsPluginGraph.cs" /> - <Compile Include="Graph\Plugin.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Graph\PluginFamily.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Graph\PluginFamilyCollection.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Graph\PluginGraph.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Graph\SetterProperty.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Graph\SetterPropertyCollection.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Graph\TypePath.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="IInstanceFactory.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="IContainer.cs" /> - <Compile Include="InstanceFactory.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Container.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="InstanceMemento.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Interceptors\CompoundInterceptor.cs" /> - <Compile Include="Interceptors\EnrichmentInterceptor.cs" /> - <Compile Include="Interceptors\InstanceInterceptor.cs" /> - <Compile Include="Interceptors\InterceptorLibrary.cs" /> - <Compile Include="Interceptors\Interceptors.cs" /> - <Compile Include="Interceptors\NulloInterceptor.cs" /> - <Compile Include="Interceptors\StartupInterceptor.cs" /> - <Compile Include="Interceptors\FilteredInstanceInterceptor.cs" /> - <Compile Include="MementoSource.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="MemoryInstanceMemento.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="ObjectFactory.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="PluginGraphBuilder.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Source\BasicXmlMementoSource.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Source\DirectoryXmlMementoSource.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Source\EmbeddedFolderXmlMementoSource.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Source\MementoSourceType.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Source\MemoryMementoSource.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Source\SingleEmbeddedXmlMementoSource.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Source\TemplatedMementoSource.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Source\XmlAttributeFileMementoSource.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Source\XmlAttributeInstanceMemento.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Source\XmlFileMementoSource.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Source\XmlMementoCreator.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Source\XmlMementoSource.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Source\XmlMementoStyle.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Source\XmlNodeInstanceMemento.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Source\XmlTemplater.cs"> - <SubType>Code</SubType> - </Compile> - <Compile Include="Diagnostics\ValidationBuildSession.cs" /> - <EmbeddedResource Include="StructureMapException.resx"> - <SubType>Designer</SubType> - </EmbeddedResource> - </ItemGroup> - <ItemGroup> - <None Include="..\structuremap.snk"> - <Link>Properties\structuremap.snk</Link> - </None> - <None Include="ConfigurationClasses.cd" /> - <Compile Include="CloseGenericTypeExpression.cs" /> - <Compile Include="ConfigurationExpression.cs" /> - <Compile Include="Configuration\DictionaryReader.cs" /> - <Compile Include="Configuration\DSL\AssemblyScannerExtensions.cs" /> - <Compile Include="Configuration\DSL\Expressions\InstanceExpression.cs" /> - <Compile Include="Configuration\DSL\IRegistry.cs" /> - <Compile Include="Configuration\DSL\SetterConvention.cs" /> - <Compile Include="Configuration\ITypeReader.cs" /> - <Compile Include="Configuration\PrimitiveArrayReader.cs" /> - <Compile Include="Configuration\TypeReaderFactory.cs" /> - <Compile Include="Configuration\XmlExtensions.cs" /> - <Compile Include="Construction\BuilderCompiler.cs" /> - <Compile Include="Construction\ConstructorFunctionBuilder.cs" /> - <Compile Include="Construction\IArguments.cs" /> - <Compile Include="Construction\InstanceBuilder.cs" /> - <Compile Include="Construction\SetterBuilder.cs" /> - <Compile Include="Diagnostics\Doctor.cs" /> - <Compile Include="Diagnostics\DoctorReport.cs" /> - <Compile Include="Diagnostics\DoctorResult.cs" /> - <Compile Include="Diagnostics\DoctorRunner.cs" /> - <Compile Include="Diagnostics\ValidationError.cs" /> - <Compile Include="ErrorMessages.cs" /> - <Compile Include="Example.cs" /> - <Compile Include="Extensions.cs" /> - <Compile Include="Graph\CompositeFilter.cs" /> - <Compile Include="Graph\CompositePredicate.cs" /> - <Compile Include="Configuration\DSL\Expressions\ConfigureConventionExpression.cs" /> - <Compile Include="Graph\FamilyAttributeScanner.cs" /> - <Compile Include="Graph\FindAllTypesFilter.cs" /> - <Compile Include="Graph\FindRegistriesScanner.cs" /> - <Compile Include="Graph\FirstInterfaceConvention.cs" /> - <Compile Include="Graph\IAssemblyScanner.cs" /> - <Compile Include="Graph\ImplementationMap.cs" /> - <Compile Include="Graph\IRegistrationConvention.cs" /> - <Compile Include="Graph\ITypeScanner.cs" /> - <Compile Include="Graph\PluggableAttributeScanner.cs" /> - <Compile Include="Graph\PluginCache.cs" /> - <Compile Include="IContext.cs" /> - <Compile Include="Pipeline\AdapterClasses.cs" /> - <Compile Include="Pipeline\HybridLifecycle.cs" /> - <Compile Include="Query\EmptyConfiguration.cs" /> - <Compile Include="Query\GenericFamilyConfiguration.cs" /> - <Compile Include="Query\IFamily.cs" /> - <Compile Include="Query\IModel.cs" /> - <Compile Include="Pipeline\Arguments.cs" /> - <Compile Include="Pipeline\ArrayCoercion.cs" /> - <Compile Include="Pipeline\ConditionalInstance.cs" /> - <Compile Include="Pipeline\ConstructorInstance.cs" /> - <Compile Include="Pipeline\EnumerableInstance.cs" /> - <Compile Include="Pipeline\HttpContextLifecycle.cs" /> - <Compile Include="Pipeline\HttpLifecycleBase.cs" /> - <Compile Include="Pipeline\HttpSessionLifecycle.cs" /> - <Compile Include="Pipeline\HybridSessionLifecycle.cs" /> - <Compile Include="Pipeline\IEnumerableCoercion.cs" /> - <Compile Include="Pipeline\ILifecycle.cs" /> - <Compile Include="Pipeline\IObjectCache.cs" /> - <Compile Include="Pipeline\Lifecycles.cs" /> - <Compile Include="Pipeline\ListCoercion.cs" /> - <Compile Include="Pipeline\MainObjectCache.cs" /> - <Compile Include="Pipeline\NulloObjectCache.cs" /> - <Compile Include="Pipeline\ObjectBuilder.cs" /> - <Compile Include="Pipeline\SessionWrapper.cs" /> - <Compile Include="Pipeline\SingletonLifecycle.cs" /> - <Compile Include="Pipeline\ThreadLocalStorageLifecycle.cs" /> - <Compile Include="Pipeline\UniquePerRequestLifecycle.cs" /> - <Compile ... [truncated message content] |
From: <jer...@us...> - 2010-02-05 01:24:38
|
Revision: 344 http://structuremap.svn.sourceforge.net/structuremap/?rev=344&view=rev Author: jeremydmiller Date: 2010-02-05 01:24:32 +0000 (Fri, 05 Feb 2010) Log Message: ----------- updating cruise.build to show the 2.6.2 version. Modified Paths: -------------- trunk/cruise.build Modified: trunk/cruise.build =================================================================== --- trunk/cruise.build 2010-02-05 01:23:44 UTC (rev 343) +++ trunk/cruise.build 2010-02-05 01:24:32 UTC (rev 344) @@ -4,7 +4,7 @@ <property name="deployment.dir" value="source\StructureMap.Testing.DeploymentTasks\"/> <property name="results.dir" value="results" /> <property name="nant.dir" value="bin\nant" /> - <property name="project.version" value="2.6.1" /> + <property name="project.version" value="2.6.2" /> <property name="project.config" value="release" /> <property name="archive.dir" value="archive"/> <target name="all" depends="compile, unit-test, post-clean"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2010-02-05 01:23:52
|
Revision: 343 http://structuremap.svn.sourceforge.net/structuremap/?rev=343&view=rev Author: jeremydmiller Date: 2010-02-05 01:23:44 +0000 (Fri, 05 Feb 2010) Log Message: ----------- made a copy Added Paths: ----------- branches/2.6.1/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2010-02-05 01:17:08
|
Revision: 342 http://structuremap.svn.sourceforge.net/structuremap/?rev=342&view=rev Author: jeremydmiller Date: 2010-02-05 01:16:22 +0000 (Fri, 05 Feb 2010) Log Message: ----------- Pushed the AssemblyScannerExtensions back into real methods Modified Paths: -------------- trunk/Source/StructureMap/Graph/AssemblyScanner.cs trunk/Source/StructureMap/Graph/IAssemblyScanner.cs trunk/Source/StructureMap/StructureMap.csproj trunk/cruise.build Removed Paths: ------------- trunk/Source/StructureMap/Configuration/DSL/AssemblyScannerExtensions.cs Deleted: trunk/Source/StructureMap/Configuration/DSL/AssemblyScannerExtensions.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/AssemblyScannerExtensions.cs 2010-02-04 23:30:20 UTC (rev 341) +++ trunk/Source/StructureMap/Configuration/DSL/AssemblyScannerExtensions.cs 2010-02-05 01:16:22 UTC (rev 342) @@ -1,63 +0,0 @@ -using System; -using StructureMap.Configuration.DSL.Expressions; -using StructureMap.Graph; - -namespace StructureMap.Configuration.DSL -{ - /// <summary> - /// Extend the assembly scanning DSL to support the built-in registration conventions - /// </summary> - public static class AssemblyScannerExtensions - { - /// <summary> - /// Adds the DefaultConventionScanner to the scanning operations. I.e., a concrete - /// class named "Something" that implements "ISomething" will be automatically - /// added to PluginType "ISomething" - /// </summary> - public static ConfigureConventionExpression WithDefaultConventions(this IAssemblyScanner assemblyScanner) - { - var convention = new DefaultConventionScanner(); - assemblyScanner.With(convention); - return new ConfigureConventionExpression(convention); - } - - /// <summary> - /// Scans for PluginType's and Concrete Types that close the given open generic type - /// </summary> - /// <example> - /// - /// </example> - /// <param name="openGenericType"></param> - public static ConfigureConventionExpression ConnectImplementationsToTypesClosing(this IAssemblyScanner assemblyScanner, Type openGenericType) - { - var convention = new GenericConnectionScanner(openGenericType); - assemblyScanner.With(convention); - return new ConfigureConventionExpression(convention); - } - - /// <summary> - /// Automatically registers all concrete types without primitive arguments - /// against its first interface, if any - /// </summary> - public static ConfigureConventionExpression RegisterConcreteTypesAgainstTheFirstInterface(this IAssemblyScanner assemblyScanner) - { - var convention = new FirstInterfaceConvention(); - assemblyScanner.With(convention); - return new ConfigureConventionExpression(convention); - } - - /// <summary> - /// Directs the scanning to automatically register any type that is the single - /// implementation of an interface against that interface. - /// The filters apply - /// </summary> - public static ConfigureConventionExpression SingleImplementationsOfInterface(this IAssemblyScanner assemblyScanner) - { - var convention = new ImplementationMap(); - assemblyScanner.With(convention); - assemblyScanner.ModifyGraphAfterScan(convention.RegisterSingleImplementations); - return new ConfigureConventionExpression(convention); - } - - } -} \ No newline at end of file Modified: trunk/Source/StructureMap/Graph/AssemblyScanner.cs =================================================================== --- trunk/Source/StructureMap/Graph/AssemblyScanner.cs 2010-02-04 23:30:20 UTC (rev 341) +++ trunk/Source/StructureMap/Graph/AssemblyScanner.cs 2010-02-05 01:16:22 UTC (rev 342) @@ -5,6 +5,7 @@ using System.Linq; using System.Reflection; using StructureMap.Configuration.DSL; +using StructureMap.Configuration.DSL.Expressions; using StructureMap.TypeRules; using StructureMap.Util; @@ -280,5 +281,58 @@ } return callingAssembly; } + + + + /// <summary> + /// Adds the DefaultConventionScanner to the scanning operations. I.e., a concrete + /// class named "Something" that implements "ISomething" will be automatically + /// added to PluginType "ISomething" + /// </summary> + public ConfigureConventionExpression WithDefaultConventions() + { + var convention = new DefaultConventionScanner(); + With(convention); + return new ConfigureConventionExpression(convention); + } + + /// <summary> + /// Scans for PluginType's and Concrete Types that close the given open generic type + /// </summary> + /// <example> + /// + /// </example> + /// <param name="openGenericType"></param> + public ConfigureConventionExpression ConnectImplementationsToTypesClosing(Type openGenericType) + { + var convention = new GenericConnectionScanner(openGenericType); + With(convention); + return new ConfigureConventionExpression(convention); + } + + /// <summary> + /// Automatically registers all concrete types without primitive arguments + /// against its first interface, if any + /// </summary> + public ConfigureConventionExpression RegisterConcreteTypesAgainstTheFirstInterface() + { + var convention = new FirstInterfaceConvention(); + With(convention); + return new ConfigureConventionExpression(convention); + } + + /// <summary> + /// Directs the scanning to automatically register any type that is the single + /// implementation of an interface against that interface. + /// The filters apply + /// </summary> + public ConfigureConventionExpression SingleImplementationsOfInterface() + { + var convention = new ImplementationMap(); + With(convention); + ModifyGraphAfterScan(convention.RegisterSingleImplementations); + return new ConfigureConventionExpression(convention); + } + } } \ No newline at end of file Modified: trunk/Source/StructureMap/Graph/IAssemblyScanner.cs =================================================================== --- trunk/Source/StructureMap/Graph/IAssemblyScanner.cs 2010-02-04 23:30:20 UTC (rev 341) +++ trunk/Source/StructureMap/Graph/IAssemblyScanner.cs 2010-02-05 01:16:22 UTC (rev 342) @@ -178,5 +178,34 @@ void With(IRegistrationConvention convention); void ModifyGraphAfterScan(Action<PluginGraph> modifyGraph); + + /// <summary> + /// Adds the DefaultConventionScanner to the scanning operations. I.e., a concrete + /// class named "Something" that implements "ISomething" will be automatically + /// added to PluginType "ISomething" + /// </summary> + ConfigureConventionExpression WithDefaultConventions(); + + /// <summary> + /// Scans for PluginType's and Concrete Types that close the given open generic type + /// </summary> + /// <example> + /// + /// </example> + /// <param name="openGenericType"></param> + ConfigureConventionExpression ConnectImplementationsToTypesClosing(Type openGenericType); + + /// <summary> + /// Automatically registers all concrete types without primitive arguments + /// against its first interface, if any + /// </summary> + ConfigureConventionExpression RegisterConcreteTypesAgainstTheFirstInterface(); + + /// <summary> + /// Directs the scanning to automatically register any type that is the single + /// implementation of an interface against that interface. + /// The filters apply + /// </summary> + ConfigureConventionExpression SingleImplementationsOfInterface(); } } \ No newline at end of file Modified: trunk/Source/StructureMap/StructureMap.csproj =================================================================== --- trunk/Source/StructureMap/StructureMap.csproj 2010-02-04 23:30:20 UTC (rev 341) +++ trunk/Source/StructureMap/StructureMap.csproj 2010-02-05 01:16:22 UTC (rev 342) @@ -336,7 +336,6 @@ <Compile Include="CloseGenericTypeExpression.cs" /> <Compile Include="ConfigurationExpression.cs" /> <Compile Include="Configuration\DictionaryReader.cs" /> - <Compile Include="Configuration\DSL\AssemblyScannerExtensions.cs" /> <Compile Include="Configuration\DSL\Expressions\InstanceExpression.cs" /> <Compile Include="Configuration\DSL\IRegistry.cs" /> <Compile Include="Configuration\DSL\SetterConvention.cs" /> Modified: trunk/cruise.build =================================================================== --- trunk/cruise.build 2010-02-04 23:30:20 UTC (rev 341) +++ trunk/cruise.build 2010-02-05 01:16:22 UTC (rev 342) @@ -4,7 +4,7 @@ <property name="deployment.dir" value="source\StructureMap.Testing.DeploymentTasks\"/> <property name="results.dir" value="results" /> <property name="nant.dir" value="bin\nant" /> - <property name="project.version" value="2.6.0" /> + <property name="project.version" value="2.6.1" /> <property name="project.config" value="release" /> <property name="archive.dir" value="archive"/> <target name="all" depends="compile, unit-test, post-clean"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2010-02-04 23:30:26
|
Revision: 341 http://structuremap.svn.sourceforge.net/structuremap/?rev=341&view=rev Author: jeremydmiller Date: 2010-02-04 23:30:20 +0000 (Thu, 04 Feb 2010) Log Message: ----------- Fixing a bug with the Dispose() method on PipelineGraph that only comes into play on a nested container Modified Paths: -------------- trunk/Source/StructureMap/InstanceFactory.cs trunk/Source/StructureMap/PipelineGraph.cs Modified: trunk/Source/StructureMap/InstanceFactory.cs =================================================================== --- trunk/Source/StructureMap/InstanceFactory.cs 2010-02-04 13:50:17 UTC (rev 340) +++ trunk/Source/StructureMap/InstanceFactory.cs 2010-02-04 23:30:20 UTC (rev 341) @@ -142,8 +142,12 @@ public void Dispose() { - _instances.GetAll().Each(i => i.SafeDispose()); _instances.Clear(); } + + public void DisposeInstances() + { + _instances.GetAll().Each(i => i.SafeDispose()); + } } } \ No newline at end of file Modified: trunk/Source/StructureMap/PipelineGraph.cs =================================================================== --- trunk/Source/StructureMap/PipelineGraph.cs 2010-02-04 13:50:17 UTC (rev 340) +++ trunk/Source/StructureMap/PipelineGraph.cs 2010-02-04 23:30:20 UTC (rev 341) @@ -57,10 +57,16 @@ public void Dispose() { + if (_factories.ContainsKey(typeof(IContainer))) + { + _factories[typeof (IContainer)].AllInstances.Each(x => x.SafeDispose()); + } + foreach (var factory in _factories) { factory.Value.Dispose(); } + _factories.Clear(); _profileManager.Dispose(); _genericsGraph.ClearAll(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2010-02-04 14:09:08
|
Revision: 339 http://structuremap.svn.sourceforge.net/structuremap/?rev=339&view=rev Author: jeremydmiller Date: 2010-02-04 13:40:53 +0000 (Thu, 04 Feb 2010) Log Message: ----------- Added the Func<> lazy evaluation strategy Modified Paths: -------------- trunk/Source/StructureMap/Container.cs trunk/Source/StructureMap/PipelineGraph.cs trunk/Source/StructureMap/StructureMap.csproj trunk/Source/StructureMap.Testing/ModelQueryTester.cs trunk/Source/StructureMap.Testing/Query/ModelIntegrationTester.cs trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj Added Paths: ----------- trunk/Source/StructureMap/Pipeline/AdapterClasses.cs trunk/Source/StructureMap.Testing/Pipeline/LazyFuncTester.cs Modified: trunk/Source/StructureMap/Container.cs =================================================================== --- trunk/Source/StructureMap/Container.cs 2010-02-04 03:56:44 UTC (rev 338) +++ trunk/Source/StructureMap/Container.cs 2010-02-04 13:40:53 UTC (rev 339) @@ -558,9 +558,17 @@ _pluginGraph.FindFamily(typeof (IContainer)).AddInstance(thisInstance); _pluginGraph.ProfileManager.SetDefault(typeof (IContainer), thisInstance); + var funcInstance = new FactoryTemplate(typeof (LazyInstance<>)); + _pluginGraph.FindFamily(typeof(Func<>)).AddInstance(funcInstance); + _pluginGraph.ProfileManager.SetDefault(typeof(Func<>), funcInstance); + + + pluginGraph.Log.AssertFailures(); _pipelineGraph = new PipelineGraph(pluginGraph); + + } [Obsolete("delegate to something cleaner in BuildSession")] Added: trunk/Source/StructureMap/Pipeline/AdapterClasses.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/AdapterClasses.cs (rev 0) +++ trunk/Source/StructureMap/Pipeline/AdapterClasses.cs 2010-02-04 13:40:53 UTC (rev 339) @@ -0,0 +1,79 @@ +using System; + +namespace StructureMap.Pipeline +{ + public class FactoryTemplate : Instance + { + private readonly Type _openInstanceType; + + public FactoryTemplate(Type openInstanceType) + { + _openInstanceType = openInstanceType; + } + + protected override string getDescription() + { + return string.Empty; + } + + protected override object build(Type pluginType, BuildSession session) + { + throw new NotImplementedException(); + } + + public override Instance CloseType(Type[] types) + { + var instanceType = _openInstanceType.MakeGenericType(types); + return (Instance) Activator.CreateInstance(instanceType); + } + } + + + public class LazyInstance<T> : Instance + { + protected override string getDescription() + { + return "Lazy construction of " + typeof (T).FullName; + } + + protected override object build(Type pluginType, BuildSession session) + { + var container = session.GetInstance<IContainer>(); + Func<T> func = () => container.GetInstance<T>(); + + return func; + } + } + + public class FactoryInstance<T> : Instance + { + protected override string getDescription() + { + return "Lazy factory of " + typeof (T).FullName; + } + + protected override object build(Type pluginType, BuildSession session) + { + var container = session.GetInstance<IContainer>(); + Func<string, T> func = name => container.GetInstance<T>(name); + + return func; + } + } + + public class FactoryInstance<T, T1> : Instance + { + protected override string getDescription() + { + return "Lazy construction of {0} using {1}".ToFormat(typeof(T1).FullName, typeof(T).FullName); + } + + protected override object build(Type pluginType, BuildSession session) + { + var container = session.GetInstance<IContainer>(); + Func<T, T1> func = key => container.With(key).GetInstance<T1>(); + + return func; + } + } +} \ No newline at end of file Modified: trunk/Source/StructureMap/PipelineGraph.cs =================================================================== --- trunk/Source/StructureMap/PipelineGraph.cs 2010-02-04 03:56:44 UTC (rev 338) +++ trunk/Source/StructureMap/PipelineGraph.cs 2010-02-04 13:40:53 UTC (rev 339) @@ -37,6 +37,8 @@ var factory = new InstanceFactory(family); _factories.Add(family.PluginType, factory); }); + + } private PipelineGraph(ProfileManager profileManager, GenericsPluginGraph genericsGraph, GraphLog log) Modified: trunk/Source/StructureMap/StructureMap.csproj =================================================================== --- trunk/Source/StructureMap/StructureMap.csproj 2010-02-04 03:56:44 UTC (rev 338) +++ trunk/Source/StructureMap/StructureMap.csproj 2010-02-04 13:40:53 UTC (rev 339) @@ -371,6 +371,7 @@ <Compile Include="Graph\PluggableAttributeScanner.cs" /> <Compile Include="Graph\PluginCache.cs" /> <Compile Include="IContext.cs" /> + <Compile Include="Pipeline\AdapterClasses.cs" /> <Compile Include="Pipeline\HybridLifecycle.cs" /> <Compile Include="Query\EmptyConfiguration.cs" /> <Compile Include="Query\GenericFamilyConfiguration.cs" /> Modified: trunk/Source/StructureMap.Testing/ModelQueryTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/ModelQueryTester.cs 2010-02-04 03:56:44 UTC (rev 338) +++ trunk/Source/StructureMap.Testing/ModelQueryTester.cs 2010-02-04 13:40:53 UTC (rev 339) @@ -112,15 +112,15 @@ [Test] public void Iterate_over_pluginTypes() { - // 3 registered plus the 4th is the IContainer itself - _model.PluginTypes.Count().ShouldEqual(4); + // 3 registered plus the 4th is the IContainer itself + Func + _model.PluginTypes.Count().ShouldEqual(5); } [Test] public void Iterate_over_pluginTypes_w_container() { - // IContainer is always added to the Container - _container.Model.PluginTypes.Count().ShouldEqual(4); + // IContainer is always added to the Container + Func<> + _container.Model.PluginTypes.Count().ShouldEqual(5); } [Test] Added: trunk/Source/StructureMap.Testing/Pipeline/LazyFuncTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Pipeline/LazyFuncTester.cs (rev 0) +++ trunk/Source/StructureMap.Testing/Pipeline/LazyFuncTester.cs 2010-02-04 13:40:53 UTC (rev 339) @@ -0,0 +1,78 @@ +using System; +using NUnit.Framework; +using StructureMap.Pipeline; +using StructureMap.Testing.Widget; + +namespace StructureMap.Testing.Pipeline +{ + [TestFixture] + public class LazyFuncTester + { + [SetUp] + public void SetUp() + { + } + + [Test] + public void FactoryTemplateTester() + { + var container = new Container(x => + { + x.For(typeof (Func<>)).Use(new FactoryTemplate(typeof (LazyInstance<>))); + }); + + //container.GetInstance<Func<ConcreteClass>>()().ShouldNotBeNull(); + } + + [Test] + public void build_a_func_for_a_concrete_class() + { + var container = new Container(); + var func = container.GetInstance<Func<ConcreteClass>>(); + + func().ShouldNotBeNull(); + } + + [Test] + public void build_a_func_that_returns_a_transient() + { + var container = new Container(x => + { + x.For<IWidget>().Use<ColorWidget>().Ctor<string>("color").Is("green"); + }); + + var func = container.GetInstance<Func<IWidget>>(); + var w1 = func(); + var w2 = func(); + var w3 = func(); + + w1.ShouldBeOfType<ColorWidget>().Color.ShouldEqual("green"); + + w1.ShouldNotBeTheSameAs(w2); + w1.ShouldNotBeTheSameAs(w3); + w2.ShouldNotBeTheSameAs(w3); + } + + [Test] + public void build_a_func_that_returns_a_singleton() + { + var container = new Container(x => + { + x.ForSingletonOf<IWidget>().Use<ColorWidget>().Ctor<string>("color").Is("green"); + }); + + var func = container.GetInstance<Func<IWidget>>(); + var w1 = func(); + var w2 = func(); + var w3 = func(); + + w1.ShouldBeOfType<ColorWidget>().Color.ShouldEqual("green"); + + w1.ShouldBeTheSameAs(w2); + w1.ShouldBeTheSameAs(w3); + w2.ShouldBeTheSameAs(w3); + } + + public class ConcreteClass{} + } +} \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/Query/ModelIntegrationTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Query/ModelIntegrationTester.cs 2010-02-04 03:56:44 UTC (rev 338) +++ trunk/Source/StructureMap.Testing/Query/ModelIntegrationTester.cs 2010-02-04 13:40:53 UTC (rev 339) @@ -46,8 +46,8 @@ [Test] public void can_iterate_through_families_including_both_generics_and_normal() { - // +1 for "IContainer" itself - container.Model.PluginTypes.Count().ShouldEqual(8); + // +1 for "IContainer" itself + Func + container.Model.PluginTypes.Count().ShouldEqual(9); container.Model.PluginTypes.Each(x => Debug.WriteLine(x.PluginType.FullName)); } @@ -86,7 +86,7 @@ [Test] public void get_all_instances_from_the_top() { - container.Model.AllInstances.Count().ShouldEqual(11); + container.Model.AllInstances.Count().ShouldEqual(12); } [Test] Modified: trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj =================================================================== --- trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2010-02-04 03:56:44 UTC (rev 338) +++ trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2010-02-04 13:40:53 UTC (rev 339) @@ -364,6 +364,7 @@ <Compile Include="Pipeline\GenericsHelperExpressionTester.cs" /> <Compile Include="Pipeline\HybridBuildLifecycleTester.cs" /> <Compile Include="Pipeline\InstanceTester.cs" /> + <Compile Include="Pipeline\LazyFuncTester.cs" /> <Compile Include="Pipeline\MainObjectCacheTester.cs" /> <Compile Include="Pipeline\ObjectInstanceTester.cs" /> <Compile Include="Pipeline\MissingInstanceTester.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2010-02-04 13:50:24
|
Revision: 340 http://structuremap.svn.sourceforge.net/structuremap/?rev=340&view=rev Author: jeremydmiller Date: 2010-02-04 13:50:17 +0000 (Thu, 04 Feb 2010) Log Message: ----------- pushed the AssemblyScannerExtensions to the same namespace as Registry Modified Paths: -------------- trunk/Source/StructureMap/StructureMap.csproj trunk/Source/StructureMap.DebuggerVisualizers.Testing/Program.cs trunk/Source/StructureMap.Testing/Bugs/TryGetInstanceWithOpenGenericsBugTester.cs trunk/Source/StructureMap.Testing/Graph/FirstInterfaceConventionTester.cs trunk/Source/StructureMap.Testing/Graph/GenericConnectionScannerTester.cs trunk/Source/StructureMap.Testing/Graph/SingleImplementationScannerTester.cs Added Paths: ----------- trunk/Source/StructureMap/Configuration/DSL/AssemblyScannerExtensions.cs Removed Paths: ------------- trunk/Source/StructureMap/AssemblyScannerExtensions.cs Deleted: trunk/Source/StructureMap/AssemblyScannerExtensions.cs =================================================================== --- trunk/Source/StructureMap/AssemblyScannerExtensions.cs 2010-02-04 13:40:53 UTC (rev 339) +++ trunk/Source/StructureMap/AssemblyScannerExtensions.cs 2010-02-04 13:50:17 UTC (rev 340) @@ -1,63 +0,0 @@ -using System; -using StructureMap.Configuration.DSL.Expressions; -using StructureMap.Graph; - -namespace StructureMap -{ - /// <summary> - /// Extend the assembly scanning DSL to support the built-in registration conventions - /// </summary> - public static class AssemblyScannerExtensions - { - /// <summary> - /// Adds the DefaultConventionScanner to the scanning operations. I.e., a concrete - /// class named "Something" that implements "ISomething" will be automatically - /// added to PluginType "ISomething" - /// </summary> - public static ConfigureConventionExpression WithDefaultConventions(this IAssemblyScanner assemblyScanner) - { - var convention = new DefaultConventionScanner(); - assemblyScanner.With(convention); - return new ConfigureConventionExpression(convention); - } - - /// <summary> - /// Scans for PluginType's and Concrete Types that close the given open generic type - /// </summary> - /// <example> - /// - /// </example> - /// <param name="openGenericType"></param> - public static ConfigureConventionExpression ConnectImplementationsToTypesClosing(this IAssemblyScanner assemblyScanner, Type openGenericType) - { - var convention = new GenericConnectionScanner(openGenericType); - assemblyScanner.With(convention); - return new ConfigureConventionExpression(convention); - } - - /// <summary> - /// Automatically registers all concrete types without primitive arguments - /// against its first interface, if any - /// </summary> - public static ConfigureConventionExpression RegisterConcreteTypesAgainstTheFirstInterface(this IAssemblyScanner assemblyScanner) - { - var convention = new FirstInterfaceConvention(); - assemblyScanner.With(convention); - return new ConfigureConventionExpression(convention); - } - - /// <summary> - /// Directs the scanning to automatically register any type that is the single - /// implementation of an interface against that interface. - /// The filters apply - /// </summary> - public static ConfigureConventionExpression SingleImplementationsOfInterface(this IAssemblyScanner assemblyScanner) - { - var convention = new ImplementationMap(); - assemblyScanner.With(convention); - assemblyScanner.ModifyGraphAfterScan(convention.RegisterSingleImplementations); - return new ConfigureConventionExpression(convention); - } - - } -} \ No newline at end of file Copied: trunk/Source/StructureMap/Configuration/DSL/AssemblyScannerExtensions.cs (from rev 338, trunk/Source/StructureMap/AssemblyScannerExtensions.cs) =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/AssemblyScannerExtensions.cs (rev 0) +++ trunk/Source/StructureMap/Configuration/DSL/AssemblyScannerExtensions.cs 2010-02-04 13:50:17 UTC (rev 340) @@ -0,0 +1,63 @@ +using System; +using StructureMap.Configuration.DSL.Expressions; +using StructureMap.Graph; + +namespace StructureMap.Configuration.DSL +{ + /// <summary> + /// Extend the assembly scanning DSL to support the built-in registration conventions + /// </summary> + public static class AssemblyScannerExtensions + { + /// <summary> + /// Adds the DefaultConventionScanner to the scanning operations. I.e., a concrete + /// class named "Something" that implements "ISomething" will be automatically + /// added to PluginType "ISomething" + /// </summary> + public static ConfigureConventionExpression WithDefaultConventions(this IAssemblyScanner assemblyScanner) + { + var convention = new DefaultConventionScanner(); + assemblyScanner.With(convention); + return new ConfigureConventionExpression(convention); + } + + /// <summary> + /// Scans for PluginType's and Concrete Types that close the given open generic type + /// </summary> + /// <example> + /// + /// </example> + /// <param name="openGenericType"></param> + public static ConfigureConventionExpression ConnectImplementationsToTypesClosing(this IAssemblyScanner assemblyScanner, Type openGenericType) + { + var convention = new GenericConnectionScanner(openGenericType); + assemblyScanner.With(convention); + return new ConfigureConventionExpression(convention); + } + + /// <summary> + /// Automatically registers all concrete types without primitive arguments + /// against its first interface, if any + /// </summary> + public static ConfigureConventionExpression RegisterConcreteTypesAgainstTheFirstInterface(this IAssemblyScanner assemblyScanner) + { + var convention = new FirstInterfaceConvention(); + assemblyScanner.With(convention); + return new ConfigureConventionExpression(convention); + } + + /// <summary> + /// Directs the scanning to automatically register any type that is the single + /// implementation of an interface against that interface. + /// The filters apply + /// </summary> + public static ConfigureConventionExpression SingleImplementationsOfInterface(this IAssemblyScanner assemblyScanner) + { + var convention = new ImplementationMap(); + assemblyScanner.With(convention); + assemblyScanner.ModifyGraphAfterScan(convention.RegisterSingleImplementations); + return new ConfigureConventionExpression(convention); + } + + } +} \ No newline at end of file Modified: trunk/Source/StructureMap/StructureMap.csproj =================================================================== --- trunk/Source/StructureMap/StructureMap.csproj 2010-02-04 13:40:53 UTC (rev 339) +++ trunk/Source/StructureMap/StructureMap.csproj 2010-02-04 13:50:17 UTC (rev 340) @@ -336,7 +336,7 @@ <Compile Include="CloseGenericTypeExpression.cs" /> <Compile Include="ConfigurationExpression.cs" /> <Compile Include="Configuration\DictionaryReader.cs" /> - <Compile Include="AssemblyScannerExtensions.cs" /> + <Compile Include="Configuration\DSL\AssemblyScannerExtensions.cs" /> <Compile Include="Configuration\DSL\Expressions\InstanceExpression.cs" /> <Compile Include="Configuration\DSL\IRegistry.cs" /> <Compile Include="Configuration\DSL\SetterConvention.cs" /> Modified: trunk/Source/StructureMap.DebuggerVisualizers.Testing/Program.cs =================================================================== --- trunk/Source/StructureMap.DebuggerVisualizers.Testing/Program.cs 2010-02-04 13:40:53 UTC (rev 339) +++ trunk/Source/StructureMap.DebuggerVisualizers.Testing/Program.cs 2010-02-04 13:50:17 UTC (rev 340) @@ -1,5 +1,6 @@ using System.Diagnostics; using System.Windows.Forms; +using StructureMap.Configuration.DSL; namespace StructureMap.DebuggerVisualizers.Testing { Modified: trunk/Source/StructureMap.Testing/Bugs/TryGetInstanceWithOpenGenericsBugTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Bugs/TryGetInstanceWithOpenGenericsBugTester.cs 2010-02-04 13:40:53 UTC (rev 339) +++ trunk/Source/StructureMap.Testing/Bugs/TryGetInstanceWithOpenGenericsBugTester.cs 2010-02-04 13:50:17 UTC (rev 340) @@ -1,5 +1,6 @@ using System.Diagnostics; using NUnit.Framework; +using StructureMap.Configuration.DSL; using StructureMap.TypeRules; namespace StructureMap.Testing.Bugs Modified: trunk/Source/StructureMap.Testing/Graph/FirstInterfaceConventionTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Graph/FirstInterfaceConventionTester.cs 2010-02-04 13:40:53 UTC (rev 339) +++ trunk/Source/StructureMap.Testing/Graph/FirstInterfaceConventionTester.cs 2010-02-04 13:50:17 UTC (rev 340) @@ -1,5 +1,6 @@ using System.Linq; using NUnit.Framework; +using StructureMap.Configuration.DSL; using StructureMap.Testing.Widget3; using StructureMap.TypeRules; Modified: trunk/Source/StructureMap.Testing/Graph/GenericConnectionScannerTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Graph/GenericConnectionScannerTester.cs 2010-02-04 13:40:53 UTC (rev 339) +++ trunk/Source/StructureMap.Testing/Graph/GenericConnectionScannerTester.cs 2010-02-04 13:50:17 UTC (rev 340) @@ -1,5 +1,6 @@ using System; using NUnit.Framework; +using StructureMap.Configuration.DSL; using StructureMap.Graph; namespace StructureMap.Testing.Graph Modified: trunk/Source/StructureMap.Testing/Graph/SingleImplementationScannerTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Graph/SingleImplementationScannerTester.cs 2010-02-04 13:40:53 UTC (rev 339) +++ trunk/Source/StructureMap.Testing/Graph/SingleImplementationScannerTester.cs 2010-02-04 13:50:17 UTC (rev 340) @@ -1,5 +1,6 @@ using System; using NUnit.Framework; +using StructureMap.Configuration.DSL; namespace StructureMap.Testing.Graph { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2010-02-04 03:56:50
|
Revision: 338 http://structuremap.svn.sourceforge.net/structuremap/?rev=338&view=rev Author: jeremydmiller Date: 2010-02-04 03:56:44 +0000 (Thu, 04 Feb 2010) Log Message: ----------- adding the AddSpecial / UseSpecial methods because one person in the world will need it. Modified Paths: -------------- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2010-02-04 03:47:54 UTC (rev 337) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2010-02-04 03:56:44 UTC (rev 338) @@ -78,7 +78,7 @@ /// </summary> /// <param name="configure"></param> /// <returns></returns> - public CreatePluginFamilyExpression<PLUGINTYPE> Use(Action<IInstanceExpression<PLUGINTYPE>> configure) + public CreatePluginFamilyExpression<PLUGINTYPE> UseSpecial(Action<IInstanceExpression<PLUGINTYPE>> configure) { var expression = new InstanceExpression<PLUGINTYPE>(i => Use(i)); configure(expression); @@ -92,7 +92,7 @@ /// </summary> /// <param name="configure"></param> /// <returns></returns> - public CreatePluginFamilyExpression<PLUGINTYPE> Add(Action<IInstanceExpression<PLUGINTYPE>> configure) + public CreatePluginFamilyExpression<PLUGINTYPE> AddSpecial(Action<IInstanceExpression<PLUGINTYPE>> configure) { var expression = new InstanceExpression<PLUGINTYPE>(i => Add(i)); configure(expression); Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs 2010-02-04 03:47:54 UTC (rev 337) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs 2010-02-04 03:56:44 UTC (rev 338) @@ -252,7 +252,7 @@ /// Access to the uncommon types of Instance /// </summary> /// <param name="configure"></param> - public void Use(Action<IInstanceExpression<T>> configure) + public void UseSpecial(Action<IInstanceExpression<T>> configure) { var expression = new InstanceExpression<T>(i => Use(i)); configure(expression); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2010-02-04 03:48:00
|
Revision: 337 http://structuremap.svn.sourceforge.net/structuremap/?rev=337&view=rev Author: jeremydmiller Date: 2010-02-04 03:47:54 +0000 (Thu, 04 Feb 2010) Log Message: ----------- convenience methods to get at all the weird Instance types Modified Paths: -------------- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs trunk/Source/StructureMap/PipelineGraph.cs Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2010-02-04 03:17:07 UTC (rev 336) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2010-02-04 03:47:54 UTC (rev 337) @@ -59,6 +59,48 @@ } + /// <summary> + /// Conditional binding of instances + /// </summary> + /// <param name="configuration"></param> + /// <returns></returns> + public ConditionalInstance<PLUGINTYPE> ConditionallyUse( + Action<ConditionalInstance<PLUGINTYPE>.ConditionalInstanceExpression> configuration) + { + var instance = new ConditionalInstance<PLUGINTYPE>(configuration); + Use(instance); + + return instance; + } + + /// <summary> + /// Access to all of the uncommon Instance types + /// </summary> + /// <param name="configure"></param> + /// <returns></returns> + public CreatePluginFamilyExpression<PLUGINTYPE> Use(Action<IInstanceExpression<PLUGINTYPE>> configure) + { + var expression = new InstanceExpression<PLUGINTYPE>(i => Use(i)); + configure(expression); + + return this; + } + + + /// <summary> + /// Access to all of the uncommon Instance types + /// </summary> + /// <param name="configure"></param> + /// <returns></returns> + public CreatePluginFamilyExpression<PLUGINTYPE> Add(Action<IInstanceExpression<PLUGINTYPE>> configure) + { + var expression = new InstanceExpression<PLUGINTYPE>(i => Add(i)); + configure(expression); + + return this; + } + + private CreatePluginFamilyExpression<PLUGINTYPE> alterAndContinue(Action<PluginFamily> action) { _alterations.Add(action); Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs 2010-02-04 03:17:07 UTC (rev 336) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs 2010-02-04 03:47:54 UTC (rev 337) @@ -110,6 +110,7 @@ _registry.addExpression(graph => graph.SetDefault(_parent._profileName, _pluginType, instance)); } + /// <summary> /// Use the named Instance as the Profile Instance for this PluginType @@ -248,6 +249,17 @@ } /// <summary> + /// Access to the uncommon types of Instance + /// </summary> + /// <param name="configure"></param> + public void Use(Action<IInstanceExpression<T>> configure) + { + var expression = new InstanceExpression<T>(i => Use(i)); + configure(expression); + } + + + /// <summary> /// For this Profile, use the Concrete Type /// </summary> /// <typeparam name="CONCRETETYPE"></typeparam> Modified: trunk/Source/StructureMap/PipelineGraph.cs =================================================================== --- trunk/Source/StructureMap/PipelineGraph.cs 2010-02-04 03:17:07 UTC (rev 336) +++ trunk/Source/StructureMap/PipelineGraph.cs 2010-02-04 03:47:54 UTC (rev 337) @@ -55,18 +55,6 @@ public void Dispose() { - //if (_factories.ContainsKey(typeof (IContainer))) - //{ - // foreach (Instance instance in _factories[typeof (IContainer)].AllInstances) - // { - // var disposable = instance as IDisposable; - // if (disposable != null) - // { - // disposable.Dispose(); - // } - // } - //} - foreach (var factory in _factories) { factory.Value.Dispose(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2010-02-04 03:17:14
|
Revision: 336 http://structuremap.svn.sourceforge.net/structuremap/?rev=336&view=rev Author: jeremydmiller Date: 2010-02-04 03:17:07 +0000 (Thu, 04 Feb 2010) Log Message: ----------- Made disposing a container much, much more robust Modified Paths: -------------- trunk/Source/StructureMap/Container.cs trunk/Source/StructureMap/InstanceFactory.cs trunk/Source/StructureMap/Pipeline/MainObjectCache.cs trunk/Source/StructureMap/Pipeline/ObjectInstance.cs trunk/Source/StructureMap/PipelineGraph.cs trunk/Source/StructureMap/Query/InstanceFactoryTypeConfiguration.cs trunk/Source/StructureMap/TypeExtensions.cs trunk/Source/StructureMap.Testing/Pipeline/ContainerDisposalTester.cs Modified: trunk/Source/StructureMap/Container.cs =================================================================== --- trunk/Source/StructureMap/Container.cs 2010-02-04 02:32:53 UTC (rev 335) +++ trunk/Source/StructureMap/Container.cs 2010-02-04 03:17:07 UTC (rev 336) @@ -442,6 +442,7 @@ { _interceptorLibrary = _interceptorLibrary, _pipelineGraph = _pipelineGraph.ToNestedGraph(), + _onDispose = nestedDispose }; // Fixes a mild bug. The child container should inject itself @@ -463,11 +464,25 @@ return container; } + + private Action<Container> _onDispose = fullDispose; public void Dispose() { - _pipelineGraph.Dispose(); + _onDispose(this); } + private static void fullDispose(Container c) + { + c.Model.AllInstances.Each(i => i.EjectObject()); + + nestedDispose(c); + } + + private static void nestedDispose(Container c) + { + c._pipelineGraph.Dispose(); + } + #endregion /// <summary> Modified: trunk/Source/StructureMap/InstanceFactory.cs =================================================================== --- trunk/Source/StructureMap/InstanceFactory.cs 2010-02-04 02:32:53 UTC (rev 335) +++ trunk/Source/StructureMap/InstanceFactory.cs 2010-02-04 03:17:07 UTC (rev 336) @@ -142,6 +142,7 @@ public void Dispose() { + _instances.GetAll().Each(i => i.SafeDispose()); _instances.Clear(); } } Modified: trunk/Source/StructureMap/Pipeline/MainObjectCache.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/MainObjectCache.cs 2010-02-04 02:32:53 UTC (rev 335) +++ trunk/Source/StructureMap/Pipeline/MainObjectCache.cs 2010-02-04 03:17:07 UTC (rev 336) @@ -25,7 +25,7 @@ var disposable = _objects[key] as IDisposable; _objects.Remove(key); - disposeObject(disposable); + disposable.SafeDispose(); } public object Get(Type pluginType, Instance instance) @@ -59,25 +59,12 @@ { if (@object is Container) return; - disposeObject(@object as IDisposable); + @object.SafeDispose(); }); _objects.Clear(); } } - private void disposeObject(IDisposable disposable) - { - if (disposable != null) - { - try - { - disposable.Dispose(); - } - catch (Exception) - { - } - } - } } } \ No newline at end of file Modified: trunk/Source/StructureMap/Pipeline/ObjectInstance.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/ObjectInstance.cs 2010-02-04 02:32:53 UTC (rev 335) +++ trunk/Source/StructureMap/Pipeline/ObjectInstance.cs 2010-02-04 03:17:07 UTC (rev 336) @@ -40,6 +40,12 @@ public void Dispose() { + bool isContainer = _object is IContainer; + if (!isContainer) + { + _object.SafeDispose(); + } + _object = null; } Modified: trunk/Source/StructureMap/PipelineGraph.cs =================================================================== --- trunk/Source/StructureMap/PipelineGraph.cs 2010-02-04 02:32:53 UTC (rev 335) +++ trunk/Source/StructureMap/PipelineGraph.cs 2010-02-04 03:17:07 UTC (rev 336) @@ -55,17 +55,17 @@ public void Dispose() { - if (_factories.ContainsKey(typeof (IContainer))) - { - foreach (Instance instance in _factories[typeof (IContainer)].AllInstances) - { - var disposable = instance as IDisposable; - if (disposable != null) - { - disposable.Dispose(); - } - } - } + //if (_factories.ContainsKey(typeof (IContainer))) + //{ + // foreach (Instance instance in _factories[typeof (IContainer)].AllInstances) + // { + // var disposable = instance as IDisposable; + // if (disposable != null) + // { + // disposable.Dispose(); + // } + // } + //} foreach (var factory in _factories) { Modified: trunk/Source/StructureMap/Query/InstanceFactoryTypeConfiguration.cs =================================================================== --- trunk/Source/StructureMap/Query/InstanceFactoryTypeConfiguration.cs 2010-02-04 02:32:53 UTC (rev 335) +++ trunk/Source/StructureMap/Query/InstanceFactoryTypeConfiguration.cs 2010-02-04 03:17:07 UTC (rev 336) @@ -24,6 +24,7 @@ void IFamily.Eject(Instance instance) { cache.Eject(_pluginType, instance); + instance.SafeDispose(); } object IFamily.Build(Instance instance) Modified: trunk/Source/StructureMap/TypeExtensions.cs =================================================================== --- trunk/Source/StructureMap/TypeExtensions.cs 2010-02-04 02:32:53 UTC (rev 335) +++ trunk/Source/StructureMap/TypeExtensions.cs 2010-02-04 03:17:07 UTC (rev 336) @@ -19,7 +19,21 @@ list.Add(value); } + public static void SafeDispose(this object target) + { + var disposable = target as IDisposable; + if (disposable == null) return; + try + { + disposable.Dispose(); + } + catch (Exception) + { + } + } + + public static void TryGet<TKey, TValue>(this IDictionary<TKey, TValue> dictionary, TKey key, Action<TValue> action) { Modified: trunk/Source/StructureMap.Testing/Pipeline/ContainerDisposalTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Pipeline/ContainerDisposalTester.cs 2010-02-04 02:32:53 UTC (rev 335) +++ trunk/Source/StructureMap.Testing/Pipeline/ContainerDisposalTester.cs 2010-02-04 03:17:07 UTC (rev 336) @@ -16,6 +16,35 @@ #endregion [Test] + public void disposing_a_main_container_will_dispose_an_object_injected_into_the_container() + { + var disposable = new C2Yes(); + var container = new Container(x => x.For<C2Yes>().Use(disposable)); + + container.Dispose(); + + disposable.WasDisposed.ShouldBeTrue(); + } + + [Test] + public void main_container_should_dispose_singletons() + { + var container = new Container(x => + { + x.ForSingletonOf<C1Yes>().Use<C1Yes>(); + }); + + var single = container.GetInstance<C1Yes>(); + + container.Dispose(); + + single.WasDisposed.ShouldBeTrue(); + } + + + + + [Test] public void disposing_a_nested_container_does_not_try_to_dispose_objects_created_by_the_parent() { var container = new Container(x => { x.ForSingletonOf<I1>().Use<C1No>(); }); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2010-02-04 02:42:39
|
Revision: 334 http://structuremap.svn.sourceforge.net/structuremap/?rev=334&view=rev Author: jeremydmiller Date: 2010-02-04 02:23:48 +0000 (Thu, 04 Feb 2010) Log Message: ----------- Copied some methods to a new name and obsoleted the old with EnrichWith --> EnrichAllWith and OnCreation --> OnCreationForAll() Modified Paths: -------------- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2010-02-04 01:24:52 UTC (rev 333) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2010-02-04 02:23:48 UTC (rev 334) @@ -120,6 +120,16 @@ return TheDefault.Is.ConstructedBy(func); } + /// <summary> + /// Shorthand to say TheDefault.Is.ConstructedBy(func) + /// </summary> + /// <param name="func"></param> + /// <returns></returns> + public LambdaInstance<PLUGINTYPE> Use(Func<PLUGINTYPE> func) + { + return TheDefault.Is.ConstructedBy(func); + } + public void Use(Instance instance) { TheDefault.IsThis(instance); @@ -187,6 +197,7 @@ /// </summary> /// <param name="handler"></param> /// <returns></returns> + [Obsolete("Change to OnCreationForAll")] public CreatePluginFamilyExpression<PLUGINTYPE> OnCreation(Action<PLUGINTYPE> handler) { _children.Add( @@ -210,7 +221,37 @@ return this; } + /// <summary> + /// Register an Action to run against any object of this PluginType immediately after + /// it is created, but before the new object is passed back to the caller + /// </summary> + /// <param name="handler"></param> + /// <returns></returns> + public CreatePluginFamilyExpression<PLUGINTYPE> OnCreationForAll(Action<PLUGINTYPE> handler) + { + _children.Add( + graph => + { + Func<object, object> function = target => + { + handler((PLUGINTYPE)target); + return target; + }; + + var interceptor = new PluginTypeInterceptor(typeof(PLUGINTYPE), (c, o) => + { + handler((PLUGINTYPE)o); + return o; + }); + + graph.InterceptorLibrary.AddInterceptor(interceptor); + }); + + return this; + } + + /// <summary> /// Adds an Interceptor to only this PluginType /// </summary> /// <param name="interceptor"></param> @@ -234,6 +275,7 @@ /// </summary> /// <param name="handler"></param> /// <returns></returns> + [Obsolete("Change to OnCreationForAll")] public CreatePluginFamilyExpression<PLUGINTYPE> OnCreation(Action<IContext, PLUGINTYPE> handler) { _children.Add( @@ -253,7 +295,33 @@ return this; } + /// <summary> + /// Register an Action to run against any object of this PluginType immediately after + /// it is created, but before the new object is passed back to the caller + /// </summary> + /// <param name="handler"></param> + /// <returns></returns> + public CreatePluginFamilyExpression<PLUGINTYPE> OnCreationForAll(Action<IContext, PLUGINTYPE> handler) + { + _children.Add( + graph => + { + Func<IContext, object, object> function = (c, o) => + { + handler(c, (PLUGINTYPE)o); + return o; + }; + + var interceptor = new PluginTypeInterceptor(typeof(PLUGINTYPE), function); + + graph.InterceptorLibrary.AddInterceptor(interceptor); + }); + + return this; + } + + /// <summary> /// Register a Func to run against any object of this PluginType immediately after it is created, /// but before the new object is passed back to the caller. Unlike <see cref="OnCreation(Action{PLUGINTYPE})">OnCreation()</see>, /// EnrichWith() gives the the ability to return a different object. Use this method for runtime AOP @@ -261,6 +329,7 @@ /// </summary> /// <param name="handler"></param> /// <returns></returns> + [Obsolete("Change to EnrichAllWith() -- eliminates confusion")] public CreatePluginFamilyExpression<PLUGINTYPE> EnrichWith(EnrichmentHandler<PLUGINTYPE> handler) { _children.Add( @@ -277,12 +346,35 @@ /// <summary> /// Register a Func to run against any object of this PluginType immediately after it is created, + /// but before the new object is passed back to the caller. Unlike <see cref="OnCreation(Action{PLUGINTYPE})">OnCreation()</see>, + /// EnrichWith() gives the the ability to return a different object. Use this method for runtime AOP + /// scenarios or to return a decorator. + /// </summary> + /// <param name="handler"></param> + /// <returns></returns> + public CreatePluginFamilyExpression<PLUGINTYPE> EnrichAllWith(EnrichmentHandler<PLUGINTYPE> handler) + { + _children.Add( + graph => + { + Func<IContext, object, object> function = (context, target) => handler((PLUGINTYPE)target); + + var interceptor = new PluginTypeInterceptor(typeof(PLUGINTYPE), function); + graph.InterceptorLibrary.AddInterceptor(interceptor); + }); + + return this; + } + + /// <summary> + /// Register a Func to run against any object of this PluginType immediately after it is created, /// but before the new object is passed back to the caller. Unlike <see cref="OnCreation(Action{IContext,PLUGINTYPE})">OnCreation()</see>, /// EnrichWith() gives the the ability to return a different object. Use this method for runtime AOP /// scenarios or to return a decorator. /// </summary> /// <param name="handler"></param> /// <returns></returns> + [Obsolete("Change to EnrichAllWith -- it's to avoid confusion")] public CreatePluginFamilyExpression<PLUGINTYPE> EnrichWith(ContextEnrichmentHandler<PLUGINTYPE> handler) { _children.Add( @@ -296,7 +388,30 @@ return this; } + /// <summary> + /// Register a Func to run against any object of this PluginType immediately after it is created, + /// but before the new object is passed back to the caller. Unlike <see cref="OnCreation(Action{IContext,PLUGINTYPE})">OnCreation()</see>, + /// EnrichWith() gives the the ability to return a different object. Use this method for runtime AOP + /// scenarios or to return a decorator. + /// </summary> + /// <param name="handler"></param> + /// <returns></returns> + public CreatePluginFamilyExpression<PLUGINTYPE> EnrichAllWith(ContextEnrichmentHandler<PLUGINTYPE> handler) + { + _children.Add( + graph => + { + var interceptor = new PluginTypeInterceptor(typeof(PLUGINTYPE), + (c, o) => handler(c, (PLUGINTYPE)o)); + graph.InterceptorLibrary.AddInterceptor(interceptor); + }); + + return this; + } + + + /// <summary> /// Shortcut method to add an additional Instance to this Plugin Type /// as just a Concrete Type. This will only work if the Concrete Type /// has no primitive constructor or mandatory Setter arguments. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2010-02-04 02:42:36
|
Revision: 335 http://structuremap.svn.sourceforge.net/structuremap/?rev=335&view=rev Author: jeremydmiller Date: 2010-02-04 02:32:53 +0000 (Thu, 04 Feb 2010) Log Message: ----------- Added the ObjectFactory.ReleaseAndDisposeAllHttpScopedObjects() convenience method Modified Paths: -------------- trunk/Source/StructureMap/ObjectFactory.cs Modified: trunk/Source/StructureMap/ObjectFactory.cs =================================================================== --- trunk/Source/StructureMap/ObjectFactory.cs 2010-02-04 02:23:48 UTC (rev 334) +++ trunk/Source/StructureMap/ObjectFactory.cs 2010-02-04 02:32:53 UTC (rev 335) @@ -45,6 +45,14 @@ } } + /// <summary> + /// Remove and dispose all objects scoped by HttpContext. Call this method at the *end* of an Http request to clean up resources + /// </summary> + public static void ReleaseAndDisposeAllHttpScopedObjects() + { + HttpContextLifecycle.DisposeAndClearAll(); + } + public static void Initialize(Action<IInitializationExpression> action) { lock (typeof (ObjectFactory)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2010-02-04 02:37:03
|
Revision: 329 http://structuremap.svn.sourceforge.net/structuremap/?rev=329&view=rev Author: jeremydmiller Date: 2010-02-04 00:33:40 +0000 (Thu, 04 Feb 2010) Log Message: ----------- Pulling back some code for 3.0 to make a temporary bug release Modified Paths: -------------- trunk/Source/HTML/AutoWiring.htm trunk/Source/HTML/ConfiguringStructureMap.htm trunk/Source/HTML/Generics.htm trunk/Source/HTML/InstanceExpression.htm trunk/Source/HTML/Interception.htm trunk/Source/HTML/QuickStart.htm trunk/Source/HTML/RegistryDSL.htm trunk/Source/HTML/ScanningAssemblies.htm trunk/Source/HTML/UsingTheContainerOutsideOfObjectFactory.htm trunk/Source/StructureMap/BuildSession.cs trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs trunk/Source/StructureMap/Configuration/DSL/IRegistry.cs trunk/Source/StructureMap/Configuration/DSL/Registry.cs trunk/Source/StructureMap/Container.cs trunk/Source/StructureMap/IContainer.cs trunk/Source/StructureMap/Pipeline/SmartInstance.cs trunk/Source/StructureMap/PipelineGraph.cs trunk/Source/StructureMap/StructureMap.csproj trunk/Source/StructureMap/StructureMapException.resx trunk/Source/StructureMap/SystemRegistry.cs trunk/Source/StructureMap.DebuggerVisualizers.Testing/Program.cs trunk/Source/StructureMap.Testing/AutoMocking/RhinoAutoMockerTester.cs trunk/Source/StructureMap.Testing/AutoWiringExamples.cs trunk/Source/StructureMap.Testing/BidirectionalDependencies.cs trunk/Source/StructureMap.Testing/Bugs/FillAllPropertiesShouldWorkForAlreadyConfiguredPluginsBug.cs trunk/Source/StructureMap.Testing/Bugs/HttpSessionNullRefBug.cs trunk/Source/StructureMap.Testing/Bugs/LambdaCreatesNullBugTester.cs trunk/Source/StructureMap.Testing/Bugs/MixedConfigureAndInitializeMissingInstanceProblem.cs trunk/Source/StructureMap.Testing/Bugs/SingletonShouldBeLazy.cs trunk/Source/StructureMap.Testing/Bugs/SpecifyScopeInConfigureTester.cs trunk/Source/StructureMap.Testing/BuildSessionTester.cs trunk/Source/StructureMap.Testing/BuildUpIntegratedTester.cs trunk/Source/StructureMap.Testing/Configuration/DSL/AddInstanceTester.cs trunk/Source/StructureMap.Testing/Configuration/DSL/AddTypesTester.cs trunk/Source/StructureMap.Testing/Configuration/DSL/ConstructorExpressionTester.cs trunk/Source/StructureMap.Testing/Configuration/DSL/CreatePluginFamilyTester.cs trunk/Source/StructureMap.Testing/Configuration/DSL/GenericFamilyExpressionTester.cs trunk/Source/StructureMap.Testing/Configuration/DSL/InjectArrayTester.cs trunk/Source/StructureMap.Testing/Configuration/DSL/InterceptAllInstancesOfPluginTypeTester.cs trunk/Source/StructureMap.Testing/Configuration/DSL/InterceptorTesting.cs trunk/Source/StructureMap.Testing/Configuration/DSL/ProfileExpressionTester.cs trunk/Source/StructureMap.Testing/Configuration/DSL/RegistryTester.cs trunk/Source/StructureMap.Testing/Diagnostics/DoctorTester.cs trunk/Source/StructureMap.Testing/Diagnostics/ValidationBuildSessionTester.cs trunk/Source/StructureMap.Testing/Examples/CustomInstance.cs trunk/Source/StructureMap.Testing/Examples/Interception.cs trunk/Source/StructureMap.Testing/Examples/RegisteringWithTheAPI.cs trunk/Source/StructureMap.Testing/Examples.cs trunk/Source/StructureMap.Testing/GenericsAcceptanceTester.cs trunk/Source/StructureMap.Testing/Graph/ArrayConstructorTester.cs trunk/Source/StructureMap.Testing/Graph/AssemblyScannerTester.cs trunk/Source/StructureMap.Testing/Graph/ContainerTester.cs trunk/Source/StructureMap.Testing/Graph/ConventionBasedSetterInjectionTester.cs trunk/Source/StructureMap.Testing/Graph/DynamicInjectionTester.cs trunk/Source/StructureMap.Testing/Graph/FillDependenciesTester.cs trunk/Source/StructureMap.Testing/Graph/FullStackFacadeTester.cs trunk/Source/StructureMap.Testing/Graph/GenericsPluginGraphTester.cs trunk/Source/StructureMap.Testing/Graph/InstanceFactoryTester.cs trunk/Source/StructureMap.Testing/Graph/IntegratedTester.cs trunk/Source/StructureMap.Testing/Graph/Interceptors/TypeInterceptionTester.cs trunk/Source/StructureMap.Testing/Graph/PluginGraphBuilderTester.cs trunk/Source/StructureMap.Testing/Graph/PluginTester.cs trunk/Source/StructureMap.Testing/Graph/TestExplicitArguments.cs trunk/Source/StructureMap.Testing/Graph/TypeFindingTester.cs trunk/Source/StructureMap.Testing/ModelQueryTester.cs trunk/Source/StructureMap.Testing/ObjectFactoryTester.cs trunk/Source/StructureMap.Testing/PerRequestInterceptorTester.cs trunk/Source/StructureMap.Testing/Pipeline/BuildStrategiesTester.cs trunk/Source/StructureMap.Testing/Pipeline/ConditionalInstanceTester.cs trunk/Source/StructureMap.Testing/Pipeline/ConfiguredInstanceTester.cs trunk/Source/StructureMap.Testing/Pipeline/GenericsHelperExpressionTester.cs trunk/Source/StructureMap.Testing/Pipeline/HybridBuildLifecycleTester.cs trunk/Source/StructureMap.Testing/Pipeline/MissingInstanceTester.cs trunk/Source/StructureMap.Testing/Pipeline/NestedContainerSupportTester.cs trunk/Source/StructureMap.Testing/Pipeline/ObjectBuilderTester.cs trunk/Source/StructureMap.Testing/Pipeline/OptionalSetterInjectionTester.cs trunk/Source/StructureMap.Testing/Pipeline/SmartInstanceTester.cs trunk/Source/StructureMap.Testing/Pipeline/ThreadLocalStorageLifecycleTester.cs trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj trunk/Source/StructureMap.Testing/StructureMapConfigurationTester.cs trunk/cruise.build Removed Paths: ------------- trunk/Source/StructureMap/Pipeline/BasicInstance.cs trunk/Source/StructureMap.Testing/Configuration/DSL/DeepInstanceTester.cs Modified: trunk/Source/HTML/AutoWiring.htm =================================================================== --- trunk/Source/HTML/AutoWiring.htm 2010-02-03 23:16:32 UTC (rev 328) +++ trunk/Source/HTML/AutoWiring.htm 2010-02-04 00:33:40 UTC (rev 329) @@ -150,7 +150,7 @@ <span style="COLOR: green">// Set up the IRepository</span></p> <p style="MARGIN: 0px"> - x.ForRequestedType<<span style="COLOR: #2b91af">IRepository</span>>().TheDefault.Is.OfConcreteType<<span + x.ForRequestedType<<span style="COLOR: #2b91af">IRepository</span>>().Use<<span style="COLOR: #2b91af">Repository</span>>()</p> <p style="MARGIN: 0px"> Modified: trunk/Source/HTML/ConfiguringStructureMap.htm =================================================================== --- trunk/Source/HTML/ConfiguringStructureMap.htm 2010-02-03 23:16:32 UTC (rev 328) +++ trunk/Source/HTML/ConfiguringStructureMap.htm 2010-02-04 00:33:40 UTC (rev 329) @@ -142,7 +142,7 @@ these methods for all all the possible configuration directives.</p> <!-- -{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;\red0\green128\blue0;}??\fs20 \cf3 public\cf0 \cf3 interface\cf0 \cf4 IInitializationExpression\par ??\cf0 \{\par ?? \cf5 // Directives on how to treat the StructureMap.config file\par ??\cf0 \cf3 bool\cf0 UseDefaultStructureMapConfigFile \{ \cf3 set\cf0 ; \}\par ?? \cf3 bool\cf0 IgnoreStructureMapConfig \{ \cf3 set\cf0 ; \}\par ??\par ?? \cf5 // Xml configuration from the App.Config file\par ??\cf0 \cf3 bool\cf0 PullConfigurationFromAppConfig \{ \cf3 set\cf0 ; \}\par ??\par ?? \cf5 // Ancillary sources of Xml configuration\par ??\cf0 \cf3 void\cf0 AddConfigurationFromXmlFile(\cf3 string\cf0 fileName);\par ?? \cf3 void\cf0 AddConfigurationFromNode(\cf4 XmlNode\cf0 node);\par ??\par ?? \cf5 // Specifying Registry's\par ??\cf0 \cf3 void\cf0 AddRegistry<T>() \cf3 where\cf0 T : \cf4 Registry\cf0 , \cf3 new\cf0 ();\par ?? \cf3 void\cf0 AddRegistry(\cf4 Registry\cf0 registry);\par ??\par ?? \cf5 // Designate the Default Profile. This will be applied as soon as the \par ??\cf0 \cf5 // Container is initialized.\par ??\cf0 \cf3 string\cf0 DefaultProfileName \{ \cf3 get\cf0 ; \cf3 set\cf0 ; \}\par ??\par ?? \cf5 // ... and the Registry DSL as well\par ??\par ??\cf0 \cf5 // The Registry DSL\par ??\cf0 \cf4 CreatePluginFamilyExpression\cf0 <PLUGINTYPE> BuildInstancesOf<PLUGINTYPE>();\par ?? \cf4 CreatePluginFamilyExpression\cf0 <PLUGINTYPE> ForRequestedType<PLUGINTYPE>();\par ?? \cf4 GenericFamilyExpression\cf0 For(\cf4 Type\cf0 pluginType);\par ?? \cf4 Registry\cf0 .\cf4 BuildWithExpression\cf0 <T> ForConcreteType<T>();\par ??\par ?? \cf4 IsExpression\cf0 <T> InstanceOf<T>();\par ?? \cf4 GenericIsExpression\cf0 InstanceOf(\cf4 Type\cf0 pluginType);\par ??\par ?? \cf4 ProfileExpression\cf0 CreateProfile(\cf3 string\cf0 profileName);\par ?? \cf3 void\cf0 CreateProfile(\cf3 string\cf0 profileName, \cf4 Action\cf0 <\cf4 ProfileExpression\cf0 > action);\par ??\par ?? \cf3 void\cf0 RegisterInterceptor(\cf4 TypeInterceptor\cf0 interceptor);\par ?? \cf4 MatchedTypeInterceptor\cf0 IfTypeMatches(\cf4 Predicate\cf0 <\cf4 Type\cf0 > match);\par ??\par ?? \cf3 void\cf0 Scan(\cf4 Action\cf0 <\cf4 IAssemblyScanner\cf0 > action);\par ??\par ?? \cf4 CreatePluginFamilyExpression\cf0 <PLUGINTYPE> FillAllPropertiesOfType<PLUGINTYPE>();\par ?? \}} +{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;\red0\green128\blue0;}??\fs20 \cf3 public\cf0 \cf3 interface\cf0 \cf4 IInitializationExpression\par ??\cf0 \{\par ?? \cf5 // Directives on how to treat the StructureMap.config file\par ??\cf0 \cf3 bool\cf0 UseDefaultStructureMapConfigFile \{ \cf3 set\cf0 ; \}\par ?? \cf3 bool\cf0 IgnoreStructureMapConfig \{ \cf3 set\cf0 ; \}\par ??\par ?? \cf5 // Xml configuration from the App.Config file\par ??\cf0 \cf3 bool\cf0 PullConfigurationFromAppConfig \{ \cf3 set\cf0 ; \}\par ??\par ?? \cf5 // Ancillary sources of Xml configuration\par ??\cf0 \cf3 void\cf0 AddConfigurationFromXmlFile(\cf3 string\cf0 fileName);\par ?? \cf3 void\cf0 AddConfigurationFromNode(\cf4 XmlNode\cf0 node);\par ??\par ?? \cf5 // Specifying Registry's\par ??\cf0 \cf3 void\cf0 AddRegistry<T>() \cf3 where\cf0 T : \cf4 Registry\cf0 , \cf3 new\cf0 ();\par ?? \cf3 void\cf0 AddRegistry(\cf4 Registry\cf0 registry);\par ??\par ?? \cf5 // Designate the Default Profile. This will be applied as soon as the \par ??\cf0 \cf5 // Container is initialized.\par ??\cf0 \cf3 string\cf0 DefaultProfileName \{ \cf3 get\cf0 ; \cf3 set\cf0 ; \}\par ??\par ?? \cf5 // ... and the Registry DSL as well\par ??\par ??\cf0 \cf5 // The Registry DSL\par ??\cf0 \cf4 CreatePluginFamilyExpression\cf0 <PLUGINTYPE> BuildInstancesOf<PLUGINTYPE>();\par ?? \cf4 CreatePluginFamilyExpression\cf0 <PLUGINTYPE> ForRequestedType<PLUGINTYPE>();\par ?? \cf4 GenericFamilyExpression\cf0 ForRequestedType(\cf4 Type\cf0 pluginType);\par ?? \cf4 Registry\cf0 .\cf4 BuildWithExpression\cf0 <T> ForConcreteType<T>();\par ??\par ?? \cf4 IsExpression\cf0 <T> InstanceOf<T>();\par ?? \cf4 GenericIsExpression\cf0 InstanceOf(\cf4 Type\cf0 pluginType);\par ??\par ?? \cf4 ProfileExpression\cf0 CreateProfile(\cf3 string\cf0 profileName);\par ?? \cf3 void\cf0 CreateProfile(\cf3 string\cf0 profileName, \cf4 Action\cf0 <\cf4 ProfileExpression\cf0 > action);\par ??\par ?? \cf3 void\cf0 RegisterInterceptor(\cf4 TypeInterceptor\cf0 interceptor);\par ?? \cf4 MatchedTypeInterceptor\cf0 IfTypeMatches(\cf4 Predicate\cf0 <\cf4 Type\cf0 > match);\par ??\par ?? \cf3 void\cf0 Scan(\cf4 Action\cf0 <\cf4 IAssemblyScanner\cf0 > action);\par ??\par ?? \cf4 CreatePluginFamilyExpression\cf0 <PLUGINTYPE> FillAllPropertiesOfType<PLUGINTYPE>();\par ?? \}} --> <div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;"> <p style="margin: 0px;"> Modified: trunk/Source/HTML/Generics.htm =================================================================== --- trunk/Source/HTML/Generics.htm 2010-02-03 23:16:32 UTC (rev 328) +++ trunk/Source/HTML/Generics.htm 2010-02-04 00:33:40 UTC (rev 329) @@ -237,7 +237,7 @@ <p>Great, but now let's move on to registering these classes with a Container. This unit test fixture from the code illustrates this very scenario:</p> <!-- -{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red0\green0\blue255;\red0\green128\blue0;}??\fs20 [\cf3 SetUp\cf0 ]\par ?? \cf4 public\cf0 \cf4 void\cf0 SetUp()\par ?? \{\par ?? container = \cf4 new\cf0 \cf3 Container\cf0 (x =>\par ?? \{\par ?? \cf5 // Define the basic open type for IFlattener<>\par ??\cf0 x.For(\cf4 typeof\cf0 (\cf3 IFlattener\cf0 <>)).TheDefaultIsConcreteType(\cf4 typeof\cf0 (\cf3 PassthroughFlattener\cf0 <>));\par ?? \par ?? \cf5 // Explicitly Register a specific closed type for Address\par ??\cf0 x.ForRequestedType<\cf3 IFlattener\cf0 <\cf3 Address\cf0 >>().TheDefaultIsConcreteType<\cf3 AddressFlattener\cf0 >();\par ?? \});\par ?? \}} +{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red0\green0\blue255;\red0\green128\blue0;}??\fs20 [\cf3 SetUp\cf0 ]\par ?? \cf4 public\cf0 \cf4 void\cf0 SetUp()\par ?? \{\par ?? container = \cf4 new\cf0 \cf3 Container\cf0 (x =>\par ?? \{\par ?? \cf5 // Define the basic open type for IFlattener<>\par ??\cf0 x.ForRequestedType(\cf4 typeof\cf0 (\cf3 IFlattener\cf0 <>)).TheDefaultIsConcreteType(\cf4 typeof\cf0 (\cf3 PassthroughFlattener\cf0 <>));\par ?? \par ?? \cf5 // Explicitly Register a specific closed type for Address\par ??\cf0 x.ForRequestedType<\cf3 IFlattener\cf0 <\cf3 Address\cf0 >>().TheDefaultIsConcreteType<\cf3 AddressFlattener\cf0 >();\par ?? \});\par ?? \}} --> <div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;"> <p style="margin: 0px;"> @@ -258,7 +258,7 @@ <span style="color: green;">// Define the basic open type for IFlattener<></span></p> <p style="margin: 0px;"> - x.For(<span style="color: blue;">typeof</span> (<span + x.ForRequestedType(<span style="color: blue;">typeof</span> (<span style="color: #2b91af;">IFlattener</span><>)).TheDefaultIsConcreteType(<span style="color: blue;">typeof</span> (<span style="color: #2b91af;">PassthroughFlattener</span><>));</p> <p style="margin: 0px;"> Modified: trunk/Source/HTML/InstanceExpression.htm =================================================================== --- trunk/Source/HTML/InstanceExpression.htm 2010-02-03 23:16:32 UTC (rev 328) +++ trunk/Source/HTML/InstanceExpression.htm 2010-02-04 00:33:40 UTC (rev 329) @@ -32,7 +32,7 @@ code sample below, the text "**********;" represents a call to an InstanceExpression.</p> <!-- -{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;\red0\green128\blue0;\red163\green21\blue21;}??\fs20 \cf3 public\cf0 \cf3 class\cf0 \cf4 InstanceExampleRegistry\cf0 : \cf4 Registry\par ??\cf0 \{\par ?? \cf3 public\cf0 InstanceExampleRegistry()\par ?? \{\par ?? \cf5 // Shortcut for just specifying "use this type -- with auto wiring"\par ??\cf0 ForRequestedType<\cf4 IService\cf0 >().TheDefaultIsConcreteType<\cf4 RemoteService\cf0 >();\par ?? \par ?? \cf5 // Set the default Instance of a PluginType\par ??\cf0 ForRequestedType<\cf4 IService\cf0 >().TheDefault.Is.OfConcreteType<\cf4 RemoteService\cf0 >();\par ?? \par ?? \cf5 // Add an additional Instance of a PluginType\par ??\cf0 InstanceOf<\cf4 IService\cf0 >().Is.OfConcreteType<\cf4 RemoteService\cf0 >();\par ??\par ?? \cf5 // Add multiple additional Instances of a PluginType\par ??\cf0 ForRequestedType<\cf4 IService\cf0 >().AddInstances(x =>\par ?? \{\par ?? x.ConstructedBy(() => \cf3 new\cf0 \cf4 ColorService\cf0 (\cf6 "Red"\cf0 ));\par ??\par ?? x.OfConcreteType<\cf4 RemoteService\cf0 >();\par ??\par ?? x.Object(\cf3 new\cf0 \cf4 ColorService\cf0 (\cf6 "Red"\cf0 ));\par ?? \});\par ??\par ?? \cf5 // Use the InstanceExpression to define the default Instance\par ??\cf0 \cf5 // of a PluginType within a Profile\par ??\cf0 CreateProfile(\cf6 "Connected"\cf0 , x =>\par ?? \{\par ?? x.Type<\cf4 IService\cf0 >().Is.OfConcreteType<\cf4 RemoteService\cf0 >();\par ?? \});\par ?? \}\par ?? \}} +{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;\red0\green128\blue0;\red163\green21\blue21;}??\fs20 \cf3 public\cf0 \cf3 class\cf0 \cf4 InstanceExampleRegistry\cf0 : \cf4 Registry\par ??\cf0 \{\par ?? \cf3 public\cf0 InstanceExampleRegistry()\par ?? \{\par ?? \cf5 // Shortcut for just specifying "use this type -- with auto wiring"\par ??\cf0 ForRequestedType<\cf4 IService\cf0 >().TheDefaultIsConcreteType<\cf4 RemoteService\cf0 >();\par ?? \par ?? \cf5 // Set the default Instance of a PluginType\par ??\cf0 ForRequestedType<\cf4 IService\cf0 >().Use<\cf4 RemoteService\cf0 >();\par ?? \par ?? \cf5 // Add an additional Instance of a PluginType\par ??\cf0 InstanceOf<\cf4 IService\cf0 >().Is.OfConcreteType<\cf4 RemoteService\cf0 >();\par ??\par ?? \cf5 // Add multiple additional Instances of a PluginType\par ??\cf0 ForRequestedType<\cf4 IService\cf0 >().AddInstances(x =>\par ?? \{\par ?? x.ConstructedBy(() => \cf3 new\cf0 \cf4 ColorService\cf0 (\cf6 "Red"\cf0 ));\par ??\par ?? x.OfConcreteType<\cf4 RemoteService\cf0 >();\par ??\par ?? x.Object(\cf3 new\cf0 \cf4 ColorService\cf0 (\cf6 "Red"\cf0 ));\par ?? \});\par ??\par ?? \cf5 // Use the InstanceExpression to define the default Instance\par ??\cf0 \cf5 // of a PluginType within a Profile\par ??\cf0 CreateProfile(\cf6 "Connected"\cf0 , x =>\par ?? \{\par ?? x.Type<\cf4 IService\cf0 >().Is.OfConcreteType<\cf4 RemoteService\cf0 >();\par ?? \});\par ?? \}\par ?? \}} --> <div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;"> <p style="margin: 0px;"> @@ -308,7 +308,7 @@ <p style="margin: 0px">            {</p> - <p style="margin: 0px">                registry.ForRequestedType<<span style="color: #2b91af">Thing</span>>().TheDefault.Is.OfConcreteType<<span style="color: #2b91af">Thing</span>>()</p> + <p style="margin: 0px">                registry.ForRequestedType<<span style="color: #2b91af">Thing</span>>().Use<<span style="color: #2b91af">Thing</span>>()</p> <p style="margin: 0px">                    <strong>.WithCtorArg(<span style="color: #a31515">"name"</span>).EqualTo(<span style="color: #a31515">"Jeremy"</span>)</strong></p> @@ -456,12 +456,12 @@ </a> <p>Setter dependencies are configured much like constructor dependencies:</p> <!-- -{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red163\green21\blue21;}??\fs20 registry.ForRequestedType<\cf3 Thing\cf0 >().TheDefault.Is.OfConcreteType<\cf3 Thing\cf0 >()\par ?? .WithCtorArg(\cf4 "name"\cf0 ).EqualTo(\cf4 "Jeremy"\cf0 )\par ?? .WithCtorArg(\cf4 "count"\cf0 ).EqualTo(4)\par ?? .WithCtorArg(\cf4 "average"\cf0 ).EqualTo(.333)\par ?? .SetterDependency<\cf3 Rule\cf0 >().Is(x =>\par ?? \{\par ?? x.OfConcreteType<\cf3 WidgetRule\cf0 >().SetterDependency<\cf3 IWidget\cf0 >().Is(\par ?? c => c.OfConcreteType<\cf3 ColorWidget\cf0 >().WithCtorArg(\cf4 "color"\cf0 ).EqualTo(\cf4 "yellow"\cf0 ));\par ?? \});} +{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red163\green21\blue21;}??\fs20 registry.ForRequestedType<\cf3 Thing\cf0 >().Use<\cf3 Thing\cf0 >()\par ?? .WithCtorArg(\cf4 "name"\cf0 ).EqualTo(\cf4 "Jeremy"\cf0 )\par ?? .WithCtorArg(\cf4 "count"\cf0 ).EqualTo(4)\par ?? .WithCtorArg(\cf4 "average"\cf0 ).EqualTo(.333)\par ?? .SetterDependency<\cf3 Rule\cf0 >().Is(x =>\par ?? \{\par ?? x.OfConcreteType<\cf3 WidgetRule\cf0 >().SetterDependency<\cf3 IWidget\cf0 >().Is(\par ?? c => c.OfConcreteType<\cf3 ColorWidget\cf0 >().WithCtorArg(\cf4 "color"\cf0 ).EqualTo(\cf4 "yellow"\cf0 ));\par ?? \});} --> <div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;"> <p style="margin: 0px;"> - registry.ForRequestedType<<span style="color: #2b91af;">Thing</span>>().TheDefault.Is.OfConcreteType<span + registry.ForRequestedType<<span style="color: #2b91af;">Thing</span>>().Use<span style="color: #2b91af;">Thing</span>>()</p> <p style="margin: 0px;"> @@ -522,7 +522,7 @@ <p>StructureMap supports Array arguments of non primitive objects. An array of dependencies or type T can be defined with the TheArrayOf<T>() method shown below.</p> <!-- -{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;\red163\green21\blue21;}??\fs20 \cf3 var\cf0 container = \cf3 new\cf0 \cf4 Container\cf0 (x =>\par ?? \{\par ?? x.ForRequestedType<\cf4 Processor\cf0 >().TheDefault.Is.OfConcreteType<\cf4 Processor\cf0 >()\par ?? .WithCtorArg(\cf5 "name"\cf0 ).EqualTo(\cf5 "Jeremy"\cf0 )\par ?? .TheArrayOf<\cf4 IHandler\cf0 >().Contains(y =>\par ?? \{\par ?? y.OfConcreteType<\cf4 Handler1\cf0 >();\par ?? y.OfConcreteType<\cf4 Handler2\cf0 >();\par ?? y.OfConcreteType<\cf4 Handler3\cf0 >();\par ?? \});\par ?? \});} +{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;\red163\green21\blue21;}??\fs20 \cf3 var\cf0 container = \cf3 new\cf0 \cf4 Container\cf0 (x =>\par ?? \{\par ?? x.ForRequestedType<\cf4 Processor\cf0 >().Use<\cf4 Processor\cf0 >()\par ?? .WithCtorArg(\cf5 "name"\cf0 ).EqualTo(\cf5 "Jeremy"\cf0 )\par ?? .TheArrayOf<\cf4 IHandler\cf0 >().Contains(y =>\par ?? \{\par ?? y.OfConcreteType<\cf4 Handler1\cf0 >();\par ?? y.OfConcreteType<\cf4 Handler2\cf0 >();\par ?? y.OfConcreteType<\cf4 Handler3\cf0 >();\par ?? \});\par ?? \});} --> <div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;"> <p style="margin: 0px;"> @@ -533,7 +533,7 @@ {</p> <p style="margin: 0px;"> - x.ForRequestedType<<span style="color: #2b91af;">Processor</span>>().TheDefault.Is.OfConcreteType<<span + x.ForRequestedType<<span style="color: #2b91af;">Processor</span>>().Use<<span style="color: #2b91af;">Processor</span>>()</p> <p style="margin: 0px;"> @@ -728,7 +728,7 @@ (IUrlRegistry, IActionRegistry, and ITypeRegistry) before injecting them into StructureMap:</p> <!-- -{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;}??\fs20 \cf3 private\cf0 \cf3 readonly\cf0 \cf4 ActionRegistry\cf0 _actionRegistry = \cf3 new\cf0 \cf4 ActionRegistry\cf0 ();\par ?? \cf3 private\cf0 \cf3 readonly\cf0 \cf4 ISpecialCaseRouteRegistry\cf0 _specialCaseRouteRegistry = \cf3 new\cf0 \cf4 SpecialCaseRouteRegistry\cf0 ();\par ?? \cf3 private\cf0 \cf3 readonly\cf0 \cf4 TypeRegistry\cf0 _typeRegistry = \cf3 new\cf0 \cf4 TypeRegistry\cf0 ();\par ?? \cf3 private\cf0 \cf3 readonly\cf0 \cf4 List\cf0 <\cf4 Type\cf0 > _workflowTypes = \cf3 new\cf0 \cf4 List\cf0 <\cf4 Type\cf0 >();\par ?? \cf3 private\cf0 \cf4 UrlGraph\cf0 _graph;\par ?? \cf3 private\cf0 \cf4 ControllerRegistry\cf0 _registry;\par ??\par ?? \cf3 public\cf0 WebRegistry(\cf4 ICollection\cf0 <\cf4 RouteBase\cf0 > routes)\par ?? \{\par ?? createUrlGraph(routes);\par ??\par ?? ForRequestedType<\cf4 IUrlRegistry\cf0 >().TheDefault.Is.Object(_graph);\par ?? ForRequestedType<\cf4 IActionRegistry\cf0 >().TheDefault.Is.Object(_actionRegistry);\par ?? ForRequestedType<\cf4 ITypeRegistry\cf0 >().TheDefault.Is.Object(_typeRegistry);\par ?? ForRequestedType<\cf4 ITypeReport\cf0 >().TheDefaultIsConcreteType<\cf4 WorkflowItemTypeReport\cf0 >();\par ?? ForRequestedType<\cf4 ISpecialCaseRouteRegistry\cf0 >().TheDefault.Is.Object(_specialCaseRouteRegistry);\par ??\par ?? ForRequestedType<\cf4 ILogViewerRegistry\cf0 >()\par ?? .TheDefault.Is.OfConcreteType<\cf4 LogViewerRegistry\cf0 >();\par ??\par ?? ForRequestedType<\cf4 IWebPlatformDetector\cf0 >().TheDefaultIsConcreteType<\cf4 MobileWebPlatformDetector\cf0 >();\par ??\par ?? Scan(x =>\par ?? \{\par ?? x.TheCallingAssembly();\par ?? x.With<\cf4 DefaultConventionScanner\cf0 >();\par ?? \});\par ??\par ?? registerRoutingActions();\par ?? registerSpecialCaseRoutes();\par ?? \}} +{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;}??\fs20 \cf3 private\cf0 \cf3 readonly\cf0 \cf4 ActionRegistry\cf0 _actionRegistry = \cf3 new\cf0 \cf4 ActionRegistry\cf0 ();\par ?? \cf3 private\cf0 \cf3 readonly\cf0 \cf4 ISpecialCaseRouteRegistry\cf0 _specialCaseRouteRegistry = \cf3 new\cf0 \cf4 SpecialCaseRouteRegistry\cf0 ();\par ?? \cf3 private\cf0 \cf3 readonly\cf0 \cf4 TypeRegistry\cf0 _typeRegistry = \cf3 new\cf0 \cf4 TypeRegistry\cf0 ();\par ?? \cf3 private\cf0 \cf3 readonly\cf0 \cf4 List\cf0 <\cf4 Type\cf0 > _workflowTypes = \cf3 new\cf0 \cf4 List\cf0 <\cf4 Type\cf0 >();\par ?? \cf3 private\cf0 \cf4 UrlGraph\cf0 _graph;\par ?? \cf3 private\cf0 \cf4 ControllerRegistry\cf0 _registry;\par ??\par ?? \cf3 public\cf0 WebRegistry(\cf4 ICollection\cf0 <\cf4 RouteBase\cf0 > routes)\par ?? \{\par ?? createUrlGraph(routes);\par ??\par ?? ForRequestedType<\cf4 IUrlRegistry\cf0 >().TheDefault.Is.Object(_graph);\par ?? ForRequestedType<\cf4 IActionRegistry\cf0 >().TheDefault.Is.Object(_actionRegistry);\par ?? ForRequestedType<\cf4 ITypeRegistry\cf0 >().TheDefault.Is.Object(_typeRegistry);\par ?? ForRequestedType<\cf4 ITypeReport\cf0 >().TheDefaultIsConcreteType<\cf4 WorkflowItemTypeReport\cf0 >();\par ?? ForRequestedType<\cf4 ISpecialCaseRouteRegistry\cf0 >().TheDefault.Is.Object(_specialCaseRouteRegistry);\par ??\par ?? ForRequestedType<\cf4 ILogViewerRegistry\cf0 >()\par ?? .Use<\cf4 LogViewerRegistry\cf0 >();\par ??\par ?? ForRequestedType<\cf4 IWebPlatformDetector\cf0 >().TheDefaultIsConcreteType<\cf4 MobileWebPlatformDetector\cf0 >();\par ??\par ?? Scan(x =>\par ?? \{\par ?? x.TheCallingAssembly();\par ?? x.With<\cf4 DefaultConventionScanner\cf0 >();\par ?? \});\par ??\par ?? registerRoutingActions();\par ?? registerSpecialCaseRoutes();\par ?? \}} --> <div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;"> <p style="margin: 0px;"> @@ -770,7 +770,7 @@ <p>The Object() method is the pertinant method in the InstanceExpression. There is also an alternative syntax called "IsThis":</p> <!-- -{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;\red163\green21\blue21;}??\fs20 \cf3 var\cf0 container = \cf3 new\cf0 \cf4 Container\cf0 (x =>\par ?? \{\par ?? x.ForRequestedType<\cf4 ClassWithDependency\cf0 >().TheDefault.Is.OfConcreteType<\cf4 ClassWithDependency\cf0 >()\par ?? .TheArrayOf<\cf4 Rule\cf0 >().Contains(arr =>\par ?? \{\par ?? arr.IsThis(\cf3 new\cf0 \cf4 ColorRule\cf0 (\cf5 "Red"\cf0 ));\par ?? \});\par ?? \});} +{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;\red163\green21\blue21;}??\fs20 \cf3 var\cf0 container = \cf3 new\cf0 \cf4 Container\cf0 (x =>\par ?? \{\par ?? x.ForRequestedType<\cf4 ClassWithDependency\cf0 >().Use<\cf4 ClassWithDependency\cf0 >()\par ?? .TheArrayOf<\cf4 Rule\cf0 >().Contains(arr =>\par ?? \{\par ?? arr.IsThis(\cf3 new\cf0 \cf4 ColorRule\cf0 (\cf5 "Red"\cf0 ));\par ?? \});\par ?? \});} --> <div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;"> <p style="margin: 0px;"> @@ -781,7 +781,7 @@ {</p> <p style="margin: 0px;"> - x.ForRequestedType<<span style="color: #2b91af;">ClassWithDependency</span>>().TheDefault.Is.OfConcreteType<<span + x.ForRequestedType<<span style="color: #2b91af;">ClassWithDependency</span>>().Use<<span style="color: #2b91af;">ClassWithDependency</span>>()</p> <p style="margin: 0px;"> @@ -860,7 +860,7 @@ when configuring array dependencies or overriding the autowiring defaults. Use the TheInstanceNamed() function as shown below to do this:</p> <!-- -{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red0\green0\blue255;\red163\green21\blue21;}??\fs20 \cf3 IContainer\cf0 manager = \cf4 new\cf0 \cf3 Container\cf0 (r =>\par ?? \{\par ?? r.InstanceOf<\cf3 IHandler\cf0 >().Is.OfConcreteType<\cf3 Handler1\cf0 >().WithName(\cf5 "One"\cf0 );\par ?? r.InstanceOf<\cf3 IHandler\cf0 >().Is.OfConcreteType<\cf3 Handler2\cf0 >().WithName(\cf5 "Two"\cf0 );\par ??\par ?? r.ForRequestedType<\cf3 Processor\cf0 >().TheDefault.Is.OfConcreteType<\cf3 Processor\cf0 >()\par ?? .WithCtorArg(\cf5 "name"\cf0 ).EqualTo(\cf5 "Jeremy"\cf0 )\par ?? .TheArrayOf<\cf3 IHandler\cf0 >().Contains(x =>\par ?? \{\par ?? x.TheInstanceNamed(\cf5 "Two"\cf0 );\par ?? x.TheInstanceNamed(\cf5 "One"\cf0 );\par ?? \});\par ?? \});} +{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red0\green0\blue255;\red163\green21\blue21;}??\fs20 \cf3 IContainer\cf0 manager = \cf4 new\cf0 \cf3 Container\cf0 (r =>\par ?? \{\par ?? r.InstanceOf<\cf3 IHandler\cf0 >().Is.OfConcreteType<\cf3 Handler1\cf0 >().WithName(\cf5 "One"\cf0 );\par ?? r.InstanceOf<\cf3 IHandler\cf0 >().Is.OfConcreteType<\cf3 Handler2\cf0 >().WithName(\cf5 "Two"\cf0 );\par ??\par ?? r.ForRequestedType<\cf3 Processor\cf0 >().Use<\cf3 Processor\cf0 >()\par ?? .WithCtorArg(\cf5 "name"\cf0 ).EqualTo(\cf5 "Jeremy"\cf0 )\par ?? .TheArrayOf<\cf3 IHandler\cf0 >().Contains(x =>\par ?? \{\par ?? x.TheInstanceNamed(\cf5 "Two"\cf0 );\par ?? x.TheInstanceNamed(\cf5 "One"\cf0 );\par ?? \});\par ?? \});} --> <div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;"> <p style="margin: 0px;"> @@ -883,7 +883,7 @@ </p> <p style="margin: 0px;"> - r.ForRequestedType<<span style="color: #2b91af;">Processor</span>>().TheDefault.Is.OfConcreteType<<span + r.ForRequestedType<<span style="color: #2b91af;">Processor</span>>().Use<<span style="color: #2b91af;">Processor</span>>()</p> <p style="margin: 0px;"> Modified: trunk/Source/HTML/Interception.htm =================================================================== --- trunk/Source/HTML/Interception.htm 2010-02-03 23:16:32 UTC (rev 328) +++ trunk/Source/HTML/Interception.htm 2010-02-04 00:33:40 UTC (rev 329) @@ -329,7 +329,7 @@ <h2>Apply Interception to all Instances of a PluginType</h2> <p>The same OnCreation(), EnrichWith(), and InterceptWith() methods can be applied - to all Instances of a given PluginType off of the For() or + to all Instances of a given PluginType off of the ForRequestedType() or BuildInstancesOf() methods of the <a href="RegistryDSL.htm">Registry DSL</a>:</p> <!-- {\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green128\blue0;\red43\green145\blue175;\red0\green0\blue255;}??\fs20 \cf3 // Place the Interception at the PluginType level\par ??\cf0 ForRequestedType<\cf4 IConnectionListener\cf0 >()\par ?? .OnCreation(x => x.StartConnection()) \cf3 // OnCreation\par ??\cf0 .EnrichWith(x => \cf5 new\cf0 \cf4 LoggingDecorator\cf0 (x)) \cf3 // Enrich\par ??\cf0 .InterceptWith(\cf5 new\cf0 \cf4 CustomInterceptor\cf0 ()) \cf3 // Custom Interceptor\par ??\par ??\par ??\cf0 .TheDefaultIsConcreteType<\cf4 ClassThatNeedsSomeBootstrapping\cf0 >();} Modified: trunk/Source/HTML/QuickStart.htm =================================================================== --- trunk/Source/HTML/QuickStart.htm 2010-02-03 23:16:32 UTC (rev 328) +++ trunk/Source/HTML/QuickStart.htm 2010-02-04 00:33:40 UTC (rev 329) @@ -223,7 +223,7 @@ {</p> <p style="MARGIN: 0px"> - x.ForRequestedType<<span style="COLOR: #2b91af">IRepository</span>>().TheDefault.Is.OfConcreteType<<span + x.ForRequestedType<<span style="COLOR: #2b91af">IRepository</span>>().Use<<span style="COLOR: #2b91af">Repository</span>>()</p> <p style="MARGIN: 0px"> @@ -241,7 +241,7 @@ AppSettings</span></p> <p style="MARGIN: 0px"> - x.ForRequestedType<<span style="COLOR: #2b91af">IRepository</span>>().TheDefault.Is.OfConcreteType<<span + x.ForRequestedType<<span style="COLOR: #2b91af">IRepository</span>>().Use<<span style="COLOR: #2b91af">Repository</span>>()</p> <p style="MARGIN: 0px"> @@ -339,7 +339,7 @@ <span style="COLOR: green">// Set up the IRepository</span></p> <p style="MARGIN: 0px"> - x.ForRequestedType<<span style="COLOR: #2b91af">IRepository</span>>().TheDefault.Is.OfConcreteType<<span + x.ForRequestedType<<span style="COLOR: #2b91af">IRepository</span>>().Use<<span style="COLOR: #2b91af">Repository</span>>()</p> <p style="MARGIN: 0px"> @@ -402,7 +402,7 @@ </p> <p style="MARGIN: 0px"> - x.ForRequestedType<<span style="COLOR: #2b91af">IRepository</span>>().TheDefault.Is.OfConcreteType<<span + x.ForRequestedType<<span style="COLOR: #2b91af">IRepository</span>>().Use<<span style="COLOR: #2b91af">Repository</span>>()</p> <p style="MARGIN: 0px"> @@ -458,7 +458,7 @@ </p> <p style="MARGIN: 0px"> - x.ForRequestedType<<span style="COLOR: #2b91af">IRepository</span>>().TheDefault.Is.OfConcreteType<<span + x.ForRequestedType<<span style="COLOR: #2b91af">IRepository</span>>().Use<<span style="COLOR: #2b91af">Repository</span>>()</p> <p style="MARGIN: 0px"> @@ -508,7 +508,7 @@ {</p> <p style="MARGIN: 0px"> - x.ForRequestedType<<span style="COLOR: #2b91af">IRepository</span>>().TheDefault.Is.OfConcreteType<<span + x.ForRequestedType<<span style="COLOR: #2b91af">IRepository</span>>().Use<<span style="COLOR: #2b91af">Repository</span>>();</p> <p style="MARGIN: 0px"> Modified: trunk/Source/HTML/RegistryDSL.htm =================================================================== --- trunk/Source/HTML/RegistryDSL.htm 2010-02-03 23:16:32 UTC (rev 328) +++ trunk/Source/HTML/RegistryDSL.htm 2010-02-04 00:33:40 UTC (rev 329) @@ -166,12 +166,12 @@ <p>The Registry class exposes these methods for configuration. Most of these methods are the root of a Fluent Interface expression.</p> <!-- -{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green128\blue0;\red43\green145\blue175;\red0\green0\blue255;}??\fs20 \cf3 // Registering Types -- BuildInstancesOf() and For() are Synonyms\par ??\cf0 \cf4 CreatePluginFamilyExpression\cf0 <PLUGINTYPE> BuildInstancesOf<PLUGINTYPE>();\par ?? \cf4 CreatePluginFamilyExpression\cf0 <PLUGINTYPE> ForRequestedType<PLUGINTYPE>();\par ?? \par ?? \cf4 GenericFamilyExpression\cf0 For(\cf4 Type\cf0 pluginType);\par ??\par ?? \cf3 // Shortcut for configuring the default configuration of a concrete type\par ??\cf0 \cf4 Registry\cf0 .\cf4 BuildWithExpression\cf0 <T> ForConcreteType<T>();\par ??\par ?? \cf3 // Adding additional Instances of a PluginType\par ??\cf0 \cf4 IsExpression\cf0 <T> InstanceOf<T>();\par ?? \cf4 GenericIsExpression\cf0 InstanceOf(\cf4 Type\cf0 pluginType);\par ??\par ?? \cf3 // Creating or Adding to a Profile\par ??\cf0 \cf4 ProfileExpression\cf0 CreateProfile(\cf5 string\cf0 profileName);\par ?? \cf5 void\cf0 CreateProfile(\cf5 string\cf0 profileName, \cf4 Action\cf0 <\cf4 ProfileExpression\cf0 > action);\par ??\par ?? \cf3 // Interception\par ??\cf0 \cf5 void\cf0 RegisterInterceptor(\cf4 TypeInterceptor\cf0 interceptor);\par ?? \cf4 MatchedTypeInterceptor\cf0 IfTypeMatches(\cf4 Predicate\cf0 <\cf4 Type\cf0 > match);\par ??\par ?? \cf3 // Type Scanning and Auto Registration\par ??\cf0 \cf5 void\cf0 Scan(\cf4 Action\cf0 <\cf4 IAssemblyScanner\cf0 > action);\par ??\par ?? \cf3 // Controlling Setter Injection Behavior\par ??\cf0 \cf4 CreatePluginFamilyExpression\cf0 <PLUGINTYPE> FillAllPropertiesOfType<PLUGINTYPE>();\par ?? \cf5 void\cf0 SetAllProperties(\cf4 Action\cf0 <\cf4 SetterConvention\cf0 > action);} +{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green128\blue0;\red43\green145\blue175;\red0\green0\blue255;}??\fs20 \cf3 // Registering Types -- BuildInstancesOf() and ForRequestedType() are Synonyms\par ??\cf0 \cf4 CreatePluginFamilyExpression\cf0 <PLUGINTYPE> BuildInstancesOf<PLUGINTYPE>();\par ?? \cf4 CreatePluginFamilyExpression\cf0 <PLUGINTYPE> ForRequestedType<PLUGINTYPE>();\par ?? \par ?? \cf4 GenericFamilyExpression\cf0 ForRequestedType(\cf4 Type\cf0 pluginType);\par ??\par ?? \cf3 // Shortcut for configuring the default configuration of a concrete type\par ??\cf0 \cf4 Registry\cf0 .\cf4 BuildWithExpression\cf0 <T> ForConcreteType<T>();\par ??\par ?? \cf3 // Adding additional Instances of a PluginType\par ??\cf0 \cf4 IsExpression\cf0 <T> InstanceOf<T>();\par ?? \cf4 GenericIsExpression\cf0 InstanceOf(\cf4 Type\cf0 pluginType);\par ??\par ?? \cf3 // Creating or Adding to a Profile\par ??\cf0 \cf4 ProfileExpression\cf0 CreateProfile(\cf5 string\cf0 profileName);\par ?? \cf5 void\cf0 CreateProfile(\cf5 string\cf0 profileName, \cf4 Action\cf0 <\cf4 ProfileExpression\cf0 > action);\par ??\par ?? \cf3 // Interception\par ??\cf0 \cf5 void\cf0 RegisterInterceptor(\cf4 TypeInterceptor\cf0 interceptor);\par ?? \cf4 MatchedTypeInterceptor\cf0 IfTypeMatches(\cf4 Predicate\cf0 <\cf4 Type\cf0 > match);\par ??\par ?? \cf3 // Type Scanning and Auto Registration\par ??\cf0 \cf5 void\cf0 Scan(\cf4 Action\cf0 <\cf4 IAssemblyScanner\cf0 > action);\par ??\par ?? \cf3 // Controlling Setter Injection Behavior\par ??\cf0 \cf4 CreatePluginFamilyExpression\cf0 <PLUGINTYPE> FillAllPropertiesOfType<PLUGINTYPE>();\par ?? \cf5 void\cf0 SetAllProperties(\cf4 Action\cf0 <\cf4 SetterConvention\cf0 > action);} --> <div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;"> <p style="margin: 0px;"> <span style="color: green;">// Registering Types -- - BuildInstancesOf() and For() are Synonyms</span></p> + BuildInstancesOf() and ForRequestedType() are Synonyms</span></p> <p style="margin: 0px;"> <span style="color: #2b91af;"> CreatePluginFamilyExpression</span><PLUGINTYPE> BuildInstancesOf<PLUGINTYPE>();</p> @@ -182,7 +182,7 @@ </p> <p style="margin: 0px;"> <span style="color: #2b91af;">GenericFamilyExpression</span> - For(<span style="color: #2b91af;">Type</span> pluginType);</p> + ForRequestedType(<span style="color: #2b91af;">Type</span> pluginType);</p> <p style="margin: 0px;"> </p> <p style="margin: 0px;"> @@ -289,7 +289,7 @@ object in other ways than a constructor function. In that case, you need to use something like this:</p> <!-- -{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green128\blue0;\red43\green145\blue175;\red163\green21\blue21;}??\fs20 \cf3 // In this case, we need to specify the value of "connectionString" argument to\par ??\cf0 \cf3 // the constructor function\par ??\cf0 x.ForRequestedType<\cf4 DatabaseRepository\cf0 >().TheDefault.Is.OfConcreteType<\cf4 DatabaseRepository\cf0 >()\par ?? .WithCtorArg(\cf5 "connectionString"\cf0 ).EqualToAppSetting(\cf5 "connectionString"\cf0 );} +{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green128\blue0;\red43\green145\blue175;\red163\green21\blue21;}??\fs20 \cf3 // In this case, we need to specify the value of "connectionString" argument to\par ??\cf0 \cf3 // the constructor function\par ??\cf0 x.ForRequestedType<\cf4 DatabaseRepository\cf0 >().Use<\cf4 DatabaseRepository\cf0 >()\par ?? .WithCtorArg(\cf5 "connectionString"\cf0 ).EqualToAppSetting(\cf5 "connectionString"\cf0 );} --> <div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;"> <p style="margin: 0px;"> @@ -301,7 +301,7 @@ <span style="color: green;">// the constructor function</span></p> <p style="margin: 0px;"> - x.ForRequestedType<<span style="color: #2b91af;">DatabaseRepository</span>>().TheDefault.Is.OfConcreteType<<span + x.ForRequestedType<<span style="color: #2b91af;">DatabaseRepository</span>>().Use<<span style="color: #2b91af;">DatabaseRepository</span>>()</p> <p style="margin: 0px;"> @@ -319,7 +319,7 @@ cannot use the generic ForRequestedType<T>() method. For example, with open generic types, you have to use this syntax:</p> <!-- -{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;}??\fs20 \cf3 var\cf0 container = \cf3 new\cf0 \cf4 Container\cf0 (r =>\par ?? \{\par ?? r.For(\cf3 typeof\cf0 (\cf4 IRepository\cf0 <>)).TheDefaultIsConcreteType(\cf3 typeof\cf0 (\cf4 OnlineRepository\cf0 <>));\par ?? \});} +{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;}??\fs20 \cf3 var\cf0 container = \cf3 new\cf0 \cf4 Container\cf0 (r =>\par ?? \{\par ?? r.ForRequestedType(\cf3 typeof\cf0 (\cf4 IRepository\cf0 <>)).TheDefaultIsConcreteType(\cf3 typeof\cf0 (\cf4 OnlineRepository\cf0 <>));\par ?? \});} --> <div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;"> <p style="margin: 0px;"> @@ -330,7 +330,7 @@ {</p> <p style="margin: 0px;"> - r.For(<span style="color: blue;">typeof</span> (<span + r.ForRequestedType(<span style="color: blue;">typeof</span> (<span style="color: #2b91af;">IRepository</span><>)).TheDefaultIsConcreteType(<span style="color: blue;">typeof</span> (<span style="color: #2b91af;">OnlineRepository</span><>));</p> <p style="margin: 0px;"> @@ -638,7 +638,7 @@ build an instance of the DatabaseRepository class. We could register this class like this:</p> <!-- -{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red163\green21\blue21;}??\fs20 \cf3 ObjectFactory\cf0 .Initialize(x =>\par ?? \{\par ?? x.ForRequestedType<\cf3 DatabaseRepository\cf0 >().TheDefault.Is.OfConcreteType<\cf3 DatabaseRepository\cf0 >()\par ?? .WithCtorArg(\cf4 "connectionString"\cf0 ).EqualToAppSetting(\cf4 "connectionString"\cf0 );\par ?? \});} +{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red43\green145\blue175;\red163\green21\blue21;}??\fs20 \cf3 ObjectFactory\cf0 .Initialize(x =>\par ?? \{\par ?? x.ForRequestedType<\cf3 DatabaseRepository\cf0 >().Use<\cf3 DatabaseRepository\cf0 >()\par ?? .WithCtorArg(\cf4 "connectionString"\cf0 ).EqualToAppSetting(\cf4 "connectionString"\cf0 );\par ?? \});} --> <div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;"> <p style="margin: 0px;"> @@ -648,7 +648,7 @@ {</p> <p style="margin: 0px;"> - x.ForRequestedType<<span style="color: #2b91af;">DatabaseRepository</span>>().TheDefault.Is.OfConcreteType<<span + x.ForRequestedType<<span style="color: #2b91af;">DatabaseRepository</span>>().Use<<span style="color: #2b91af;">DatabaseRepository</span>>()</p> <p style="margin: 0px;"> Modified: trunk/Source/HTML/ScanningAssemblies.htm =================================================================== --- trunk/Source/HTML/ScanningAssemblies.htm 2010-02-03 23:16:32 UTC (rev 328) +++ trunk/Source/HTML/ScanningAssemblies.htm 2010-02-04 00:33:40 UTC (rev 329) @@ -333,7 +333,7 @@ The most common usage is probably just specifying "this" assembly with IAssemblyScanner.TheCallingAssembly():</p> <!-- -{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;\red0\green128\blue0;}??\fs20 \cf3 public\cf0 \cf3 class\cf0 \cf4 WebCoreRegistry\cf0 : \cf4 Registry\par ??\cf0 \{\par ?? \cf3 protected\cf0 \cf3 override\cf0 \cf3 void\cf0 configure()\par ?? \{\par ?? ForRequestedType<\cf4 ICachedSet\cf0 >().TheDefaultIsConcreteType<\cf4 CachedSet\cf0 >().CacheBy(\cf4 InstanceScope\cf0 .Hybrid);\par ?? ForRequestedType<\cf4 IControlBuilder\cf0 >().TheDefault.Is.OfConcreteType<\cf4 AspNetControlBuilder\cf0 >();\par ?? ForRequestedType<\cf4 IPartialRenderer\cf0 >().TheDefault.Is.OfConcreteType<\cf4 PartialRenderer\cf0 >();\par ??\par ?? Scan(x =>\par ?? \{\par ?? \cf5 // Scan "this" assembly. In other words, the assembly that \par ??\cf0 \cf5 // contains the WebCoreRegistry class\par ??\cf0 x.TheCallingAssembly();\par ??\par ?? x.IncludeNamespaceContainingType<\cf4 AuthenticationContext\cf0 >();\par ?? x.IncludeNamespaceContainingType<\cf4 ISecurityDataService\cf0 >();\par ??\par ?? x.WithDefaultConventions();\par ?? \});\par ?? \}\par ?? \}} +{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;\red0\green128\blue0;}??\fs20 \cf3 public\cf0 \cf3 class\cf0 \cf4 WebCoreRegistry\cf0 : \cf4 Registry\par ??\cf0 \{\par ?? \cf3 protected\cf0 \cf3 override\cf0 \cf3 void\cf0 configure()\par ?? \{\par ?? ForRequestedType<\cf4 ICachedSet\cf0 >().TheDefaultIsConcreteType<\cf4 CachedSet\cf0 >().CacheBy(\cf4 InstanceScope\cf0 .Hybrid);\par ?? ForRequestedType<\cf4 IControlBuilder\cf0 >().Use<\cf4 AspNetControlBuilder\cf0 >();\par ?? ForRequestedType<\cf4 IPartialRenderer\cf0 >().Use<\cf4 PartialRenderer\cf0 >();\par ??\par ?? Scan(x =>\par ?? \{\par ?? \cf5 // Scan "this" assembly. In other words, the assembly that \par ??\cf0 \cf5 // contains the WebCoreRegistry class\par ??\cf0 x.TheCallingAssembly();\par ??\par ?? x.IncludeNamespaceContainingType<\cf4 AuthenticationContext\cf0 >();\par ?? x.IncludeNamespaceContainingType<\cf4 ISecurityDataService\cf0 >();\par ??\par ?? x.WithDefaultConventions();\par ?? \});\par ?? \}\par ?? \}} --> <div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;"> <p style="margin: 0px;"> @@ -355,11 +355,11 @@ style="color: #2b91af;">InstanceScope</span>.Hybrid);</p> <p style="margin: 0px;"> ForRequestedType<<span - style="color: #2b91af;">IControlBuilder</span>>().TheDefault.Is.OfConcreteType<<span + style="color: #2b91af;">IControlBuilder</span>>().Use<<span style="color: #2b91af;">AspNetControlBuilder</span>>();</p> <p style="margin: 0px;"> ForRequestedType<<span - style="color: #2b91af;">IPartialRenderer</span>>().TheDefault.Is.OfConcreteType<<span + style="color: #2b91af;">IPartialRenderer</span>>().Use<<span style="color: #2b91af;">PartialRenderer</span>>();</p> <p style="margin: 0px;"> </p> @@ -686,7 +686,7 @@ project (in other words, the scenario that forced us to overhaul the StructureMap auto registration):</p> <!-- -{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue0;\red255\green255\blue255;\red0\green0\blue255;\red43\green145\blue175;\red163\green21\blue21;\red0\green12... [truncated message content] |
From: <jer...@us...> - 2010-02-04 02:35:32
|
Revision: 330 http://structuremap.svn.sourceforge.net/structuremap/?rev=330&view=rev Author: jeremydmiller Date: 2010-02-04 00:51:33 +0000 (Thu, 04 Feb 2010) Log Message: ----------- committed a patch from Frank Quednau related to open generics types Modified Paths: -------------- trunk/Source/StructureMap/Graph/PluginFamily.cs trunk/Source/StructureMap/Pipeline/ConstructorInstance.cs trunk/Source/StructureMap/TypeExtensions.cs trunk/Source/StructureMap.Testing/GenericsAcceptanceTester.cs trunk/Source/StructureMap.Testing/Graph/DynamicInjectionTester.cs Modified: trunk/Source/StructureMap/Graph/PluginFamily.cs =================================================================== --- trunk/Source/StructureMap/Graph/PluginFamily.cs 2010-02-04 00:33:40 UTC (rev 329) +++ trunk/Source/StructureMap/Graph/PluginFamily.cs 2010-02-04 00:51:33 UTC (rev 330) @@ -288,9 +288,15 @@ return clone; }).Where(x => x != null).Each(templatedFamily.AddInstance); + //Are there instances that close the templatedtype straight away? + _instances.GetAll() + .Where(x => x.ConcreteType.CanBeCastTo(templatedType)) + .Each(templatedFamily.AddInstance); + // Need to attach the new PluginFamily to the old PluginGraph Parent.PluginFamilies.Add(templatedFamily); + return templatedFamily; } @@ -363,4 +369,4 @@ #endregion } -} \ No newline at end of file +} Modified: trunk/Source/StructureMap/Pipeline/ConstructorInstance.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/ConstructorInstance.cs 2010-02-04 00:33:40 UTC (rev 329) +++ trunk/Source/StructureMap/Pipeline/ConstructorInstance.cs 2010-02-04 00:51:33 UTC (rev 330) @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.Globalization; using System.Linq; using StructureMap.Construction; using StructureMap.Graph; @@ -198,7 +199,7 @@ if (value.GetType() == dependencyType) return new ObjectInstance(value); TypeConverter converter = TypeDescriptor.GetConverter(dependencyType); - object convertedValue = converter.ConvertFrom(value); + object convertedValue = converter.ConvertFrom(null, CultureInfo.InvariantCulture, value); return new ObjectInstance(convertedValue); } catch (Exception e) @@ -276,4 +277,4 @@ return "'{0}' -> {1}".ToFormat(Name, _plugin.PluggedType.FullName); } } -} \ No newline at end of file +} Modified: trunk/Source/StructureMap/TypeExtensions.cs =================================================================== --- trunk/Source/StructureMap/TypeExtensions.cs 2010-02-04 00:33:40 UTC (rev 329) +++ trunk/Source/StructureMap/TypeExtensions.cs 2010-02-04 00:51:33 UTC (rev 330) @@ -181,7 +181,7 @@ return false; } - if (pluginType.IsOpenGeneric() && pluggedType.IsGenericType) + if (pluginType.IsOpenGeneric()) { return GenericsPluginGraph.CanBeCast(pluginType, pluggedType); } @@ -257,4 +257,4 @@ } } } -} \ No newline at end of file +} Modified: trunk/Source/StructureMap.Testing/GenericsAcceptanceTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/GenericsAcceptanceTester.cs 2010-02-04 00:33:40 UTC (rev 329) +++ trunk/Source/StructureMap.Testing/GenericsAcceptanceTester.cs 2010-02-04 00:51:33 UTC (rev 330) @@ -157,6 +157,13 @@ } [Test] + public void CanPlugConcreteNonGenericClassIntoGenericInterface() + { + typeof(NotSoGenericService).CanBeCastTo(typeof(IGenericService<>)) + .ShouldBeTrue(); + } + + [Test] public void Define_profile_with_generics_and_concrete_type() { var container = new Container(registry => @@ -306,4 +313,9 @@ return typeof (T); } } -} \ No newline at end of file + + public class NotSoGenericService : IGenericService<string> + { + public void DoSomething(string thing) { } + } +} Modified: trunk/Source/StructureMap.Testing/Graph/DynamicInjectionTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Graph/DynamicInjectionTester.cs 2010-02-04 00:33:40 UTC (rev 329) +++ trunk/Source/StructureMap.Testing/Graph/DynamicInjectionTester.cs 2010-02-04 00:51:33 UTC (rev 330) @@ -37,7 +37,15 @@ public class Service3<T> : IService<T> { } + + public interface IOtherService<T> + { + } + public class Service4 : IOtherService<string> + { + } + [PluginFamily("Default")] public interface IThingy { @@ -134,6 +142,22 @@ } [Test] + public void Add_an_assembly_on_the_fly_and_pick_up_plugins4() + { + var container = new Container(); + container.Configure( + registry => registry.Scan( + x => + { + x.AssemblyContainingType(typeof (IOtherService<>)); + x.AddAllTypesOf(typeof (IOtherService<>)); + })); + + var instances = container.GetAllInstances<IOtherService<string>>(); + instances.Any(s=> s is Service4).ShouldBeTrue(); + } + + [Test] public void Add_generic_stuff_in_configure() { var container = new Container(); @@ -331,4 +355,4 @@ throw new NotImplementedException(); } } -} \ No newline at end of file +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2010-02-04 02:35:32
|
Revision: 331 http://structuremap.svn.sourceforge.net/structuremap/?rev=331&view=rev Author: jeremydmiller Date: 2010-02-04 00:52:26 +0000 (Thu, 04 Feb 2010) Log Message: ----------- backing it up to 2.6 in the cruise.build file Modified Paths: -------------- trunk/cruise.build Modified: trunk/cruise.build =================================================================== --- trunk/cruise.build 2010-02-04 00:51:33 UTC (rev 330) +++ trunk/cruise.build 2010-02-04 00:52:26 UTC (rev 331) @@ -4,7 +4,7 @@ <property name="deployment.dir" value="source\StructureMap.Testing.DeploymentTasks\"/> <property name="results.dir" value="results" /> <property name="nant.dir" value="bin\nant" /> - <property name="project.version" value="3.0.0" /> + <property name="project.version" value="2.6.0" /> <property name="project.config" value="release" /> <property name="archive.dir" value="archive"/> <target name="all" depends="compile, unit-test, post-clean"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2010-02-04 02:35:31
|
Revision: 332 http://structuremap.svn.sourceforge.net/structuremap/?rev=332&view=rev Author: jeremydmiller Date: 2010-02-04 00:56:59 +0000 (Thu, 04 Feb 2010) Log Message: ----------- patch from Kyle Malloy that adds IContext.BuildUp() and fixes a bug where Lifecycle was not correctly set from a Configure() block Modified Paths: -------------- trunk/Source/StructureMap/BuildSession.cs trunk/Source/StructureMap/Graph/PluginFamily.cs trunk/Source/StructureMap/IContext.cs trunk/Source/StructureMap.Testing/Graph/PluginFamilyTester.cs Modified: trunk/Source/StructureMap/BuildSession.cs =================================================================== --- trunk/Source/StructureMap/BuildSession.cs 2010-02-04 00:52:26 UTC (rev 331) +++ trunk/Source/StructureMap/BuildSession.cs 2010-02-04 00:56:59 UTC (rev 332) @@ -5,6 +5,7 @@ using StructureMap.Interceptors; using StructureMap.Pipeline; using StructureMap.Util; +using StructureMap.Construction; namespace StructureMap { @@ -61,6 +62,17 @@ } } + public void BuildUp(object target) + { + Type pluggedType = target.GetType(); + IConfiguredInstance instance = _pipelineGraph.GetDefault(pluggedType) as IConfiguredInstance + ?? new ConfiguredInstance(pluggedType); + + IInstanceBuilder builder = PluginCache.FindBuilder(pluggedType); + var arguments = new Arguments(instance, this); + builder.BuildUp(arguments, target); + } + public T GetInstance<T>() { return (T) CreateInstance(typeof (T)); @@ -186,4 +198,4 @@ return _pipelineGraph.ForType(pluginType); } } -} \ No newline at end of file +} Modified: trunk/Source/StructureMap/Graph/PluginFamily.cs =================================================================== --- trunk/Source/StructureMap/Graph/PluginFamily.cs 2010-02-04 00:52:26 UTC (rev 331) +++ trunk/Source/StructureMap/Graph/PluginFamily.cs 2010-02-04 00:56:59 UTC (rev 332) @@ -242,6 +242,11 @@ public void ImportFrom(PluginFamily source) { + if (source.Lifecycle != null) + { + SetScopeTo(source.Lifecycle); + } + source.Instances.Each(instance => _instances.Fill(instance.Name, instance)); source._pluggedTypes.Each((key, plugin) => _pluggedTypes.Fill(key, plugin)); Modified: trunk/Source/StructureMap/IContext.cs =================================================================== --- trunk/Source/StructureMap/IContext.cs 2010-02-04 00:52:26 UTC (rev 331) +++ trunk/Source/StructureMap/IContext.cs 2010-02-04 00:56:59 UTC (rev 332) @@ -27,6 +27,14 @@ string RequestedName { get; } /// <summary> + /// The "BuildUp" method takes in an already constructed object + /// and uses Setter Injection to push in configured dependencies + /// of that object + /// </summary> + /// <param name="target"></param> + void BuildUp(object target); + + /// <summary> /// Get the object of type T that is valid for this build session. /// </summary> /// <typeparam name="T"></typeparam> @@ -81,4 +89,4 @@ /// <returns></returns> IEnumerable<T> GetAllInstances<T>(); } -} \ No newline at end of file +} Modified: trunk/Source/StructureMap.Testing/Graph/PluginFamilyTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Graph/PluginFamilyTester.cs 2010-02-04 00:52:26 UTC (rev 331) +++ trunk/Source/StructureMap.Testing/Graph/PluginFamilyTester.cs 2010-02-04 00:56:59 UTC (rev 332) @@ -281,6 +281,18 @@ family.SetScopeTo(InstanceScope.ThreadLocal); Assert.IsInstanceOfType(typeof (ThreadLocalStorageLifecycle), family.Lifecycle); } + + [Test] + public void Lifecycle_is_imported_from_the_source_when_merging_PluginFamilies() + { + var source = new PluginFamily(typeof(GenericType<>)); + source.SetScopeTo(InstanceScope.Unique); + var importInto = new PluginFamily(typeof(GenericType<>)); + + importInto.ImportFrom(source); + + importInto.Lifecycle.ShouldBeOfType(source.Lifecycle.GetType()); + } } @@ -313,4 +325,6 @@ public interface IDevice { } -} \ No newline at end of file + + public class GenericType<T> { } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2010-02-04 02:35:13
|
Revision: 333 http://structuremap.svn.sourceforge.net/structuremap/?rev=333&view=rev Author: jeremydmiller Date: 2010-02-04 01:24:52 +0000 (Thu, 04 Feb 2010) Log Message: ----------- finally fixed the issue w/ the lifecycle being displayed incorrectly in WhatDoIHave() Modified Paths: -------------- trunk/Source/StructureMap/Diagnostics/WhatDoIHaveWriter.cs trunk/Source/StructureMap.Testing/Graph/ConventionBasedSetterInjectionTester.cs Modified: trunk/Source/StructureMap/Diagnostics/WhatDoIHaveWriter.cs =================================================================== --- trunk/Source/StructureMap/Diagnostics/WhatDoIHaveWriter.cs 2010-02-04 00:56:59 UTC (rev 332) +++ trunk/Source/StructureMap/Diagnostics/WhatDoIHaveWriter.cs 2010-02-04 01:24:52 UTC (rev 333) @@ -82,11 +82,11 @@ if (pluginType.Lifecycle != null) { - _writer.AddContent("Scoped as: " + pluginType.Lifecycle.GetType().Name); + _writer.AddContent("Scoped as: " + pluginType.Lifecycle); } else { - _writer.AddContent("Scoped as: PerRequest"); + _writer.AddContent("Scoped as: PerRequest/Transient"); } foreach (InstanceRef instance in pluginType.Instances) Modified: trunk/Source/StructureMap.Testing/Graph/ConventionBasedSetterInjectionTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Graph/ConventionBasedSetterInjectionTester.cs 2010-02-04 00:56:59 UTC (rev 332) +++ trunk/Source/StructureMap.Testing/Graph/ConventionBasedSetterInjectionTester.cs 2010-02-04 01:24:52 UTC (rev 333) @@ -40,6 +40,9 @@ plugin.Setters.IsMandatory("LastName").ShouldBeTrue(); plugin.Setters.IsMandatory("Gateway").ShouldBeFalse(); plugin.Setters.IsMandatory("Service").ShouldBeFalse(); + + + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2010-02-03 23:16:39
|
Revision: 328 http://structuremap.svn.sourceforge.net/structuremap/?rev=328&view=rev Author: jeremydmiller Date: 2010-02-03 23:16:32 +0000 (Wed, 03 Feb 2010) Log Message: ----------- Applied a patch from Frank Quednau related to applying closed types to a generic interface Modified Paths: -------------- branches/2.5.4/Source/StructureMap/Graph/PluginFamily.cs branches/2.5.4/Source/StructureMap/Pipeline/ConstructorInstance.cs branches/2.5.4/Source/StructureMap/TypeExtensions.cs branches/2.5.4/Source/StructureMap.Testing/GenericsAcceptanceTester.cs branches/2.5.4/Source/StructureMap.Testing/Graph/DynamicInjectionTester.cs Modified: branches/2.5.4/Source/StructureMap/Graph/PluginFamily.cs =================================================================== --- branches/2.5.4/Source/StructureMap/Graph/PluginFamily.cs 2010-01-30 22:08:48 UTC (rev 327) +++ branches/2.5.4/Source/StructureMap/Graph/PluginFamily.cs 2010-02-03 23:16:32 UTC (rev 328) @@ -288,9 +288,15 @@ return clone; }).Where(x => x != null).Each(templatedFamily.AddInstance); + //Are there instances that close the templatedtype straight away? + _instances.GetAll() + .Where(x => x.ConcreteType.CanBeCastTo(templatedType)) + .Each(templatedFamily.AddInstance); + // Need to attach the new PluginFamily to the old PluginGraph Parent.PluginFamilies.Add(templatedFamily); + return templatedFamily; } @@ -363,4 +369,4 @@ #endregion } -} \ No newline at end of file +} Modified: branches/2.5.4/Source/StructureMap/Pipeline/ConstructorInstance.cs =================================================================== --- branches/2.5.4/Source/StructureMap/Pipeline/ConstructorInstance.cs 2010-01-30 22:08:48 UTC (rev 327) +++ branches/2.5.4/Source/StructureMap/Pipeline/ConstructorInstance.cs 2010-02-03 23:16:32 UTC (rev 328) @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.ComponentModel; +using System.Globalization; using System.Linq; using StructureMap.Construction; using StructureMap.Graph; @@ -198,7 +199,7 @@ if (value.GetType() == dependencyType) return new ObjectInstance(value); TypeConverter converter = TypeDescriptor.GetConverter(dependencyType); - object convertedValue = converter.ConvertFrom(value); + object convertedValue = converter.ConvertFrom(null, CultureInfo.InvariantCulture, value); return new ObjectInstance(convertedValue); } catch (Exception e) @@ -276,4 +277,4 @@ return "'{0}' -> {1}".ToFormat(Name, _plugin.PluggedType.FullName); } } -} \ No newline at end of file +} Modified: branches/2.5.4/Source/StructureMap/TypeExtensions.cs =================================================================== --- branches/2.5.4/Source/StructureMap/TypeExtensions.cs 2010-01-30 22:08:48 UTC (rev 327) +++ branches/2.5.4/Source/StructureMap/TypeExtensions.cs 2010-02-03 23:16:32 UTC (rev 328) @@ -181,7 +181,7 @@ return false; } - if (pluginType.IsOpenGeneric() && pluggedType.IsGenericType) + if (pluginType.IsOpenGeneric()) { return GenericsPluginGraph.CanBeCast(pluginType, pluggedType); } @@ -257,4 +257,4 @@ } } } -} \ No newline at end of file +} Modified: branches/2.5.4/Source/StructureMap.Testing/GenericsAcceptanceTester.cs =================================================================== --- branches/2.5.4/Source/StructureMap.Testing/GenericsAcceptanceTester.cs 2010-01-30 22:08:48 UTC (rev 327) +++ branches/2.5.4/Source/StructureMap.Testing/GenericsAcceptanceTester.cs 2010-02-03 23:16:32 UTC (rev 328) @@ -157,6 +157,13 @@ } [Test] + public void CanPlugConcreteNonGenericClassIntoGenericInterface() + { + typeof(NotSoGenericService).CanBeCastTo(typeof(IGenericService<>)) + .ShouldBeTrue(); + } + + [Test] public void Define_profile_with_generics_and_concrete_type() { var container = new Container(registry => @@ -306,4 +313,9 @@ return typeof (T); } } -} \ No newline at end of file + + public class NotSoGenericService : IGenericService<string> + { + public void DoSomething(string thing) { } + } +} Modified: branches/2.5.4/Source/StructureMap.Testing/Graph/DynamicInjectionTester.cs =================================================================== --- branches/2.5.4/Source/StructureMap.Testing/Graph/DynamicInjectionTester.cs 2010-01-30 22:08:48 UTC (rev 327) +++ branches/2.5.4/Source/StructureMap.Testing/Graph/DynamicInjectionTester.cs 2010-02-03 23:16:32 UTC (rev 328) @@ -47,7 +47,15 @@ public class Service3<T> : IService<T> { } + + public interface IOtherService<T> + { + } + public class Service4 : IOtherService<string> + { + } + [PluginFamily("Default")] public interface IThingy { @@ -151,6 +159,22 @@ } [Test] + public void Add_an_assembly_on_the_fly_and_pick_up_plugins4() + { + var container = new Container(); + container.Configure( + registry => registry.Scan( + x => + { + x.AssemblyContainingType(typeof (IOtherService<>)); + x.AddAllTypesOf(typeof (IOtherService<>)); + })); + + var instances = container.GetAllInstances<IOtherService<string>>(); + instances.Any(s=> s is Service4).ShouldBeTrue(); + } + + [Test] public void Add_generic_stuff_in_configure() { var container = new Container(); @@ -346,4 +370,4 @@ throw new NotImplementedException(); } } -} \ No newline at end of file +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fli...@us...> - 2010-01-30 22:08:54
|
Revision: 327 http://structuremap.svn.sourceforge.net/structuremap/?rev=327&view=rev Author: flimflan Date: 2010-01-30 22:08:48 +0000 (Sat, 30 Jan 2010) Log Message: ----------- Changed some tests to use Container instead of ObjectFactory to make them more reliable Modified Paths: -------------- trunk/Source/StructureMap.Testing/Graph/DynamicInjectionTester.cs Modified: trunk/Source/StructureMap.Testing/Graph/DynamicInjectionTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Graph/DynamicInjectionTester.cs 2010-01-30 19:13:59 UTC (rev 326) +++ trunk/Source/StructureMap.Testing/Graph/DynamicInjectionTester.cs 2010-01-30 22:08:48 UTC (rev 327) @@ -12,16 +12,6 @@ [TestFixture] public class DynamicInjectionTester { - #region Setup/Teardown - - [SetUp] - public void SetUp() - { - ObjectFactory.Initialize(x => { }); - } - - #endregion - private readonly IService _red = new ColorService("Red"); private readonly IService _blue = new ColorService("Blue"); private readonly IService _orange = new ColorService("Orange"); @@ -93,14 +83,7 @@ x.AddAllTypesOf<IWidget>(); })); - IList<IWidget> instances = container.GetAllInstances<IWidget>(); - bool found = false; - foreach (IWidget widget in instances) - { - found |= widget.GetType().Equals(typeof (TheWidget)); - } - - Assert.IsTrue(found); + container.GetAllInstances<IWidget>().OfType<TheWidget>().Any().ShouldBeTrue(); } @@ -120,7 +103,7 @@ ); IList<IService<string>> instances = container.GetAllInstances<IService<string>>(); - instances.Count.ShouldBeGreaterThan(0); + instances.Count.ShouldEqual(3); } @@ -167,31 +150,32 @@ [Test] public void AddANewDefaultTypeForAPluginTypeThatAlreadyExists() { - ObjectFactory.Initialize(x => { x.For<ISomething>().TheDefaultIsConcreteType<SomethingTwo>(); }); + var container = new Container(x => { x.For<ISomething>().TheDefaultIsConcreteType<SomethingTwo>(); }); - ObjectFactory.Configure(x => { x.For<ISomething>().TheDefaultIsConcreteType<SomethingOne>(); }); + container.Configure(x => { x.For<ISomething>().TheDefaultIsConcreteType<SomethingOne>(); }); - ObjectFactory.GetInstance<ISomething>().ShouldBeOfType<SomethingOne>(); + container.GetInstance<ISomething>().ShouldBeOfType<SomethingOne>(); } [Test] public void AddANewDefaultTypeForAPluginTypeThatAlreadyExists2() { - ObjectFactory.Initialize(x => { x.For<ISomething>(); }); + var container = new Container(x => { x.For<ISomething>(); }); - ObjectFactory.Configure(x => { x.For<ISomething>().TheDefaultIsConcreteType<SomethingOne>(); }); + container.Configure(x => { x.For<ISomething>().TheDefaultIsConcreteType<SomethingOne>(); }); - Assert.IsInstanceOfType(typeof (SomethingOne), ObjectFactory.GetInstance<ISomething>()); + Assert.IsInstanceOfType(typeof(SomethingOne), container.GetInstance<ISomething>()); } [Test] - public void AddInstanceFromObjectFactory() + public void AddInstanceFromContainer() { var one = new SomethingOne(); - ObjectFactory.Inject<ISomething>(one); + var container = new Container(); + container.Inject<ISomething>(one); - Assert.AreSame(one, ObjectFactory.GetInstance<ISomething>()); + Assert.AreSame(one, container.GetInstance<ISomething>()); } [Test] @@ -215,7 +199,7 @@ [Test] public void AddNamedInstanceByType() { - ObjectFactory.Configure(r => + var container = new Container(r => { r.For<ISomething>().AddInstances(x => { @@ -224,8 +208,8 @@ }); }); - Assert.IsInstanceOfType(typeof (SomethingOne), ObjectFactory.GetNamedInstance<ISomething>("One")); - Assert.IsInstanceOfType(typeof (SomethingTwo), ObjectFactory.GetNamedInstance<ISomething>("Two")); + Assert.IsInstanceOfType(typeof(SomethingOne), container.GetInstance<ISomething>("One")); + Assert.IsInstanceOfType(typeof(SomethingTwo), container.GetInstance<ISomething>("Two")); } [Test] @@ -234,7 +218,7 @@ var one = new SomethingOne(); var two = new SomethingOne(); - ObjectFactory.Configure(r => + var container = new Container(r => { r.For<ISomething>().AddInstances(x => { @@ -243,8 +227,8 @@ }); }); - Assert.AreSame(one, ObjectFactory.GetNamedInstance<ISomething>("One")); - Assert.AreSame(two, ObjectFactory.GetNamedInstance<ISomething>("Two")); + Assert.AreSame(one, container.GetInstance<ISomething>("One")); + Assert.AreSame(two, container.GetInstance<ISomething>("Two")); } @@ -263,11 +247,11 @@ } [Test] - public void AddTypeThroughObjectFactory() + public void AddTypeThroughContainer() { - ObjectFactory.Initialize(x => { x.For<ISomething>().TheDefaultIsConcreteType<SomethingOne>(); }); + var container = new Container(x => { x.For<ISomething>().TheDefaultIsConcreteType<SomethingOne>(); }); - Assert.IsInstanceOfType(typeof (SomethingOne), ObjectFactory.GetInstance<ISomething>()); + Assert.IsInstanceOfType(typeof(SomethingOne), container.GetInstance<ISomething>()); } [Test] @@ -284,10 +268,10 @@ [Test] public void InjectType() { - ObjectFactory.Configure( + var container = new Container( r => r.InstanceOf<ISomething>().Is.OfConcreteType<SomethingOne>()); - IList<ISomething> list = ObjectFactory.GetAllInstances<ISomething>(); + IList<ISomething> list = container.GetAllInstances<ISomething>(); Assert.IsInstanceOfType(typeof (SomethingOne), list[0]); } @@ -295,9 +279,9 @@ [Test] public void JustAddATypeWithNoNameAndDefault() { - ObjectFactory.Initialize(x => { x.For<ISomething>().TheDefaultIsConcreteType<SomethingOne>(); }); + var container = new Container(x => { x.For<ISomething>().TheDefaultIsConcreteType<SomethingOne>(); }); - Assert.IsInstanceOfType(typeof (SomethingOne), ObjectFactory.GetInstance<ISomething>()); + Assert.IsInstanceOfType(typeof(SomethingOne), container.GetInstance<ISomething>()); } [Test] @@ -323,10 +307,11 @@ { var one = new SomethingOne(); var two = new SomethingOne(); - ObjectFactory.Inject<ISomething>(one); - ObjectFactory.Inject<ISomething>(two); + var container = new Container(); + container.Inject<ISomething>(one); + container.Inject<ISomething>(two); - Assert.AreSame(two, ObjectFactory.GetInstance<ISomething>()); + Assert.AreSame(two, container.GetInstance<ISomething>()); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fli...@us...> - 2010-01-30 19:14:06
|
Revision: 326 http://structuremap.svn.sourceforge.net/structuremap/?rev=326&view=rev Author: flimflan Date: 2010-01-30 19:13:59 +0000 (Sat, 30 Jan 2010) Log Message: ----------- When wiring up the built-in registration conventions, can now call OnAddedPluginTypes() to configure options (scope, enrichment, etc) for discovered plugin types - pulled registration of built-in conventions off IAssemblyScanner and moved to AssemblyScannerExtensions Modified Paths: -------------- trunk/Source/StructureMap/Graph/AssemblyScanner.cs trunk/Source/StructureMap/Graph/FirstInterfaceConvention.cs trunk/Source/StructureMap/Graph/IAssemblyScanner.cs trunk/Source/StructureMap/Graph/ITypeScanner.cs trunk/Source/StructureMap/Graph/ImplementationMap.cs trunk/Source/StructureMap/StructureMap.csproj trunk/Source/StructureMap.Testing/Graph/DefaultConventionScanningTester.cs trunk/Source/StructureMap.Testing/Graph/SingleImplementationScannerTester.cs trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj Added Paths: ----------- trunk/Source/StructureMap/AssemblyScannerExtensions.cs trunk/Source/StructureMap/Configuration/DSL/Expressions/ConfigureConventionExpression.cs trunk/Source/StructureMap/Graph/IRegistrationConvention.cs trunk/Source/StructureMap.Testing/Graph/GenericConnectionScannerTester.cs Added: trunk/Source/StructureMap/AssemblyScannerExtensions.cs =================================================================== --- trunk/Source/StructureMap/AssemblyScannerExtensions.cs (rev 0) +++ trunk/Source/StructureMap/AssemblyScannerExtensions.cs 2010-01-30 19:13:59 UTC (rev 326) @@ -0,0 +1,63 @@ +using System; +using StructureMap.Configuration.DSL.Expressions; +using StructureMap.Graph; + +namespace StructureMap +{ + /// <summary> + /// Extend the assembly scanning DSL to support the built-in registration conventions + /// </summary> + public static class AssemblyScannerExtensions + { + /// <summary> + /// Adds the DefaultConventionScanner to the scanning operations. I.e., a concrete + /// class named "Something" that implements "ISomething" will be automatically + /// added to PluginType "ISomething" + /// </summary> + public static ConfigureConventionExpression WithDefaultConventions(this IAssemblyScanner assemblyScanner) + { + var convention = new DefaultConventionScanner(); + assemblyScanner.With(convention); + return new ConfigureConventionExpression(convention); + } + + /// <summary> + /// Scans for PluginType's and Concrete Types that close the given open generic type + /// </summary> + /// <example> + /// + /// </example> + /// <param name="openGenericType"></param> + public static ConfigureConventionExpression ConnectImplementationsToTypesClosing(this IAssemblyScanner assemblyScanner, Type openGenericType) + { + var convention = new GenericConnectionScanner(openGenericType); + assemblyScanner.With(convention); + return new ConfigureConventionExpression(convention); + } + + /// <summary> + /// Automatically registers all concrete types without primitive arguments + /// against its first interface, if any + /// </summary> + public static ConfigureConventionExpression RegisterConcreteTypesAgainstTheFirstInterface(this IAssemblyScanner assemblyScanner) + { + var convention = new FirstInterfaceConvention(); + assemblyScanner.With(convention); + return new ConfigureConventionExpression(convention); + } + + /// <summary> + /// Directs the scanning to automatically register any type that is the single + /// implementation of an interface against that interface. + /// The filters apply + /// </summary> + public static ConfigureConventionExpression SingleImplementationsOfInterface(this IAssemblyScanner assemblyScanner) + { + var convention = new ImplementationMap(); + assemblyScanner.With(convention); + assemblyScanner.ModifyGraphAfterScan(convention.RegisterSingleImplementations); + return new ConfigureConventionExpression(convention); + } + + } +} \ No newline at end of file Added: trunk/Source/StructureMap/Configuration/DSL/Expressions/ConfigureConventionExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/ConfigureConventionExpression.cs (rev 0) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/ConfigureConventionExpression.cs 2010-01-30 19:13:59 UTC (rev 326) @@ -0,0 +1,21 @@ +using System; +using StructureMap.Graph; + +namespace StructureMap.Configuration.DSL.Expressions +{ + public class ConfigureConventionExpression + { + private readonly ConfigurableRegistrationConvention _convention; + + internal ConfigureConventionExpression(ConfigurableRegistrationConvention convention) + { + _convention = convention; + } + + public ConfigureConventionExpression OnAddedPluginTypes(Action<GenericFamilyExpression> configurePluginType) + { + _convention.SetFamilyConfigurationAction(configurePluginType); + return this; + } + } +} \ No newline at end of file Modified: trunk/Source/StructureMap/Graph/AssemblyScanner.cs =================================================================== --- trunk/Source/StructureMap/Graph/AssemblyScanner.cs 2010-01-28 01:27:28 UTC (rev 325) +++ trunk/Source/StructureMap/Graph/AssemblyScanner.cs 2010-01-30 19:13:59 UTC (rev 326) @@ -42,7 +42,6 @@ private readonly List<Assembly> _assemblies = new List<Assembly>(); private readonly List<IRegistrationConvention> _conventions = new List<IRegistrationConvention>(); private readonly CompositeFilter<Type> _filter = new CompositeFilter<Type>(); - private readonly ImplementationMap _implementationMap = new ImplementationMap(); private readonly List<Action<PluginGraph>> _postScanningActions = new List<Action<PluginGraph>>(); private readonly List<ITypeScanner> _scanners = new List<ITypeScanner>(); @@ -75,16 +74,6 @@ _scanners.Fill(scanner); } - public void WithDefaultConventions() - { - Convention<DefaultConventionScanner>(); - } - - public void RegisterConcreteTypesAgainstTheFirstInterface() - { - Convention<FirstInterfaceConvention>(); - } - [Obsolete("Replace ITypeScanner with IRegistrationConvention")] public void With<T>() where T : ITypeScanner, new() { @@ -186,18 +175,11 @@ Exclude(type => type == typeof (T)); } - public void ConnectImplementationsToTypesClosing(Type openGenericType) + public void ModifyGraphAfterScan(Action<PluginGraph> modifyGraph) { - With(new GenericConnectionScanner(openGenericType)); + _postScanningActions.Add(modifyGraph); } - - public void SingleImplementationsOfInterface() - { - _conventions.Fill(_implementationMap); - _postScanningActions.Add(graph => _implementationMap.RegisterSingleImplementations(graph)); - } - public void AssembliesFromApplicationBaseDirectory() { AssembliesFromApplicationBaseDirectory(a => true); Modified: trunk/Source/StructureMap/Graph/FirstInterfaceConvention.cs =================================================================== --- trunk/Source/StructureMap/Graph/FirstInterfaceConvention.cs 2010-01-28 01:27:28 UTC (rev 325) +++ trunk/Source/StructureMap/Graph/FirstInterfaceConvention.cs 2010-01-30 19:13:59 UTC (rev 326) @@ -6,9 +6,9 @@ namespace StructureMap.Graph { - public class FirstInterfaceConvention : IRegistrationConvention + public class FirstInterfaceConvention : ConfigurableRegistrationConvention { - public void Process(Type type, Registry registry) + public override void Process(Type type, Registry registry) { if (!type.IsConcrete() || !type.CanBeCreated()) return; @@ -18,6 +18,7 @@ { Debug.WriteLine("Plugging {0} into {1}".ToFormat(type.Name, interfaceType.Name)); registry.AddType(interfaceType, type); + ConfigureFamily(registry.For(interfaceType)); } } } Modified: trunk/Source/StructureMap/Graph/IAssemblyScanner.cs =================================================================== --- trunk/Source/StructureMap/Graph/IAssemblyScanner.cs 2010-01-28 01:27:28 UTC (rev 325) +++ trunk/Source/StructureMap/Graph/IAssemblyScanner.cs 2010-01-30 19:13:59 UTC (rev 326) @@ -1,5 +1,6 @@ using System; using System.Reflection; +using StructureMap.Configuration.DSL.Expressions; namespace StructureMap.Graph { @@ -76,20 +77,6 @@ void With(ITypeScanner scanner); /// <summary> - /// Adds the DefaultConventionScanner to the scanning operations. I.e., a concrete - /// class named "Something" that implements "ISomething" will be automatically - /// added to PluginType "ISomething" - /// </summary> - void WithDefaultConventions(); - - /// <summary> - /// Automatically registers all concrete types without primitive arguments - /// against its first interface, if any - /// </summary> - void RegisterConcreteTypesAgainstTheFirstInterface(); - - - /// <summary> /// Creates and adds a new ITypeScanner of type T to this scanning operation /// </summary> /// <typeparam name="T"></typeparam> @@ -178,22 +165,6 @@ // ... Other methods /// <summary> - /// Scans for PluginType's and Concrete Types that close the given open generic type - /// </summary> - /// <example> - /// - /// </example> - /// <param name="openGenericType"></param> - void ConnectImplementationsToTypesClosing(Type openGenericType); - - /// <summary> - /// Directs the scanning to automatically register any type that is the single - /// implementation of an interface against that interface. - /// The filters apply - /// </summary> - void SingleImplementationsOfInterface(); - - /// <summary> /// Adds a registration convention to be applied to all the types in this /// logical "scan" operation /// </summary> @@ -205,5 +176,7 @@ /// logical "scan" operation /// </summary> void With(IRegistrationConvention convention); + + void ModifyGraphAfterScan(Action<PluginGraph> modifyGraph); } } \ No newline at end of file Added: trunk/Source/StructureMap/Graph/IRegistrationConvention.cs =================================================================== --- trunk/Source/StructureMap/Graph/IRegistrationConvention.cs (rev 0) +++ trunk/Source/StructureMap/Graph/IRegistrationConvention.cs 2010-01-30 19:13:59 UTC (rev 326) @@ -0,0 +1,31 @@ +using System; +using StructureMap.Configuration.DSL; +using StructureMap.Configuration.DSL.Expressions; + +namespace StructureMap.Graph +{ + public interface IRegistrationConvention + { + void Process(Type type, Registry registry); + } + + /// <summary> + /// Allows built-in registration conventions to be configurable through the assembly scanning DSL + /// </summary> + /// <remarks> + /// Intended for StructureMap internal use only. + /// Custom registration convention instances can be directly configured + /// before being passed to IAssemblyScanner.With(IRegistrationConvention). + /// </remarks> + public abstract class ConfigurableRegistrationConvention : IRegistrationConvention + { + protected Action<GenericFamilyExpression> ConfigureFamily = x => { }; + + public void SetFamilyConfigurationAction(Action<GenericFamilyExpression> configureFamily) + { + ConfigureFamily = configureFamily; + } + + public abstract void Process(Type type, Registry registry); + } +} \ No newline at end of file Modified: trunk/Source/StructureMap/Graph/ITypeScanner.cs =================================================================== --- trunk/Source/StructureMap/Graph/ITypeScanner.cs 2010-01-28 01:27:28 UTC (rev 325) +++ trunk/Source/StructureMap/Graph/ITypeScanner.cs 2010-01-30 19:13:59 UTC (rev 326) @@ -10,14 +10,9 @@ void Process(Type type, PluginGraph graph); } - public interface IRegistrationConvention + public class DefaultConventionScanner : ConfigurableRegistrationConvention { - void Process(Type type, Registry registry); - } - - public class DefaultConventionScanner : IRegistrationConvention - { - public void Process(Type type, Registry registry) + public override void Process(Type type, Registry registry) { if (!type.IsConcrete()) return; @@ -25,6 +20,7 @@ if (pluginType != null && Constructor.HasConstructors(type)) { registry.AddType(pluginType, type); + ConfigureFamily(registry.For(pluginType)); } } @@ -36,7 +32,7 @@ } } - public class GenericConnectionScanner : IRegistrationConvention + public class GenericConnectionScanner : ConfigurableRegistrationConvention { private readonly Type _openType; @@ -50,12 +46,14 @@ } } - public void Process(Type type, Registry registry) + public override void Process(Type type, Registry registry) { Type interfaceType = type.FindInterfaceThatCloses(_openType); if (interfaceType != null) { - registry.For(interfaceType).Add(type); + var family = registry.For(interfaceType); + ConfigureFamily(family); + family.Add(type); } } } Modified: trunk/Source/StructureMap/Graph/ImplementationMap.cs =================================================================== --- trunk/Source/StructureMap/Graph/ImplementationMap.cs 2010-01-28 01:27:28 UTC (rev 325) +++ trunk/Source/StructureMap/Graph/ImplementationMap.cs 2010-01-30 19:13:59 UTC (rev 326) @@ -7,11 +7,11 @@ namespace StructureMap.Graph { - public class ImplementationMap : IRegistrationConvention + public class ImplementationMap : ConfigurableRegistrationConvention { private readonly Cache<Type, List<Type>> _types = new Cache<Type, List<Type>>(t => new List<Type>()); - public void Process(Type type, Registry registry) + public override void Process(Type type, Registry registry) { RegisterType(type); } @@ -30,13 +30,22 @@ public void RegisterSingleImplementations(PluginGraph graph) { + var singleImplementationRegistry = new SingleImplementationRegistry(); _types.Each((pluginType, types) => { if (types.Count == 1) { - graph.AddType(pluginType, types[0]); + singleImplementationRegistry.AddType(pluginType, types[0]); + ConfigureFamily(singleImplementationRegistry.For(pluginType)); } }); + singleImplementationRegistry.ConfigurePluginGraph(graph); } } + + internal class SingleImplementationRegistry : Registry + { + // This type created just to make the output clearer in WhatDoIHave() + // might consider adding a Description property to Registry instead + } } \ No newline at end of file Modified: trunk/Source/StructureMap/StructureMap.csproj =================================================================== --- trunk/Source/StructureMap/StructureMap.csproj 2010-01-28 01:27:28 UTC (rev 325) +++ trunk/Source/StructureMap/StructureMap.csproj 2010-01-30 19:13:59 UTC (rev 326) @@ -336,6 +336,7 @@ <Compile Include="CloseGenericTypeExpression.cs" /> <Compile Include="ConfigurationExpression.cs" /> <Compile Include="Configuration\DictionaryReader.cs" /> + <Compile Include="AssemblyScannerExtensions.cs" /> <Compile Include="Configuration\DSL\Expressions\InstanceExpression.cs" /> <Compile Include="Configuration\DSL\IRegistry.cs" /> <Compile Include="Configuration\DSL\SetterConvention.cs" /> @@ -358,12 +359,14 @@ <Compile Include="Extensions.cs" /> <Compile Include="Graph\CompositeFilter.cs" /> <Compile Include="Graph\CompositePredicate.cs" /> + <Compile Include="Configuration\DSL\Expressions\ConfigureConventionExpression.cs" /> <Compile Include="Graph\FamilyAttributeScanner.cs" /> <Compile Include="Graph\FindAllTypesFilter.cs" /> <Compile Include="Graph\FindRegistriesScanner.cs" /> <Compile Include="Graph\FirstInterfaceConvention.cs" /> <Compile Include="Graph\IAssemblyScanner.cs" /> <Compile Include="Graph\ImplementationMap.cs" /> + <Compile Include="Graph\IRegistrationConvention.cs" /> <Compile Include="Graph\ITypeScanner.cs" /> <Compile Include="Graph\PluggableAttributeScanner.cs" /> <Compile Include="Graph\PluginCache.cs" /> Modified: trunk/Source/StructureMap.Testing/Graph/DefaultConventionScanningTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Graph/DefaultConventionScanningTester.cs 2010-01-28 01:27:28 UTC (rev 325) +++ trunk/Source/StructureMap.Testing/Graph/DefaultConventionScanningTester.cs 2010-01-30 19:13:59 UTC (rev 326) @@ -6,71 +6,14 @@ namespace StructureMap.Testing.Graph { [TestFixture] - public class GenericConnectionScannerTester - { - #region Setup/Teardown - - [SetUp] - public void SetUp() - { - container = new Container(x => - { - x.Scan(o => - { - o.TheCallingAssembly(); - o.ConnectImplementationsToTypesClosing(typeof (IFinder<>)); - }); - }); - } - - #endregion - - private Container container; - - [Test] - public void can_find_the_closed_finders() - { - container.GetInstance<IFinder<string>>().ShouldBeOfType<StringFinder>(); - container.GetInstance<IFinder<int>>().ShouldBeOfType<IntFinder>(); - container.GetInstance<IFinder<double>>().ShouldBeOfType<DoubleFinder>(); - } - - [Test, ExpectedException(typeof (ApplicationException))] - public void fails_on_closed_type() - { - new GenericConnectionScanner(typeof (double)); - } - } - - public interface IFinder<T> - { - } - - public class StringFinder : IFinder<string> - { - } - - public class IntFinder : IFinder<int> - { - } - - public class DoubleFinder : IFinder<double> - { - } - - [TestFixture] public class DefaultConventionScanningTester { - #region Setup/Teardown - [SetUp] public void SetUp() { PluginCache.ResetAll(); } - #endregion - [Test] public void FindPluginType() { @@ -129,6 +72,21 @@ family.Seal(); Assert.AreEqual(1, family.InstanceCount); } + + [Test] + public void can_configure_plugin_families_via_dsl() + { + var container = new Container(registry => registry.Scan(x => + { + x.TheCallingAssembly(); + x.WithDefaultConventions().OnAddedPluginTypes(t => t.Singleton()); + })); + + var firstInstance = container.GetInstance<IConvention>(); + var secondInstance = container.GetInstance<IConvention>(); + secondInstance.ShouldBeTheSameAs(firstInstance); + } + } public interface IConvention Added: trunk/Source/StructureMap.Testing/Graph/GenericConnectionScannerTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Graph/GenericConnectionScannerTester.cs (rev 0) +++ trunk/Source/StructureMap.Testing/Graph/GenericConnectionScannerTester.cs 2010-01-30 19:13:59 UTC (rev 326) @@ -0,0 +1,63 @@ +using System; +using NUnit.Framework; +using StructureMap.Graph; + +namespace StructureMap.Testing.Graph +{ + [TestFixture] + public class GenericConnectionScannerTester + { + [Test] + public void can_find_the_closed_finders() + { + var container = new Container(x => x.Scan(o => + { + o.TheCallingAssembly(); + o.ConnectImplementationsToTypesClosing(typeof(IFinder<>)); + })); + container.GetInstance<IFinder<string>>().ShouldBeOfType<StringFinder>(); + container.GetInstance<IFinder<int>>().ShouldBeOfType<IntFinder>(); + container.GetInstance<IFinder<double>>().ShouldBeOfType<DoubleFinder>(); + } + + [Test, ExpectedException(typeof (ApplicationException))] + public void fails_on_closed_type() + { + new GenericConnectionScanner(typeof (double)); + } + + [Test] + public void can_configure_plugin_families_via_dsl() + { + var container = new Container(registry => registry.Scan(x => + { + x.TheCallingAssembly(); + x.ConnectImplementationsToTypesClosing(typeof(IFinder<>)).OnAddedPluginTypes(t => t.Singleton()); + })); + + var firstStringFinder = container.GetInstance<IFinder<string>>().ShouldBeOfType<StringFinder>(); + var secondStringFinder = container.GetInstance<IFinder<string>>().ShouldBeOfType<StringFinder>(); + secondStringFinder.ShouldBeTheSameAs(firstStringFinder); + + var firstIntFinder = container.GetInstance<IFinder<int>>().ShouldBeOfType<IntFinder>(); + var secondIntFinder = container.GetInstance<IFinder<int>>().ShouldBeOfType<IntFinder>(); + secondIntFinder.ShouldBeTheSameAs(firstIntFinder); + } + } + + public interface IFinder<T> + { + } + + public class StringFinder : IFinder<string> + { + } + + public class IntFinder : IFinder<int> + { + } + + public class DoubleFinder : IFinder<double> + { + } +} \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/Graph/SingleImplementationScannerTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Graph/SingleImplementationScannerTester.cs 2010-01-28 01:27:28 UTC (rev 325) +++ trunk/Source/StructureMap.Testing/Graph/SingleImplementationScannerTester.cs 2010-01-30 19:13:59 UTC (rev 326) @@ -6,28 +6,48 @@ [TestFixture] public class SingleImplementationScannerTester { - [Test] - public void other() + private Container _container; + + [SetUp] + public void Setup() { - typeof (Type).IsValueType.ShouldBeFalse(); + _container = new Container(registry => registry.Scan(x => + { + x.TheCallingAssembly(); + x.IncludeNamespaceContainingType<SingleImplementationScannerTester>(); + x.SingleImplementationsOfInterface(); + })); } [Test] public void registers_plugins_that_only_have_a_single_implementation() { - var container = new Container(registry => - { - registry.Scan(x => - { - x.TheCallingAssembly(); - x.IncludeNamespaceContainingType<SingleImplementationScannerTester>(); - x.SingleImplementationsOfInterface(); - }); - }); - container.GetInstance<IOnlyHaveASingleConcreteImplementation>() + _container.GetInstance<IOnlyHaveASingleConcreteImplementation>() .ShouldBeOfType<MyNameIsNotConventionallyRelatedToMyInterface>(); } + + [Test] + public void should_not_automatically_register_plugins_that_have_multiple_implementations() + { + _container.TryGetInstance<IHaveMultipleConcreteImplementations>().ShouldBeNull(); + } + + [Test] + public void can_configure_plugin_families_via_dsl() + { + var differentContainer = new Container(registry => registry.Scan(x => + { + x.TheCallingAssembly(); + x.IncludeNamespaceContainingType<SingleImplementationScannerTester>(); + x.SingleImplementationsOfInterface().OnAddedPluginTypes(t => t.Singleton()); + })); + + var firstInstance = differentContainer.GetInstance<IOnlyHaveASingleConcreteImplementation>(); + var secondInstance = differentContainer.GetInstance<IOnlyHaveASingleConcreteImplementation>(); + secondInstance.ShouldBeTheSameAs(firstInstance); + } + } @@ -38,4 +58,8 @@ public class MyNameIsNotConventionallyRelatedToMyInterface : IOnlyHaveASingleConcreteImplementation { } -} \ No newline at end of file + + public interface IHaveMultipleConcreteImplementations { } + public class FirstConcreteImplementation : IHaveMultipleConcreteImplementations { } + public class SecondConcreteImplementation : IHaveMultipleConcreteImplementations { } +} Modified: trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj =================================================================== --- trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2010-01-28 01:27:28 UTC (rev 325) +++ trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2010-01-30 19:13:59 UTC (rev 326) @@ -258,6 +258,7 @@ <SubType>Code</SubType> </Compile> <Compile Include="Graph\FirstInterfaceConventionTester.cs" /> + <Compile Include="Graph\GenericConnectionScannerTester.cs" /> <Compile Include="Graph\SingleImplementationScannerTester.cs" /> <Compile Include="Graph\TestExplicitArguments.cs" /> <Compile Include="Graph\FillDependenciesTester.cs"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |