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: <jer...@us...> - 2009-06-12 20:13:40
|
Revision: 250 http://structuremap.svn.sourceforge.net/structuremap/?rev=250&view=rev Author: jeremydmiller Date: 2009-06-12 20:13:34 +0000 (Fri, 12 Jun 2009) Log Message: ----------- fixing a small problem for Dovetail Modified Paths: -------------- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs trunk/Source/StructureMap/Pipeline/MainObjectCache.cs Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2009-06-08 15:10:10 UTC (rev 249) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2009-06-12 20:13:34 UTC (rev 250) @@ -103,13 +103,13 @@ } /// <summary> - /// Shorthand way of saying TheDefaultIsConcreteType<> + /// Shorthand way of saying TheDefault.Is.OfConcreteType<> /// </summary> /// <typeparam name="CONCRETETYPE"></typeparam> /// <returns></returns> - public CreatePluginFamilyExpression<PLUGINTYPE> Use<CONCRETETYPE>() where CONCRETETYPE : PLUGINTYPE + public SmartInstance<CONCRETETYPE> Use<CONCRETETYPE>() where CONCRETETYPE : PLUGINTYPE { - return TheDefaultIsConcreteType<CONCRETETYPE>(); + return TheDefault.Is.OfConcreteType<CONCRETETYPE>(); } /// <summary> Modified: trunk/Source/StructureMap/Pipeline/MainObjectCache.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/MainObjectCache.cs 2009-06-08 15:10:10 UTC (rev 249) +++ trunk/Source/StructureMap/Pipeline/MainObjectCache.cs 2009-06-12 20:13:34 UTC (rev 250) @@ -26,8 +26,19 @@ public void Set(Type pluginType, Instance instance, object value) { - var key = new InstanceKey(instance, pluginType); - _objects.Add(key, value); + if (value == null) return; + + try + { + var key = new InstanceKey(instance, pluginType); + _objects.Add(key, value); + } + catch (ArgumentException e) + { + string message = string.Format("Duplicate key for Instance {0} of PluginType {1}", instance.Name, + pluginType.AssemblyQualifiedName); + throw new ArgumentException(message, e); + } } public void DisposeAndClear() @@ -36,6 +47,8 @@ { foreach (var @object in _objects.Values) { + if (@object is Container) continue; + IDisposable disposable = @object as IDisposable; if (disposable != null) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2009-06-08 15:10:13
|
Revision: 249 http://structuremap.svn.sourceforge.net/structuremap/?rev=249&view=rev Author: jeremydmiller Date: 2009-06-08 15:10:10 +0000 (Mon, 08 Jun 2009) Log Message: ----------- fixing a bug with nested containers Modified Paths: -------------- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs trunk/Source/StructureMap/Configuration/DSL/Registry.cs trunk/Source/StructureMap/Container.cs trunk/Source/StructureMap.Testing/Pipeline/NestedContainerSupportTester.cs Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2009-06-03 17:47:44 UTC (rev 248) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2009-06-08 15:10:10 UTC (rev 249) @@ -113,6 +113,16 @@ } /// <summary> + /// Shorthand to say TheDefault.Is.ConstructedBy(func) + /// </summary> + /// <param name="func"></param> + /// <returns></returns> + public ConstructorInstance<PLUGINTYPE> Use(Func<IContext, PLUGINTYPE> func) + { + return TheDefault.Is.ConstructedBy(func); + } + + /// <summary> /// Sets the object creation of the instances of the PluginType. For example: PerRequest, /// Singleton, ThreadLocal, HttpContext, or Hybrid /// </summary> Modified: trunk/Source/StructureMap/Configuration/DSL/Registry.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2009-06-03 17:47:44 UTC (rev 248) +++ trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2009-06-08 15:10:10 UTC (rev 249) @@ -47,20 +47,7 @@ void SelectConstructor<T>(Expression<Func<T>> expression); } - public static class RegistryExtensions - { - public static CreatePluginFamilyExpression<PLUGINTYPE> For<PLUGINTYPE>(this IRegistry registry) - { - return registry.ForRequestedType<PLUGINTYPE>(); - } - public static GenericFamilyExpression For(this IRegistry registry, Type pluginType) - { - return registry.ForRequestedType(pluginType); - } - } - - /// <summary> /// A Registry class provides methods and grammars for configuring a Container or ObjectFactory. /// Using a Registry subclass is the recommended way of configuring a StructureMap Container. @@ -403,5 +390,25 @@ { ForRequestedType<PLUGINTYPE>().TheDefault.IsThis(instance); } + + /// <summary> + /// Shorthand for ForRequestedType<PLUGINTYPE>() + /// </summary> + /// <typeparam name="PLUGINTYPE"></typeparam> + /// <returns></returns> + public CreatePluginFamilyExpression<PLUGINTYPE> For<PLUGINTYPE>() + { + return ForRequestedType<PLUGINTYPE>(); + } + + /// <summary> + /// Shorthand for ForRequestedType(pluginType) + /// </summary> + /// <param name="pluginType"></param> + /// <returns></returns> + public GenericFamilyExpression For(Type pluginType) + { + return ForRequestedType(pluginType); + } } } \ No newline at end of file Modified: trunk/Source/StructureMap/Container.cs =================================================================== --- trunk/Source/StructureMap/Container.cs 2009-06-03 17:47:44 UTC (rev 248) +++ trunk/Source/StructureMap/Container.cs 2009-06-08 15:10:10 UTC (rev 249) @@ -430,12 +430,17 @@ /// <returns></returns> public IContainer GetNestedContainer() { - return new Container + var container = new Container { _interceptorLibrary = _interceptorLibrary, _pipelineGraph = _pipelineGraph.Clone(), _transientCache = new MainObjectCache() }; + + // Fixes a mild bug. The child container should inject itself + container._pipelineGraph.Inject<IContainer>(container); + + return container; } /// <summary> Modified: trunk/Source/StructureMap.Testing/Pipeline/NestedContainerSupportTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Pipeline/NestedContainerSupportTester.cs 2009-06-03 17:47:44 UTC (rev 248) +++ trunk/Source/StructureMap.Testing/Pipeline/NestedContainerSupportTester.cs 2009-06-08 15:10:10 UTC (rev 249) @@ -14,7 +14,19 @@ { } + [Test] + public void the_nested_container_delivers_itself_as_the_IContainer() + { + var parent = new Container(x => + { + x.For<IWidget>().Use<AWidget>(); + }); + var child = parent.GetNestedContainer(); + + child.GetInstance<IContainer>().ShouldBeTheSameAs(child); + } + [Test] public void transient_service_in_the_parent_container_is_effectively_a_singleton_for_the_nested_container() { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2009-06-03 17:47:46
|
Revision: 248 http://structuremap.svn.sourceforge.net/structuremap/?rev=248&view=rev Author: jeremydmiller Date: 2009-06-03 17:47:44 +0000 (Wed, 03 Jun 2009) Log Message: ----------- got the dispose working for nested container Modified Paths: -------------- trunk/Source/StructureMap/Container.cs trunk/Source/StructureMap/IContainer.cs trunk/Source/StructureMap/PipelineGraph.cs trunk/Source/StructureMap.Testing/Pipeline/NestedContainerSupportTester.cs trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj Added Paths: ----------- trunk/Source/StructureMap.Testing/Pipeline/ContainerDisposalTester.cs Modified: trunk/Source/StructureMap/Container.cs =================================================================== --- trunk/Source/StructureMap/Container.cs 2009-06-03 16:21:03 UTC (rev 247) +++ trunk/Source/StructureMap/Container.cs 2009-06-03 17:47:44 UTC (rev 248) @@ -134,18 +134,8 @@ return getListOfTypeWithSession<T>(session); } - /// <summary> - /// Injects the given object into a Container as the default for the designated - /// PLUGINTYPE. Mostly used for temporarily setting up return values of the Container - /// to introduce mocks or stubs during automated testing scenarios - /// </summary> - /// <typeparam name="PLUGINTYPE"></typeparam> - /// <param name="instance"></param> - public void Inject<PLUGINTYPE>(PLUGINTYPE instance) - { - _pipelineGraph.Inject(instance); - } + /// <summary> /// Creates or finds the default instance of type T /// </summary> @@ -162,20 +152,8 @@ return (T) FillDependencies(typeof (T)); } - /// <summary> - /// Injects the given object into a Container by name for the designated - /// pluginType. Mostly used for temporarily setting up return values of the Container - /// to introduce mocks or stubs during automated testing scenarios - /// </summary> - /// <typeparam name="T"></typeparam> - /// <param name="name"></param> - /// <param name="stub"></param> - public void Inject<T>(string name, T stub) - { - LiteralInstance instance = new LiteralInstance(stub).WithName(name); - _pipelineGraph.AddInstance<T>(instance); - } + /// <summary> /// Creates or resolves all registered instances of type T /// </summary> @@ -312,26 +290,8 @@ return GetInstance(type); } - /// <summary> - /// Injects the given object into a Container as the default for the designated - /// pluginType. Mostly used for temporarily setting up return values of the Container - /// to introduce mocks or stubs during automated testing scenarios - /// </summary> - /// <param name="pluginType"></param> - /// <param name="stub"></param> - public void Inject(Type pluginType, object stub) - { - if (!CanBeCast(pluginType, stub.GetType())) - { - throw new StructureMapException(220, pluginType.FullName, - stub.GetType().FullName); - } - var instance = new LiteralInstance(stub); - _pipelineGraph.SetDefault(pluginType, instance); - } - /// <summary> /// Creates or resolves all registered instances of the pluginType /// </summary> @@ -470,7 +430,7 @@ /// <returns></returns> public IContainer GetNestedContainer() { - return new Container() + return new Container { _interceptorLibrary = _interceptorLibrary, _pipelineGraph = _pipelineGraph.Clone(), @@ -485,12 +445,17 @@ /// <returns></returns> public IContainer GetNestedContainer(string profileName) { - var container = GetNestedContainer(); + IContainer container = GetNestedContainer(); container.SetDefaultsToProfile(profileName); return container; } + public void Dispose() + { + _transientCache.DisposeAndClear(); + } + #endregion private object buildInstanceWithArgs(Type pluginType, Instance defaultInstance, ExplicitArguments args, @@ -552,16 +517,8 @@ return list; } - /// <summary> - /// Sets the default instance for the PluginType - /// </summary> - /// <param name="pluginType"></param> - /// <param name="instance"></param> - public void Inject(Type pluginType, Instance instance) - { - _pipelineGraph.SetDefault(pluginType, instance); - } + private BuildSession withNewSession(string name) { return new BuildSession(_pipelineGraph, _interceptorLibrary, _transientCache) @@ -615,5 +572,65 @@ } #endregion + + + /// <summary> + /// Injects the given object into a Container by name for the designated + /// pluginType. Mostly used for temporarily setting up return values of the Container + /// to introduce mocks or stubs during automated testing scenarios + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="name"></param> + /// <param name="object"></param> + public void Inject<T>(string name, T @object) + { + LiteralInstance instance = new LiteralInstance(@object).WithName(name); + _transientCache.Set(typeof(T), instance, @object); + _pipelineGraph.AddInstance<T>(instance); + } + + /// <summary> + /// Sets the default instance for the PluginType + /// </summary> + /// <param name="pluginType"></param> + /// <param name="instance"></param> + public void Inject(Type pluginType, Instance instance) + { + _pipelineGraph.SetDefault(pluginType, instance); + } + + /// <summary> + /// Injects the given object into a Container as the default for the designated + /// pluginType. Mostly used for temporarily setting up return values of the Container + /// to introduce mocks or stubs during automated testing scenarios + /// </summary> + /// <param name="pluginType"></param> + /// <param name="object"></param> + public void Inject(Type pluginType, object @object) + { + if (!CanBeCast(pluginType, @object.GetType())) + { + throw new StructureMapException(220, pluginType.FullName, + @object.GetType().FullName); + } + + + var instance = new LiteralInstance(@object); + _transientCache.Set(pluginType, instance, @object); + _pipelineGraph.SetDefault(pluginType, instance); + } + + /// <summary> + /// Injects the given object into a Container as the default for the designated + /// PLUGINTYPE. Mostly used for temporarily setting up return values of the Container + /// to introduce mocks or stubs during automated testing scenarios + /// </summary> + /// <typeparam name="PLUGINTYPE"></typeparam> + /// <param name="object"></param> + public void Inject<PLUGINTYPE>(PLUGINTYPE @object) + { + var instance = _pipelineGraph.Inject(@object); + _transientCache.Set(typeof(PLUGINTYPE), instance, @object); + } } } \ No newline at end of file Modified: trunk/Source/StructureMap/IContainer.cs =================================================================== --- trunk/Source/StructureMap/IContainer.cs 2009-06-03 16:21:03 UTC (rev 247) +++ trunk/Source/StructureMap/IContainer.cs 2009-06-03 17:47:44 UTC (rev 248) @@ -9,7 +9,7 @@ /// <summary> /// The main "container" object that implements the Service Locator pattern /// </summary> - public interface IContainer + public interface IContainer : IDisposable { /// <summary> /// Provides queryable access to the configured PluginType's and Instances of this Container @@ -132,8 +132,8 @@ /// to introduce mocks or stubs during automated testing scenarios /// </summary> /// <param name="pluginType"></param> - /// <param name="stub"></param> - void Inject(Type pluginType, object stub); + /// <param name="object"></param> + void Inject(Type pluginType, object @object); /// <summary> /// Injects the given object into a Container by name for the designated Modified: trunk/Source/StructureMap/PipelineGraph.cs =================================================================== --- trunk/Source/StructureMap/PipelineGraph.cs 2009-06-03 16:21:03 UTC (rev 247) +++ trunk/Source/StructureMap/PipelineGraph.cs 2009-06-03 17:47:44 UTC (rev 248) @@ -179,11 +179,13 @@ ForType(typeof (T)).AddInstance(instance); } - public void Inject<PLUGINTYPE>(PLUGINTYPE instance) + public Instance Inject<PLUGINTYPE>(PLUGINTYPE instance) { var literalInstance = new LiteralInstance(instance); ForType(typeof (PLUGINTYPE)).AddInstance(literalInstance); SetDefault(typeof (PLUGINTYPE), literalInstance); + + return literalInstance; } public void EjectAllInstancesOf<T>() Added: trunk/Source/StructureMap.Testing/Pipeline/ContainerDisposalTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Pipeline/ContainerDisposalTester.cs (rev 0) +++ trunk/Source/StructureMap.Testing/Pipeline/ContainerDisposalTester.cs 2009-06-03 17:47:44 UTC (rev 248) @@ -0,0 +1,151 @@ +using System; +using NUnit.Framework; +using StructureMap.Configuration.DSL; + +namespace StructureMap.Testing.Pipeline +{ + [TestFixture] + public class ContainerDisposalTester + { + [SetUp] + public void SetUp() + { + } + + [Test] + public void disposing_a_nested_container_should_dispose_all_of_the_transient_objects_created_by_the_nested_container() + { + var container = new Container(x => + { + x.For<I1>().Use<C1Yes>(); + x.For<I2>().Use<C2Yes>(); + x.For<I3>().AddInstances(o => + { + o.OfConcreteType<C3Yes>().WithName("1"); + o.OfConcreteType<C3Yes>().WithName("2"); + }); + }); + + var child = container.GetNestedContainer(); + + var disposables = new Disposable[] + { + child.GetInstance<I1>().ShouldBeOfType<Disposable>(), + child.GetInstance<I2>().ShouldBeOfType<Disposable>(), + child.GetInstance<I3>("1").ShouldBeOfType<Disposable>(), + child.GetInstance<I3>("2").ShouldBeOfType<Disposable>(), + }; + + child.Dispose(); + + foreach (var disposable in disposables) + { + disposable.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>(); + }); + + var child = container.GetNestedContainer(); + + // Blows up if the Dispose() is called + var notDisposable = child.GetInstance<I1>(); + + child.Dispose(); + } + + [Test] + public void should_dispose_objects_injected_into_the_container_1() + { + var container = new Container().GetNestedContainer(); + + var disposable = new C1Yes(); + container.Inject<I1>(disposable); + + container.GetInstance<I1>().ShouldBeTheSameAs(disposable); + + container.Dispose(); + + disposable.WasDisposed.ShouldBeTrue(); + } + + [Test] + public void should_dispose_objects_injected_into_the_container_2() + { + var container = new Container().GetNestedContainer(); + + var disposable = new C1Yes(); + container.Inject<I1>(disposable); + + container.Dispose(); + + disposable.WasDisposed.ShouldBeTrue(); + } + + [Test] + public void should_dispose_objects_injected_into_the_container_3() + { + var container = new Container().GetNestedContainer(); + + var disposable = new C1Yes(); + container.Inject<I1>("blue", disposable); + + container.Dispose(); + + disposable.WasDisposed.ShouldBeTrue(); + } + + + [Test] + public void should_dispose_objects_injected_into_the_container_4() + { + var container = new Container().GetNestedContainer(); + + var disposable = new C1Yes(); + container.Inject(typeof(I1), disposable); + + container.Dispose(); + + disposable.WasDisposed.ShouldBeTrue(); + } + } + + public class Disposable : IDisposable + { + private bool _wasDisposed; + + public void Dispose() + { + if (_wasDisposed) Assert.Fail("This object should not be disposed twice"); + + _wasDisposed = true; + } + + public bool WasDisposed { get { return _wasDisposed; } } + } + + public class NotDisposable : IDisposable + { + public void Dispose() + { + Assert.Fail("This object should not be disposed"); + } + } + + public interface I1{} + public interface I2{} + public interface I3{} + + public class C1Yes : Disposable, I1{} + public class C1No : NotDisposable, I1{} + public class C2Yes : Disposable, I2{} + public class C2No : Disposable, I2{} + public class C3Yes : Disposable, I3{} + public class C3No : Disposable, I3{} +} \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/Pipeline/NestedContainerSupportTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Pipeline/NestedContainerSupportTester.cs 2009-06-03 16:21:03 UTC (rev 247) +++ trunk/Source/StructureMap.Testing/Pipeline/NestedContainerSupportTester.cs 2009-06-03 17:47:44 UTC (rev 248) @@ -14,6 +14,7 @@ { } + [Test] public void transient_service_in_the_parent_container_is_effectively_a_singleton_for_the_nested_container() { @@ -36,6 +37,29 @@ } [Test] + public void inject_into_the_child_does_not_affect_the_parent_container() + { + var parent = new Container(x => + { + x.For<IWidget>().Use<AWidget>(); + }); + + var child = parent.GetNestedContainer(); + var childWidget = new ColorWidget("blue"); + child.Inject<IWidget>(childWidget); + + // do the check repeatedly + child.GetInstance<IWidget>().ShouldBeTheSameAs(childWidget); + child.GetInstance<IWidget>().ShouldBeTheSameAs(childWidget); + child.GetInstance<IWidget>().ShouldBeTheSameAs(childWidget); + + + // now, compare to the parent + parent.GetInstance<IWidget>().ShouldNotBeTheSameAs(childWidget); + + } + + [Test] public void singleton_service_in_the_parent_is_found_by_the_child() { var parent = new Container(x => Modified: trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj =================================================================== --- trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-06-03 16:21:03 UTC (rev 247) +++ trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-06-03 17:47:44 UTC (rev 248) @@ -346,6 +346,7 @@ <Compile Include="Pipeline\ConditionalInstanceTester.cs" /> <Compile Include="Pipeline\ConfiguredInstanceTester.cs" /> <Compile Include="Pipeline\ConstructorInstanceTester.cs" /> + <Compile Include="Pipeline\ContainerDisposalTester.cs" /> <Compile Include="Pipeline\ContainerIsInTheContainerTester.cs" /> <Compile Include="Pipeline\DefaultInstanceTester.cs" /> <Compile Include="Pipeline\GenericsHelperExpressionTester.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2009-06-03 16:21:06
|
Revision: 247 http://structuremap.svn.sourceforge.net/structuremap/?rev=247&view=rev Author: jeremydmiller Date: 2009-06-03 16:21:03 +0000 (Wed, 03 Jun 2009) Log Message: ----------- initial work on nested containers, some little syntactical sugar in the registry DSL Modified Paths: -------------- trunk/Source/StructureMap/BuildSession.cs trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs trunk/Source/StructureMap/Configuration/DSL/Registry.cs trunk/Source/StructureMap/Container.cs trunk/Source/StructureMap/Diagnostics/ValidationBuildSession.cs trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs trunk/Source/StructureMap/IContainer.cs trunk/Source/StructureMap/IInstanceFactory.cs trunk/Source/StructureMap/InstanceCache.cs trunk/Source/StructureMap/InstanceFactory.cs trunk/Source/StructureMap/Pipeline/BuildStack.cs trunk/Source/StructureMap/Pipeline/ConfiguredInstanceBase.cs trunk/Source/StructureMap/Pipeline/ProfileManager.cs trunk/Source/StructureMap/PipelineGraph.cs trunk/Source/StructureMap/StructureMap.csproj trunk/Source/StructureMap/Util/Cache.cs trunk/Source/StructureMap.Testing/BuildSessionTester.cs trunk/Source/StructureMap.Testing/Graph/InstanceFactoryTester.cs trunk/Source/StructureMap.Testing/Pipeline/ConfiguredInstanceTester.cs trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj trunk/Source/StructureMap.sln Added Paths: ----------- trunk/Source/StructureMap/Pipeline/ILifecycle.cs trunk/Source/StructureMap/Pipeline/IObjectCache.cs trunk/Source/StructureMap/Pipeline/Lifecycles.cs trunk/Source/StructureMap/Pipeline/MainObjectCache.cs trunk/Source/StructureMap/Pipeline/NulloObjectCache.cs trunk/Source/StructureMap/Pipeline/ObjectBuilder.cs trunk/Source/StructureMap.Testing/Pipeline/NestedContainerSupportTester.cs trunk/Source/StructureMap.Testing/Util/ trunk/Source/StructureMap.Testing/Util/CacheTester.cs Modified: trunk/Source/StructureMap/BuildSession.cs =================================================================== --- trunk/Source/StructureMap/BuildSession.cs 2009-06-03 03:04:58 UTC (rev 246) +++ trunk/Source/StructureMap/BuildSession.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -8,18 +8,17 @@ { public class BuildSession : IContext { - private readonly BuildStack _buildStack = new BuildStack(); + private BuildStack _buildStack = new BuildStack(); private readonly InstanceCache _cache = new InstanceCache(); private readonly Cache<Type, Func<object>> _defaults; private readonly PipelineGraph _pipelineGraph; private readonly ObjectBuilder _builder; - public BuildSession(PipelineGraph pipelineGraph, InterceptorLibrary interceptorLibrary) + public BuildSession(PipelineGraph pipelineGraph, InterceptorLibrary interceptorLibrary, IObjectCache cache) { + _builder = new ObjectBuilder(pipelineGraph, interceptorLibrary, cache); _pipelineGraph = pipelineGraph; - _builder = new ObjectBuilder(_pipelineGraph, interceptorLibrary, new NulloObjectCache()); - _defaults = new Cache<Type, Func<object>>(t => { Instance instance = _pipelineGraph.GetDefault(t); @@ -34,7 +33,7 @@ } public BuildSession(PluginGraph graph) - : this(new PipelineGraph(graph), graph.InterceptorLibrary) + : this(new PipelineGraph(graph), graph.InterceptorLibrary, new NulloObjectCache()) { } @@ -43,6 +42,10 @@ { } + protected void clearBuildStack() + { + _buildStack = new BuildStack(); + } protected PipelineGraph pipelineGraph { Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2009-06-03 03:04:58 UTC (rev 246) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -103,6 +103,16 @@ } /// <summary> + /// Shorthand way of saying TheDefaultIsConcreteType<> + /// </summary> + /// <typeparam name="CONCRETETYPE"></typeparam> + /// <returns></returns> + public CreatePluginFamilyExpression<PLUGINTYPE> Use<CONCRETETYPE>() where CONCRETETYPE : PLUGINTYPE + { + return TheDefaultIsConcreteType<CONCRETETYPE>(); + } + + /// <summary> /// Sets the object creation of the instances of the PluginType. For example: PerRequest, /// Singleton, ThreadLocal, HttpContext, or Hybrid /// </summary> Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs 2009-06-03 03:04:58 UTC (rev 246) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -51,6 +51,16 @@ return instance; } + + /// <summary> + /// Shorter way to call TheDefaultIsConcreteType + /// </summary> + /// <param name="concreteType"></param> + /// <returns></returns> + public ConfiguredInstance Use(Type concreteType) + { + return TheDefaultIsConcreteType(concreteType); + } /// <summary> /// Shortcut method to add an additional Instance to this Plugin Type Modified: trunk/Source/StructureMap/Configuration/DSL/Registry.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2009-06-03 03:04:58 UTC (rev 246) +++ trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -47,7 +47,20 @@ void SelectConstructor<T>(Expression<Func<T>> expression); } + public static class RegistryExtensions + { + public static CreatePluginFamilyExpression<PLUGINTYPE> For<PLUGINTYPE>(this IRegistry registry) + { + return registry.ForRequestedType<PLUGINTYPE>(); + } + public static GenericFamilyExpression For(this IRegistry registry, Type pluginType) + { + return registry.ForRequestedType(pluginType); + } + } + + /// <summary> /// A Registry class provides methods and grammars for configuring a Container or ObjectFactory. /// Using a Registry subclass is the recommended way of configuring a StructureMap Container. Modified: trunk/Source/StructureMap/Container.cs =================================================================== --- trunk/Source/StructureMap/Container.cs 2009-06-03 03:04:58 UTC (rev 246) +++ trunk/Source/StructureMap/Container.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -7,16 +7,15 @@ using StructureMap.Graph; using StructureMap.Interceptors; using StructureMap.Pipeline; -using System.Linq; namespace StructureMap { public class Container : TypeRules, IContainer { private InterceptorLibrary _interceptorLibrary; - private Model _model; private PipelineGraph _pipelineGraph; private PluginGraph _pluginGraph; + private IObjectCache _transientCache = new NulloObjectCache(); public Container(Action<ConfigurationExpression> action) { @@ -26,11 +25,13 @@ construct(expression.BuildGraph()); } - public Container(Registry registry) : this(registry.Build()) + public Container(Registry registry) + : this(registry.Build()) { } - public Container() : this(new PluginGraph()) + public Container() + : this(new PluginGraph()) { } @@ -44,25 +45,16 @@ construct(pluginGraph); } - protected MissingFactoryFunction onMissingFactory - { - set { _pipelineGraph.OnMissingFactory = value; } - } + protected MissingFactoryFunction onMissingFactory { set { _pipelineGraph.OnMissingFactory = value; } } + public PluginGraph PluginGraph { get { return _pluginGraph; } } + #region IContainer Members - public PluginGraph PluginGraph - { - get { return _pluginGraph; } - } - /// <summary> /// Provides queryable access to the configured PluginType's and Instances of this Container /// </summary> - public IModel Model - { - get { return _model; } - } + public IModel Model { get { return new Model(_pipelineGraph); } } /// <summary> /// Creates or finds the named instance of T @@ -110,30 +102,12 @@ public object GetInstance(Type pluginType, ExplicitArguments args) { Instance defaultInstance = _pipelineGraph.GetDefault(pluginType); - var requestedName = Plugin.DEFAULT; + string requestedName = Plugin.DEFAULT; return buildInstanceWithArgs(pluginType, defaultInstance, args, requestedName); } - private object buildInstanceWithArgs(Type pluginType, Instance defaultInstance, ExplicitArguments args, string requestedName) - { - if (defaultInstance == null && pluginType.IsConcrete()) - { - defaultInstance = new ConfiguredInstance(pluginType); - } - BasicInstance basicInstance = defaultInstance as BasicInstance; - - Instance instance = basicInstance == null ? defaultInstance : new ExplicitInstance(pluginType, args, basicInstance); - - BuildSession session = withNewSession(requestedName); - - args.RegisterDefaults(session); - - return session.CreateInstance(pluginType, instance); - } - - /// <summary> /// Gets all configured instances of type T using explicitly configured arguments from the "args" /// </summary> @@ -146,7 +120,7 @@ args.RegisterDefaults(session); - var instances = session.CreateInstanceArray(type, null); + Array instances = session.CreateInstanceArray(type, null); return new ArrayList(instances); } @@ -241,9 +215,9 @@ /// <returns></returns> public object TryGetInstance(Type pluginType, string instanceKey) { - return !_pipelineGraph.HasInstance(pluginType, instanceKey) - ? null - : GetInstance(pluginType, instanceKey); + return !_pipelineGraph.HasInstance(pluginType, instanceKey) + ? null + : GetInstance(pluginType, instanceKey); } /// <summary> @@ -253,9 +227,9 @@ /// <returns></returns> public object TryGetInstance(Type pluginType) { - return !_pipelineGraph.HasDefaultForPluginType(pluginType) - ? null - : GetInstance(pluginType); + return !_pipelineGraph.HasDefaultForPluginType(pluginType) + ? null + : GetInstance(pluginType); } /// <summary> @@ -265,7 +239,7 @@ /// <returns></returns> public T TryGetInstance<T>() { - return (T)(TryGetInstance(typeof (T)) ?? default(T)); + return (T) (TryGetInstance(typeof (T)) ?? default(T)); } /// <summary> @@ -276,11 +250,11 @@ /// <param name="target"></param> public void BuildUp(object target) { - var pluggedType = target.GetType(); - IConfiguredInstance instance = _pipelineGraph.GetDefault(pluggedType) as IConfiguredInstance - ?? new ConfiguredInstance(pluggedType); + Type pluggedType = target.GetType(); + IConfiguredInstance instance = _pipelineGraph.GetDefault(pluggedType) as IConfiguredInstance + ?? new ConfiguredInstance(pluggedType); - var builder = PluginCache.FindBuilder(pluggedType); + InstanceBuilder builder = PluginCache.FindBuilder(pluggedType); builder.BuildUp(instance, withNewSession(Plugin.DEFAULT), target); } @@ -291,7 +265,7 @@ /// <returns></returns> public T TryGetInstance<T>(string instanceKey) { - return (T)(TryGetInstance(typeof(T), instanceKey) ?? default(T)); + return (T) (TryGetInstance(typeof (T), instanceKey) ?? default(T)); } /// <summary> @@ -365,7 +339,7 @@ /// <returns></returns> public IList GetAllInstances(Type pluginType) { - var instances = withNewSession(Plugin.DEFAULT).CreateInstanceArray(pluginType, null); + Array instances = withNewSession(Plugin.DEFAULT).CreateInstanceArray(pluginType, null); return new ArrayList(instances); } @@ -434,15 +408,7 @@ return new ExplicitArgsExpression(this).With(argName); } - public ExplicitArgsExpression With(Action<ExplicitArgsExpression> action) - { - var expression = new ExplicitArgsExpression(this); - action(expression); - return expression; - } - - /// <summary> /// Use with caution! Does a full environment test of the configuration of this container. Will try to create every configured /// instance and afterward calls any methods marked with the [ValidationMethod] attribute @@ -467,8 +433,95 @@ _pipelineGraph.EjectAllInstancesOf<T>(); } + /// <summary> + /// Convenience method to request an object using an Open Generic + /// Type and its parameter Types + /// </summary> + /// <param name="templateType"></param> + /// <returns></returns> + /// <example> + /// IFlattener flattener1 = container.ForGenericType(typeof (IFlattener<>)) + /// .WithParameters(typeof (Address)).GetInstanceAs<IFlattener>(); + /// </example> + public OpenGenericTypeExpression ForGenericType(Type templateType) + { + return new OpenGenericTypeExpression(templateType, this); + } + + /// <summary> + /// Shortcut syntax for using an object to find a service that handles + /// that type of object by using an open generic type + /// </summary> + /// <example> + /// IHandler handler = container.ForObject(shipment) + /// .GetClosedTypeOf(typeof (IHandler<>)) + /// .As<IHandler>(); + /// </example> + /// <param name="subject"></param> + /// <returns></returns> + public CloseGenericTypeExpression ForObject(object subject) + { + return new CloseGenericTypeExpression(subject, this); + } + + /// <summary> + /// Starts a "Nested" Container for atomic, isolated access + /// </summary> + /// <returns></returns> + public IContainer GetNestedContainer() + { + return new Container() + { + _interceptorLibrary = _interceptorLibrary, + _pipelineGraph = _pipelineGraph.Clone(), + _transientCache = new MainObjectCache() + }; + } + + /// <summary> + /// Starts a new "Nested" Container for atomic, isolated service location. Opens + /// </summary> + /// <param name="profileName"></param> + /// <returns></returns> + public IContainer GetNestedContainer(string profileName) + { + var container = GetNestedContainer(); + container.SetDefaultsToProfile(profileName); + + return container; + } + #endregion + private object buildInstanceWithArgs(Type pluginType, Instance defaultInstance, ExplicitArguments args, + string requestedName) + { + if (defaultInstance == null && pluginType.IsConcrete()) + { + defaultInstance = new ConfiguredInstance(pluginType); + } + + var basicInstance = defaultInstance as BasicInstance; + + Instance instance = basicInstance == null + ? defaultInstance + : new ExplicitInstance(pluginType, args, basicInstance); + + BuildSession session = withNewSession(requestedName); + + args.RegisterDefaults(session); + + return session.CreateInstance(pluginType, instance); + } + + public ExplicitArgsExpression With(Action<ExplicitArgsExpression> action) + { + var expression = new ExplicitArgsExpression(this); + action(expression); + + return expression; + } + private void construct(PluginGraph pluginGraph) { _interceptorLibrary = pluginGraph.InterceptorLibrary; @@ -482,7 +535,6 @@ pluginGraph.Log.AssertFailures(); _pipelineGraph = new PipelineGraph(pluginGraph); - _model = new Model(_pipelineGraph); PluginCache.Compile(); @@ -492,7 +544,7 @@ private IList<T> getListOfTypeWithSession<T>(BuildSession session) { var list = new List<T>(); - foreach (T instance in session.CreateInstanceArray(typeof(T), null)) + foreach (T instance in session.CreateInstanceArray(typeof (T), null)) { list.Add(instance); } @@ -512,30 +564,27 @@ private BuildSession withNewSession(string name) { - return new BuildSession(_pipelineGraph, _interceptorLibrary){RequestedName = name}; + return new BuildSession(_pipelineGraph, _interceptorLibrary, _transientCache) + { + RequestedName = name + }; } - /// <summary> - /// Convenience method to request an object using an Open Generic - /// Type and its parameter Types - /// </summary> - /// <param name="templateType"></param> - /// <returns></returns> - /// <example> - /// IFlattener flattener1 = container.ForGenericType(typeof (IFlattener<>)) - /// .WithParameters(typeof (Address)).GetInstanceAs<IFlattener>(); - /// </example> - public OpenGenericTypeExpression ForGenericType(Type templateType) + #region Nested type: GetInstanceAsExpression + + public interface GetInstanceAsExpression { - return new OpenGenericTypeExpression(templateType, this); + T GetInstanceAs<T>(); } - + #endregion + #region Nested type: OpenGenericTypeExpression + public class OpenGenericTypeExpression : GetInstanceAsExpression { + private readonly Container _container; private readonly Type _templateType; - private readonly Container _container; private Type _pluginType; public OpenGenericTypeExpression(Type templateType, Container container) @@ -549,39 +598,22 @@ _container = container; } - public GetInstanceAsExpression WithParameters(params Type[] parameterTypes) - { - _pluginType = _templateType.MakeGenericType(parameterTypes); - return this; - } + #region GetInstanceAsExpression Members public T GetInstanceAs<T>() { return (T) _container.GetInstance(_pluginType); } - } - public interface GetInstanceAsExpression - { - T GetInstanceAs<T>(); + #endregion + + public GetInstanceAsExpression WithParameters(params Type[] parameterTypes) + { + _pluginType = _templateType.MakeGenericType(parameterTypes); + return this; + } } - /// <summary> - /// Shortcut syntax for using an object to find a service that handles - /// that type of object by using an open generic type - /// </summary> - /// <example> - /// IHandler handler = container.ForObject(shipment) - /// .GetClosedTypeOf(typeof (IHandler<>)) - /// .As<IHandler>(); - /// </example> - /// <param name="subject"></param> - /// <returns></returns> - public CloseGenericTypeExpression ForObject(object subject) - { - return new CloseGenericTypeExpression(subject, this); - } + #endregion } - - } \ No newline at end of file Modified: trunk/Source/StructureMap/Diagnostics/ValidationBuildSession.cs =================================================================== --- trunk/Source/StructureMap/Diagnostics/ValidationBuildSession.cs 2009-06-03 03:04:58 UTC (rev 246) +++ trunk/Source/StructureMap/Diagnostics/ValidationBuildSession.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -17,7 +17,7 @@ private List<IInstance> _explicitInstances; public ValidationBuildSession(PipelineGraph pipelineGraph, InterceptorLibrary interceptorLibrary) - : base(pipelineGraph, interceptorLibrary) + : base(pipelineGraph, interceptorLibrary, new NulloObjectCache()) { } @@ -47,6 +47,7 @@ try { + //clearBuildStack(); return base.CreateInstance(pluginType, instance); } catch (StructureMapException ex) Modified: trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs =================================================================== --- trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs 2009-06-03 03:04:58 UTC (rev 246) +++ trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -7,13 +7,18 @@ { public class GenericsPluginGraph { - private readonly Cache<Type, PluginFamily> _families; + private Cache<Type, PluginFamily> _families; public GenericsPluginGraph() { _families = new Cache<Type, PluginFamily>(pluginType => new PluginFamily(pluginType)); } + public GenericsPluginGraph Clone() + { + return new GenericsPluginGraph(){_families = _families.Clone()}; + } + public int FamilyCount { get { return _families.Count; } Modified: trunk/Source/StructureMap/IContainer.cs =================================================================== --- trunk/Source/StructureMap/IContainer.cs 2009-06-03 03:04:58 UTC (rev 246) +++ trunk/Source/StructureMap/IContainer.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -268,5 +268,23 @@ /// <param name="subject"></param> /// <returns></returns> CloseGenericTypeExpression ForObject(object subject); + + + + /// <summary> + /// Starts a "Nested" Container for atomic, isolated access + /// </summary> + /// <returns></returns> + IContainer GetNestedContainer(); + + /// <summary> + /// Starts a new "Nested" Container for atomic, isolated service location. Opens + /// </summary> + /// <param name="profileName"></param> + /// <returns></returns> + IContainer GetNestedContainer(string profileName); } + + + } \ No newline at end of file Modified: trunk/Source/StructureMap/IInstanceFactory.cs =================================================================== --- trunk/Source/StructureMap/IInstanceFactory.cs 2009-06-03 03:04:58 UTC (rev 246) +++ trunk/Source/StructureMap/IInstanceFactory.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -12,19 +12,19 @@ public interface IInstanceFactory { Type PluginType { get; } - IEnumerable<IInstance> Instances { get; } - Instance MissingInstance { get; set; } + Instance MissingInstance { get; } + Instance[] AllInstances { get; } + // need to override this void AddInstance(Instance instance); - Instance AddType<T>(); + Instance FindInstance(string name); - void ImportFrom(PluginFamily family); [Obsolete("Kill!!!!")] @@ -32,6 +32,7 @@ ILifecycle Lifecycle {get; } + IInstanceFactory Clone(); + } - } } \ No newline at end of file Modified: trunk/Source/StructureMap/InstanceCache.cs =================================================================== --- trunk/Source/StructureMap/InstanceCache.cs 2009-06-03 03:04:58 UTC (rev 246) +++ trunk/Source/StructureMap/InstanceCache.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -25,6 +25,16 @@ public object Get(Type pluginType, Instance instance) { + if (pluginType == null) + { + throw new ArgumentNullException("pluginType"); + } + + if (instance == null) + { + throw new ArgumentNullException("instance", "Trying to find an Instance of type " + pluginType.AssemblyQualifiedName); + } + Dictionary<Instance, object> cache = getCache(pluginType); if (cache.ContainsKey(instance)) { Modified: trunk/Source/StructureMap/InstanceFactory.cs =================================================================== --- trunk/Source/StructureMap/InstanceFactory.cs 2009-06-03 03:04:58 UTC (rev 246) +++ trunk/Source/StructureMap/InstanceFactory.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -12,7 +12,7 @@ /// </summary> public class InstanceFactory : IInstanceFactory { - private readonly Cache<string, Instance> _instances = + private Cache<string, Instance> _instances = new Cache<string, Instance>(delegate { return null; }); private readonly Type _pluginType; @@ -82,11 +82,6 @@ get { return _pluginType; } } - public IEnumerable<IInstance> Instances - { - get { return _instances.GetAll(); } - } - public Instance[] AllInstances { get @@ -102,17 +97,6 @@ } - [Obsolete] - public Instance AddType<T>() - { - ConfiguredInstance instance = - new ConfiguredInstance(typeof (T)).WithName(TypePath.GetAssemblyQualifiedName(typeof (T))); - - AddInstance(instance); - - return instance; - } - public Instance FindInstance(string name) { return _instances[name] ?? MissingInstance; @@ -149,7 +133,18 @@ get { return _lifecycle; } set { _lifecycle = value; } } + + public IInstanceFactory Clone() + { + var factory = new InstanceFactory(_pluginType); + factory.MissingInstance = MissingInstance; + factory._lifecycle = _lifecycle; + factory._instances = _instances.Clone(); + + return factory; + } + #endregion } } \ No newline at end of file Modified: trunk/Source/StructureMap/Pipeline/BuildStack.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/BuildStack.cs 2009-06-03 03:04:58 UTC (rev 246) +++ trunk/Source/StructureMap/Pipeline/BuildStack.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -64,5 +64,10 @@ _current = _current.Detach(); if (_current == null) _root = null; } + + public void Clear() + { + _current = _root = null; + } } } \ No newline at end of file Modified: trunk/Source/StructureMap/Pipeline/ConfiguredInstanceBase.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/ConfiguredInstanceBase.cs 2009-06-03 03:04:58 UTC (rev 246) +++ trunk/Source/StructureMap/Pipeline/ConfiguredInstanceBase.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -206,6 +206,15 @@ protected void setChildArray(string name, Instance[] array) { + for (int i = 0; i < array.Length; i++) + { + if (array[i] == null) + { + throw new ApplicationException("There is a null value in the array of child Instances"); + } + + } + _arrays.Add(name, array); } Added: trunk/Source/StructureMap/Pipeline/ILifecycle.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/ILifecycle.cs (rev 0) +++ trunk/Source/StructureMap/Pipeline/ILifecycle.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -0,0 +1,8 @@ +namespace StructureMap.Pipeline +{ + public interface ILifecycle + { + void EjectAll(); + IObjectCache FindCache(); + } +} \ No newline at end of file Added: trunk/Source/StructureMap/Pipeline/IObjectCache.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/IObjectCache.cs (rev 0) +++ trunk/Source/StructureMap/Pipeline/IObjectCache.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -0,0 +1,18 @@ +using System; + +namespace StructureMap.Pipeline +{ + public interface IObjectCache + { + object Locker { get; } + + int Count + { + get; + } + + object Get(Type pluginType, Instance instance); + void Set(Type pluginType, Instance instance, object value); + void DisposeAndClear(); + } +} \ No newline at end of file Added: trunk/Source/StructureMap/Pipeline/Lifecycles.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/Lifecycles.cs (rev 0) +++ trunk/Source/StructureMap/Pipeline/Lifecycles.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -0,0 +1,37 @@ +using System; +using StructureMap.Attributes; + +namespace StructureMap.Pipeline +{ + public static class Lifecycles + { + public static ILifecycle GetLifecycle(InstanceScope scope) + { + switch (scope) + { + case InstanceScope.PerRequest: + return null; + + case InstanceScope.Singleton: + return new SingletonLifecycle(); + + case InstanceScope.HttpContext: + return new HttpContextLifecycle(); + + case InstanceScope.ThreadLocal: + return new ThreadLocalStorageLifecycle(); + + case InstanceScope.Hybrid: + return new HybridLifecycle(); + + case InstanceScope.HttpSession: + return new HttpSessionLifecycle(); + + case InstanceScope.HybridHttpSession: + return new HybridSessionLifecycle(); + } + + throw new ArgumentOutOfRangeException("scope"); + } + } +} \ No newline at end of file Added: trunk/Source/StructureMap/Pipeline/MainObjectCache.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/MainObjectCache.cs (rev 0) +++ trunk/Source/StructureMap/Pipeline/MainObjectCache.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; + +namespace StructureMap.Pipeline +{ + public class MainObjectCache : IObjectCache + { + private readonly IDictionary<InstanceKey, object> _objects = new Dictionary<InstanceKey,object>(); + private readonly object _locker = new object(); + + public object Locker + { + get { return _locker; } + } + + public int Count + { + get { return _objects.Count; } + } + + public object Get(Type pluginType, Instance instance) + { + var key = new InstanceKey(instance, pluginType); + return _objects.ContainsKey(key) ? _objects[key] : null; + } + + public void Set(Type pluginType, Instance instance, object value) + { + var key = new InstanceKey(instance, pluginType); + _objects.Add(key, value); + } + + public void DisposeAndClear() + { + lock (Locker) + { + foreach (var @object in _objects.Values) + { + IDisposable disposable = @object as IDisposable; + if (disposable != null) + { + try + { + disposable.Dispose(); + } + catch (Exception) { } + } + } + + _objects.Clear(); + } + } + } +} \ No newline at end of file Added: trunk/Source/StructureMap/Pipeline/NulloObjectCache.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/NulloObjectCache.cs (rev 0) +++ trunk/Source/StructureMap/Pipeline/NulloObjectCache.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -0,0 +1,32 @@ +using System; + +namespace StructureMap.Pipeline +{ + public class NulloObjectCache : IObjectCache + { + public object Locker + { + get { return new object(); } + } + + public int Count + { + get { return 0; } + } + + public object Get(Type pluginType, Instance instance) + { + return null; + } + + public void Set(Type pluginType, Instance instance, object value) + { + // no-op + } + + public void DisposeAndClear() + { + // no-op + } + } +} \ No newline at end of file Added: trunk/Source/StructureMap/Pipeline/ObjectBuilder.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/ObjectBuilder.cs (rev 0) +++ trunk/Source/StructureMap/Pipeline/ObjectBuilder.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -0,0 +1,69 @@ +using System; +using StructureMap.Interceptors; + +namespace StructureMap.Pipeline +{ + public class ObjectBuilder + { + private readonly PipelineGraph _pipeline; + private readonly InterceptorLibrary _library; + private readonly IObjectCache _defaultCache; + + public ObjectBuilder(PipelineGraph pipeline, InterceptorLibrary library, IObjectCache defaultCache) + { + if (pipeline == null) throw new ArgumentNullException("pipeline"); + + _pipeline = pipeline; + _library = library; + _defaultCache = defaultCache; + } + + public object Resolve(Type pluginType, Instance instance, BuildSession session) + { + var cache = FindCache(pluginType, instance, session); + lock (cache.Locker) + { + var returnValue = cache.Get(pluginType, instance); + if (returnValue == null) + { + returnValue = ConstructNew(pluginType, instance, session); + + + cache.Set(pluginType, instance, returnValue); + } + + return returnValue; + } + } + + public object ConstructNew(Type pluginType, Instance instance, BuildSession session) + { + object returnValue = instance.Build(pluginType, session); + return ApplyInterception(pluginType, returnValue, session, instance); + } + + public virtual object ApplyInterception(Type pluginType, object actualValue, BuildSession session, Instance instance) + { + if (actualValue == null) return null; + + try + { + return _library.FindInterceptor(actualValue.GetType()).Process(actualValue, session); + } + catch (Exception e) + { + throw new StructureMapException(308, e, instance.Name, actualValue.GetType()); + } + + + } + + public IObjectCache FindCache(Type pluginType, Instance instance, BuildSession session) + { + var lifecycle = _pipeline.ForType(pluginType).Lifecycle; + return lifecycle == null + ? _defaultCache + : lifecycle.FindCache(); + } + } +} \ No newline at end of file Modified: trunk/Source/StructureMap/Pipeline/ProfileManager.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/ProfileManager.cs 2009-06-03 03:04:58 UTC (rev 246) +++ trunk/Source/StructureMap/Pipeline/ProfileManager.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -224,6 +224,19 @@ CurrentProfile = CurrentProfile; } + public ProfileManager Clone() + { + var clone = new ProfileManager() + { + DefaultMachineProfileName = DefaultMachineProfileName, + DefaultProfileName = DefaultProfileName + }; + + clone.ImportFrom(this); + + return clone; + } + public void EjectAllInstancesOf<T>() { _currentProfile.Remove<T>(); Modified: trunk/Source/StructureMap/PipelineGraph.cs =================================================================== --- trunk/Source/StructureMap/PipelineGraph.cs 2009-06-03 03:04:58 UTC (rev 246) +++ trunk/Source/StructureMap/PipelineGraph.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -41,6 +41,27 @@ } } + private PipelineGraph(ProfileManager profileManager, GenericsPluginGraph genericsGraph) + { + _profileManager = profileManager; + _genericsGraph = genericsGraph; + } + + public PipelineGraph Clone() + { + var clone = new PipelineGraph(_profileManager.Clone(), _genericsGraph.Clone()) + { + _missingFactory = _missingFactory + }; + + foreach (var pair in _factories) + { + clone._factories.Add(pair.Key, pair.Value); + } + + return clone; + } + public GraphLog Log { get { return _log; } @@ -76,7 +97,7 @@ Default = _profileManager.GetDefault(factory.PluginType), PluginType = factory.PluginType, Lifecycle = factory.Lifecycle, - Instances = factory.Instances + Instances = factory.AllInstances }; } } @@ -152,22 +173,12 @@ _profileManager.SetDefault(pluginType, instance); } - public Instance AddInstance<PLUGINTYPE, PLUGGEDTYPE>() - { - return ForType(typeof (PLUGINTYPE)).AddType<PLUGGEDTYPE>(); - } public void AddInstance<T>(Instance instance) { ForType(typeof (T)).AddInstance(instance); } - public void AddDefaultInstance<PLUGINTYPE, PLUGGEDTYPE>() - { - Instance instance = AddInstance<PLUGINTYPE, PLUGGEDTYPE>(); - _profileManager.SetDefault(typeof (PLUGINTYPE), instance); - } - public void Inject<PLUGINTYPE>(PLUGINTYPE instance) { var literalInstance = new LiteralInstance(instance); @@ -190,7 +201,7 @@ if (_factories.ContainsKey(pluginType)) { - return _factories[pluginType].Instances; + return _factories[pluginType].AllInstances; } return new IInstance[0]; @@ -202,7 +213,7 @@ foreach (var pair in _factories) { - list.AddRange(pair.Value.Instances); + list.AddRange(pair.Value.AllInstances); } return list; Modified: trunk/Source/StructureMap/StructureMap.csproj =================================================================== --- trunk/Source/StructureMap/StructureMap.csproj 2009-06-03 03:04:58 UTC (rev 246) +++ trunk/Source/StructureMap/StructureMap.csproj 2009-06-03 16:21:03 UTC (rev 247) @@ -404,7 +404,12 @@ <Compile Include="Pipeline\HttpLifecycleBase.cs" /> <Compile Include="Pipeline\HttpSessionLifecycle.cs" /> <Compile Include="Pipeline\HybridSessionLifecycle.cs" /> - <Compile Include="Pipeline\Lifecycle.cs" /> + <Compile Include="Pipeline\ILifecycle.cs" /> + <Compile Include="Pipeline\IObjectCache.cs" /> + <Compile Include="Pipeline\Lifecycles.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" /> Modified: trunk/Source/StructureMap/Util/Cache.cs =================================================================== --- trunk/Source/StructureMap/Util/Cache.cs 2009-06-03 03:04:58 UTC (rev 246) +++ trunk/Source/StructureMap/Util/Cache.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -9,8 +9,6 @@ private readonly object _locker = new object(); private readonly IDictionary<KEY, VALUE> _values; - private Func<VALUE, KEY> _getKey = delegate { throw new NotImplementedException(); }; - private Func<KEY, VALUE> _onMissing = delegate(KEY key) { string message = string.Format("Key '{0}' could not be found", key); @@ -38,22 +36,11 @@ _values = dictionary; } - public object Locker - { - get { return _locker; } - } - public Func<KEY, VALUE> OnMissing { set { _onMissing = value; } } - public Func<VALUE, KEY> GetKey - { - get { return _getKey; } - set { _getKey = value; } - } - public int Count { get { return _values.Count; } @@ -135,19 +122,6 @@ _values.Add(key, value); } - public bool TryRetrieve(KEY key, out VALUE value) - { - value = default(VALUE); - - if (_values.ContainsKey(key)) - { - value = _values[key]; - return true; - } - - return false; - } - public void Each(Action<VALUE> action) { lock (_locker) @@ -214,5 +188,13 @@ { _values.Clear(); } + + public Cache<KEY, VALUE> Clone() + { + var clone = new Cache<KEY, VALUE>(_onMissing); + Each((k, v) => clone[k] = v); + + return clone; + } } } Modified: trunk/Source/StructureMap.Testing/BuildSessionTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/BuildSessionTester.cs 2009-06-03 03:04:58 UTC (rev 246) +++ trunk/Source/StructureMap.Testing/BuildSessionTester.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -151,7 +151,7 @@ assertActionThrowsErrorCode(200, delegate { - var session = new BuildSession(graph, null); + var session = new BuildSession(graph, null, new NulloObjectCache()); session.CreateInstance(typeof (IGateway), "Gateway that is not configured"); }); } @@ -183,7 +183,7 @@ assertActionThrowsErrorCode(202, delegate { - var session = new BuildSession(graph, null); + var session = new BuildSession(graph, null, new NulloObjectCache()); session.CreateInstance(typeof (IGateway)); }); } Modified: trunk/Source/StructureMap.Testing/Graph/InstanceFactoryTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Graph/InstanceFactoryTester.cs 2009-06-03 03:04:58 UTC (rev 246) +++ trunk/Source/StructureMap.Testing/Graph/InstanceFactoryTester.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -71,7 +71,7 @@ factory.EjectAllInstances(); - factory.Instances.Count().ShouldEqual(0); + factory.AllInstances.Count().ShouldEqual(0); lifecycle.AssertWasCalled(x => x.EjectAll()); } @@ -143,4 +143,58 @@ } + + [TestFixture] + public class when_cloning_an_InstanceFactory + { + private InstanceFactory factory; + private IInstanceFactory clone; + + [SetUp] + public void SetUp() + { + factory = new InstanceFactory(typeof(IGateway)); + factory.AddInstance(new SmartInstance<DefaultGateway>()); + factory.AddInstance(new SmartInstance<DefaultGateway>()); + + var lifecycle = MockRepository.GenerateMock<ILifecycle>(); + factory.Lifecycle = lifecycle; + factory.MissingInstance = new SmartInstance<DefaultGateway>(); + + clone = factory.Clone(); + } + + [Test] + public void missing_instance_is_copied() + { + clone.MissingInstance.ShouldBeTheSameAs(factory.MissingInstance); + } + + [Test] + public void lifecycle_is_copied() + { + clone.Lifecycle.ShouldBeTheSameAs(factory.Lifecycle); + } + + [Test] + public void plugin_type_is_set_on_the_clone() + { + clone.PluginType.ShouldEqual(typeof (IGateway)); + } + + [Test] + public void the_instances_are_copied() + { + clone.AllInstances.Count().ShouldEqual(2); + } + + [Test] + public void the_instances_are_cloned_so_that_new_instances_are_NOT_injected_into_() + { + clone.AddInstance(new LiteralInstance(new DefaultGateway())); + + factory.AllInstances.Count().ShouldEqual(2); + clone.AllInstances.Count().ShouldEqual(3); + } + } } \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/Pipeline/ConfiguredInstanceTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Pipeline/ConfiguredInstanceTester.cs 2009-06-03 03:04:58 UTC (rev 246) +++ trunk/Source/StructureMap.Testing/Pipeline/ConfiguredInstanceTester.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -30,7 +30,7 @@ PluginGraph graph = registry.Build(); var pipelineGraph = new PipelineGraph(graph); - _session = new BuildSession(pipelineGraph, graph.InterceptorLibrary); + _session = new BuildSession(pipelineGraph, graph.InterceptorLibrary, new NulloObjectCache()); } #endregion Added: trunk/Source/StructureMap.Testing/Pipeline/NestedContainerSupportTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Pipeline/NestedContainerSupportTester.cs (rev 0) +++ trunk/Source/StructureMap.Testing/Pipeline/NestedContainerSupportTester.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -0,0 +1,131 @@ +using NUnit.Framework; +using StructureMap.Attributes; +using StructureMap.Configuration.DSL; +using StructureMap.Testing.GenericWidgets; +using StructureMap.Testing.Widget; + +namespace StructureMap.Testing.Pipeline +{ + [TestFixture] + public class NestedContainerSupportTester + { + [SetUp] + public void SetUp() + { + } + + [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 child = parent.GetNestedContainer(); + + var childWidget1 = child.GetInstance<IWidget>(); + var childWidget2 = child.GetInstance<IWidget>(); + var childWidget3 = child.GetInstance<IWidget>(); + + var parentWidget = parent.GetInstance<IWidget>(); + + childWidget1.ShouldBeTheSameAs(childWidget2); + childWidget1.ShouldBeTheSameAs(childWidget3); + childWidget1.ShouldNotBeTheSameAs(parentWidget); + } + + [Test] + public void singleton_service_in_the_parent_is_found_by_the_child() + { + var parent = new Container(x => + { + x.ForSingletonOf<IWidget>().Use<AWidget>(); + }); + + var parentWidget = parent.GetInstance<IWidget>(); + + var child = parent.GetNestedContainer(); + + var childWidget1 = child.GetInstance<IWidget>(); + var childWidget2 = child.GetInstance<IWidget>(); + + parentWidget.ShouldBeTheSameAs(childWidget1); + parentWidget.ShouldBeTheSameAs(childWidget2); + } + + [Test] + public void transient_open_generics_service_in_the_parent_container_is_effectively_a_singleton_for_the_nested_container() + { + var parent = new Container(x => + { + x.For(typeof(IService<>)).Use(typeof(Service<>)); + }); + + var child = parent.GetNestedContainer(); + + var childWidget1 = child.GetInstance<IService<string>>(); + var childWidget2 = child.GetInstance<IService<string>>(); + var childWidget3 = child.GetInstance<IService<string>>(); + + var parentWidget = parent.GetInstance<IService<string>>(); + + childWidget1.ShouldBeTheSameAs(childWidget2); + childWidget1.ShouldBeTheSameAs(childWidget3); + childWidget1.ShouldNotBeTheSameAs(parentWidget); + } + + [Test] + public void singleton_service_from_open_type_in_the_parent_is_found_by_the_child() + { + var parent = new Container(x => + { + x.For(typeof(IService<>)).CacheBy(InstanceScope.Singleton).Use(typeof(Service<>)); + }); + + var child = parent.GetNestedContainer(); + + var childWidget1 = child.GetInstance<IService<string>>(); + var childWidget2 = child.GetInstance<IService<string>>(); + var childWidget3 = child.GetInstance<IService<string>>(); + + var parentWidget = parent.GetInstance<IService<string>>(); + + childWidget1.ShouldBeTheSameAs(childWidget2); + childWidget1.ShouldBeTheSameAs(childWidget3); + childWidget1.ShouldBeTheSameAs(parentWidget); + } + + [Test] + public void get_a_nested_container_for_a_profile() + { + var parent = new Container(x => + { + x.For<IWidget>().TheDefault.Is.OfConcreteType<ColorWidget>() + .WithCtorArg("color").EqualTo("red"); + + x.CreateProfile("green", o => + { + o.Type<IWidget>().Is.OfConcreteType<ColorWidget>() + .WithCtorArg("color").EqualTo("green"); + }); + + }); + + var child = parent.GetNestedContainer("green"); + + var childWidget1 = child.GetInstance<IWidget>(); + var childWidget2 = child.GetInstance<IWidget>(); + var childWidget3 = child.GetInstance<IWidget>(); + + var parentWidget = parent.GetInstance<IWidget>(); + + childWidget1.ShouldBeTheSameAs(childWidget2); + childWidget1.ShouldBeTheSameAs(childWidget3); + childWidget1.ShouldNotBeTheSameAs(parentWidget); + + parentWidget.ShouldBeOfType<ColorWidget>().Color.ShouldEqual("red"); + childWidget1.ShouldBeOfType<ColorWidget>().Color.ShouldEqual("green"); + } + } +} \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj =================================================================== --- trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-06-03 03:04:58 UTC (rev 246) +++ trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-06-03 16:21:03 UTC (rev 247) @@ -353,6 +353,7 @@ <Compile Include="Pipeline\InstanceTester.cs" /> <Compile Include="Pipeline\LiteralInstanceTester.cs" /> <Compile Include="Pipeline\MissingInstanceTester.cs" /> + <Compile Include="Pipeline\NestedContainerSupportTester.cs" /> <Compile Include="Pipeline\ObjectBuilderTester.cs" /> <Compile Include="Pipeline\OptionalSetterInjectionTester.cs" /> <Compile Include="Pipeline\ProfileManagerMergeTester.cs" /> @@ -383,6 +384,7 @@ <Compile Include="TestUtility.cs" /> <Compile Include="Diagnostics\ValidationBuildSessionTester.cs" /> <Compile Include="TypeExtensionsTester.cs" /> + <Compile Include="Util\CacheTester.cs" /> <Compile Include="XmlWriting\ElementChecker.cs"> <SubType>Code</SubType> </Compile> Added: trunk/Source/StructureMap.Testing/Util/CacheTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Util/CacheTester.cs (rev 0) +++ trunk/Source/StructureMap.Testing/Util/CacheTester.cs 2009-06-03 16:21:03 UTC (rev 247) @@ -0,0 +1,35 @@ +using NUnit.Framework; +using StructureMap.Testing.Widget; +using StructureMap.Util; + +namespace StructureMap.Testing.Util +{ + [TestFixture] + public class CacheTester + { + [SetUp] + public void SetUp() + { + } + + [Test] + public void cloning_test() + { + var cache = new Cache<string, IWidget>(x => new ColorWidget(x)); + + var red = cache["red"]; + var blue = cache["blue"]; + var green = cache["green"]; + + var clone = cache.Clone(); + + clone["red"].ShouldBeTheSameAs(red); + clone["blue"].ShouldBeTheSameAs(blue); + clone["green"].ShouldBeTheSameAs(green); + + clone["purple"].ShouldBeOfType<ColorWidget>().Color.ShouldEqual("purple"); + + clone["purple"].ShouldNotBeTheSameAs(cache["purple"]); + } + } +} \ No newline at end of file Modified: trunk/Source/StructureMap.sln =================================================================== --- trunk/Source/StructureMap.sln 2009-06-03 03:04:58 UTC (rev 246) +++ trunk/Source/StructureMap.sln 2009-06-03 16:21:03 UTC (rev 247) @@ -4,7 +4,6 @@ ProjectSection(SolutionItems) = preProject ..\Docs\Attributes.htm = ..\Docs\Attributes.htm ..\Docs\Basic Architecture.htm = ..\Docs\Basic Architecture.htm - CommonAssemblyInfo.cs = CommonAssemblyInfo.cs ..\Docs\Concepts.htm = ..\Docs\Concepts.htm ..\Docs\Configuration.htm = ..\Docs\Configuration.htm ..\Docs\ConfigurationManagement.htm = ..\Docs\ConfigurationManagement.htm This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fli...@us...> - 2009-06-03 03:04:59
|
Revision: 246 http://structuremap.svn.sourceforge.net/structuremap/?rev=246&view=rev Author: flimflan Date: 2009-06-03 03:04:58 +0000 (Wed, 03 Jun 2009) Log Message: ----------- Fixing archive step in build (again) Modified Paths: -------------- trunk/cruise.build Modified: trunk/cruise.build =================================================================== --- trunk/cruise.build 2009-06-03 02:54:36 UTC (rev 245) +++ trunk/cruise.build 2009-06-03 03:04:58 UTC (rev 246) @@ -139,9 +139,9 @@ </target> - <target name="archive"> + <target name="archive" depends="version"> <if test="${environment::variable-exists('TEAMCITY_PROJECT_NAME')}"> - <zip zipfile="${archive.dir}\StructureMap_${environment::get-variable('BUILD_NUMBER')}.zip" if="${environment::variable-exists('BUILD_NUMBER')}"> + <zip zipfile="${archive.dir}\StructureMap_${assembly-version}.zip"> <fileset basedir="${build.dir}"> <include name="*.dll" /> <include name="*.exe" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fli...@us...> - 2009-06-03 02:54:37
|
Revision: 245 http://structuremap.svn.sourceforge.net/structuremap/?rev=245&view=rev Author: flimflan Date: 2009-06-03 02:54:36 +0000 (Wed, 03 Jun 2009) Log Message: ----------- Fixing archive step in build (again) Modified Paths: -------------- trunk/RunBuild.BAT trunk/cruise.build Modified: trunk/RunBuild.BAT =================================================================== --- trunk/RunBuild.BAT 2009-06-03 02:44:07 UTC (rev 244) +++ trunk/RunBuild.BAT 2009-06-03 02:54:36 UTC (rev 245) @@ -1,2 +1,2 @@ -bin\nant\nant.exe -buildfile:cruise.build cruise +bin\nant\nant.exe -buildfile:cruise.build %* pause Modified: trunk/cruise.build =================================================================== --- trunk/cruise.build 2009-06-03 02:44:07 UTC (rev 244) +++ trunk/cruise.build 2009-06-03 02:54:36 UTC (rev 245) @@ -8,7 +8,7 @@ <property name="project.config" value="release" /> <property name="archive.dir" value="archive"/> <target name="all" depends="compile, unit-test, post-clean"/> - <target name="cruise" depends="compile, unit-test, post-clean, archive" /> + <target name="ci" depends="compile, unit-test, post-clean, archive" /> <target name="pre-clean"> <delete dir="${build.dir}" failonerror="false" /> @@ -39,7 +39,7 @@ </if> <echo message="Marking this build as version ${assembly-version}" /> - <tc-buildnumber build-number="${'{build.number}'}-${assembly-version}" /> + <tc-buildnumber build-number="${assembly-version}-${'{build.number}'}" /> <asminfo output="Source/CommonAssemblyInfo.cs" language="CSharp"> <imports> <import namespace="System" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fli...@us...> - 2009-06-03 02:44:09
|
Revision: 244 http://structuremap.svn.sourceforge.net/structuremap/?rev=244&view=rev Author: flimflan Date: 2009-06-03 02:44:07 +0000 (Wed, 03 Jun 2009) Log Message: ----------- Fixing archive step in build Modified Paths: -------------- trunk/bin/nant/lib/ICSharpCode.SharpZipLib.dll trunk/cruise.build Modified: trunk/bin/nant/lib/ICSharpCode.SharpZipLib.dll =================================================================== (Binary files differ) Modified: trunk/cruise.build =================================================================== --- trunk/cruise.build 2009-06-03 02:35:48 UTC (rev 243) +++ trunk/cruise.build 2009-06-03 02:44:07 UTC (rev 244) @@ -7,8 +7,6 @@ <property name="project.version" value="2.5.4" /> <property name="project.config" value="release" /> <property name="archive.dir" value="archive"/> - <property name="cibuild" value="false" /> - <property name="cibuild" value="true" if="${environment::variable-exists('TEAMCITY_PROJECT_NAME')}" /> <target name="all" depends="compile, unit-test, post-clean"/> <target name="cruise" depends="compile, unit-test, post-clean, archive" /> @@ -41,7 +39,7 @@ </if> <echo message="Marking this build as version ${assembly-version}" /> - <tc-buildnumber build-number="${assembly-version}_${'{build.number}'}" /> + <tc-buildnumber build-number="${'{build.number}'}-${assembly-version}" /> <asminfo output="Source/CommonAssemblyInfo.cs" language="CSharp"> <imports> <import namespace="System" /> @@ -142,7 +140,7 @@ <target name="archive"> - <if test="${cibuild}"> + <if test="${environment::variable-exists('TEAMCITY_PROJECT_NAME')}"> <zip zipfile="${archive.dir}\StructureMap_${environment::get-variable('BUILD_NUMBER')}.zip" if="${environment::variable-exists('BUILD_NUMBER')}"> <fileset basedir="${build.dir}"> <include name="*.dll" /> @@ -150,9 +148,6 @@ <exclude name="*.xml" /> </fileset> </zip> - - - <nant buildfile="Deploy.build" inheritall="true"/> </if> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fli...@us...> - 2009-06-03 02:35:50
|
Revision: 243 http://structuremap.svn.sourceforge.net/structuremap/?rev=243&view=rev Author: flimflan Date: 2009-06-03 02:35:48 +0000 (Wed, 03 Jun 2009) Log Message: ----------- Fixing some build issues Modified Paths: -------------- trunk/cruise.build Property Changed: ---------------- trunk/Source/ Property changes on: trunk/Source ___________________________________________________________________ Modified: svn:ignore - *.suo _ReSharper.StructureMap PrecompiledWeb *.resharper *.user Ankh.Load _UpgradeReport_Files UpgradeLog.XML UpgradeLog2.XML UpgradeLog3.XML UpgradeLog4.XML *.cache + *.suo _ReSharper.StructureMap PrecompiledWeb *.resharper *.user Ankh.Load _UpgradeReport_Files UpgradeLog.XML UpgradeLog2.XML UpgradeLog3.XML UpgradeLog4.XML *.cache CommonAssemblyInfo.cs Modified: trunk/cruise.build =================================================================== --- trunk/cruise.build 2009-06-03 02:16:54 UTC (rev 242) +++ trunk/cruise.build 2009-06-03 02:35:48 UTC (rev 243) @@ -1,4 +1,5 @@ <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" /> @@ -142,7 +143,7 @@ <target name="archive"> <if test="${cibuild}"> - <zip zipfile="${archive.dir}\StructureMap_${BUILD_NUMBER}.zip" if="${property::exists('BUILD_NUMBER')}"> + <zip zipfile="${archive.dir}\StructureMap_${environment::get-variable('BUILD_NUMBER')}.zip" if="${environment::variable-exists('BUILD_NUMBER')}"> <fileset basedir="${build.dir}"> <include name="*.dll" /> <include name="*.exe" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fli...@us...> - 2009-06-03 02:23:08
|
Revision: 242 http://structuremap.svn.sourceforge.net/structuremap/?rev=242&view=rev Author: flimflan Date: 2009-06-03 02:16:54 +0000 (Wed, 03 Jun 2009) Log Message: ----------- Tightening up TeamCity integration in the build Modified Paths: -------------- trunk/cruise.build Added Paths: ----------- trunk/bin/nant/extensions/common/2.0/License-BlueWireTechnologies.txt trunk/bin/nant/extensions/common/2.0/License-Castle.txt trunk/bin/nant/extensions/common/2.0/License-NAntExtensions.TeamCity.txt trunk/bin/nant/extensions/common/2.0/NAntExtensions.TeamCity.dll trunk/bin/nant/extensions/common/2.0/NAntExtensions.TeamCity.pdb Removed Paths: ------------- trunk/Source/CommonAssemblyInfo.cs Property Changed: ---------------- trunk/ Property changes on: trunk ___________________________________________________________________ Modified: svn:ignore - build results push.bat deploy TestResult.xml + build results push.bat deploy TestResult.xml archive Deleted: trunk/Source/CommonAssemblyInfo.cs =================================================================== --- trunk/Source/CommonAssemblyInfo.cs 2009-05-18 21:40:09 UTC (rev 241) +++ trunk/Source/CommonAssemblyInfo.cs 2009-06-03 02:16:54 UTC (rev 242) @@ -1,23 +0,0 @@ -using System; -using System.Reflection; -using System.Runtime.InteropServices; - -//------------------------------------------------------------------------------ -// <auto-generated> -// This code was generated by a tool. -// Runtime Version:2.0.50727.3053 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// </auto-generated> -//------------------------------------------------------------------------------ - -[assembly: ComVisibleAttribute(false)] -[assembly: AssemblyVersionAttribute("2.5.4.0000")] -[assembly: AssemblyCopyrightAttribute("Copyright (c) 2003-2008, Jeremy D. Miller")] -[assembly: AssemblyProductAttribute("StructureMap")] -[assembly: AssemblyCompanyAttribute("")] -[assembly: AssemblyConfigurationAttribute("release")] -[assembly: AssemblyInformationalVersionAttribute("2.5.4.0000")] -[assembly: AssemblyFileVersionAttribute("2.5.4.0000")] - Added: trunk/bin/nant/extensions/common/2.0/License-BlueWireTechnologies.txt =================================================================== --- trunk/bin/nant/extensions/common/2.0/License-BlueWireTechnologies.txt (rev 0) +++ trunk/bin/nant/extensions/common/2.0/License-BlueWireTechnologies.txt 2009-06-03 02:16:54 UTC (rev 242) @@ -0,0 +1,15 @@ +Copyright (c) 2008, Bluewire Technologies Ltd. +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the name of the Bluewire Technologies Ltd. nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file Added: trunk/bin/nant/extensions/common/2.0/License-Castle.txt =================================================================== --- trunk/bin/nant/extensions/common/2.0/License-Castle.txt (rev 0) +++ trunk/bin/nant/extensions/common/2.0/License-Castle.txt 2009-06-03 02:16:54 UTC (rev 242) @@ -0,0 +1,57 @@ +Apache License, Version 2.0 + +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: + + 1. You must give any other recipients of the Work or Derivative Works a copy of this License; and + + 2. You must cause any modified files to carry prominent notices stating that You changed the files; and + + 3. 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 + + 4. 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 Added: trunk/bin/nant/extensions/common/2.0/License-NAntExtensions.TeamCity.txt =================================================================== --- trunk/bin/nant/extensions/common/2.0/License-NAntExtensions.TeamCity.txt (rev 0) +++ trunk/bin/nant/extensions/common/2.0/License-NAntExtensions.TeamCity.txt 2009-06-03 02:16:54 UTC (rev 242) @@ -0,0 +1,15 @@ +Copyright (c) 2008, Alexander Gro\xDF and Marnix van Valen +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + * Neither the name of the Alexander Gro\xDF and Marnix van Valen nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file Added: trunk/bin/nant/extensions/common/2.0/NAntExtensions.TeamCity.dll =================================================================== (Binary files differ) Property changes on: trunk/bin/nant/extensions/common/2.0/NAntExtensions.TeamCity.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/bin/nant/extensions/common/2.0/NAntExtensions.TeamCity.pdb =================================================================== (Binary files differ) Property changes on: trunk/bin/nant/extensions/common/2.0/NAntExtensions.TeamCity.pdb ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Modified: trunk/cruise.build =================================================================== --- trunk/cruise.build 2009-05-18 21:40:09 UTC (rev 241) +++ trunk/cruise.build 2009-06-03 02:16:54 UTC (rev 242) @@ -1,96 +1,98 @@ <project name="StructureMap" default="all"> - <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.5.4" /> - <property name="project.config" value="release" /> - <property name="archive.dir" value="d:\builds\StructureMap"/> + <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.5.4" /> + <property name="project.config" value="release" /> + <property name="archive.dir" value="archive"/> + <property name="cibuild" value="false" /> + <property name="cibuild" value="true" if="${environment::variable-exists('TEAMCITY_PROJECT_NAME')}" /> + <target name="all" depends="compile, unit-test, post-clean"/> + <target name="cruise" depends="compile, unit-test, post-clean, archive" /> - <target name="all" depends="compile, unit-test, post-clean"/> - <target name="cruise" depends="compile, unit-test, post-clean, archive" /> + <target name="pre-clean"> + <delete dir="${build.dir}" failonerror="false" /> + <delete dir="${results.dir}" failonerror="false"/> - <target name="pre-clean"> - <delete dir="${build.dir}" failonerror="false" /> - <delete dir="${results.dir}" failonerror="false"/> + <mkdir dir="${build.dir}" /> + <mkdir dir="${results.dir}" /> + <mkdir dir="${archive.dir}" unless="${directory::exists(archive.dir)}" /> - <mkdir dir="${build.dir}" /> - <mkdir dir="${results.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> + <call target="cleanJunk" /> + </target> - <target name="version" description="mark AssemblyInfo builds with the build number"> - <property name="assembly-version" value="${project.version}.0000" /> - - <if test="${property::exists('CCNetLabel')}"> - <property name="assembly-version" value="${project.version}.${CCNetLabel}" /> - </if> - - <echo message="Marking this build as version ${assembly-version}" /> - <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="${assembly-version}" /> - <attribute type="AssemblyFileVersionAttribute" value="${assembly-version}" /> - </attributes> - <references> - <include name="System.dll" /> - </references> - </asminfo> - </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" /> + <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')}" /> + </if> - <target name="compile" depends="pre-clean,version"> + <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="${assembly-version}" /> + <attribute type="AssemblyFileVersionAttribute" value="${assembly-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="**\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> - <target name="unit-test"> + <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" /> + <arg value="StructureMap.Testing.dll" /> </exec> <exec program="${nunit-console.exe}" workingdir="${build.dir}"> <arg value="StructureMap.DebuggerVisualizers.Testing.exe" /> @@ -98,61 +100,61 @@ </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="." + + <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" /> + <delete file="build/ObjectMother.config" /> - <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" /> + </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="Source\StructureMapDoctor\bin\${project.config}\StructureMapDoctor.exe" /> + + <call target="cleanJunk" /> + </target> + + + <target name="archive"> + <if test="${cibuild}"> + <zip zipfile="${archive.dir}\StructureMap_${BUILD_NUMBER}.zip" if="${property::exists('BUILD_NUMBER')}"> + <fileset basedir="${build.dir}"> + <include name="*.dll" /> + <include name="*.exe" /> + <exclude name="*.xml" /> </fileset> - </copy> + </zip> - <copy todir="deploy" file="bin\Rhino.Mocks.dll"/> - <copy todir="deploy" file="StructureMap.chm"/> - - <copy todir="deploy" file="Source\StructureMapDoctor\bin\${project.config}\StructureMapDoctor.exe" /> - <call target="cleanJunk" /> - </target> - - - <target name="archive"> - <if test="${property::exists('CCNetLabel')}"> - <zip zipfile="${archive.dir}\StructureMap_${CCNetLabel}.zip" if="${property::exists('CCNetLabel')}"> - <fileset basedir="${build.dir}"> - <include name="*.dll" /> - <include name="*.exe" /> - <exclude name="*.xml" /> - </fileset> - </zip> - - - <nant buildfile="Deploy.build" inheritall="true"/> - </if> - - - </target> + <nant buildfile="Deploy.build" inheritall="true"/> + </if> + + </target> + </project> \ 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...> - 2009-05-18 21:40:20
|
Revision: 241 http://structuremap.svn.sourceforge.net/structuremap/?rev=241&view=rev Author: jeremydmiller Date: 2009-05-18 21:40:09 +0000 (Mon, 18 May 2009) Log Message: ----------- little helper thing for open generic type scanning Modified Paths: -------------- trunk/Source/StructureMap/Configuration/DSL/Registry.cs trunk/Source/StructureMap/Container.cs trunk/Source/StructureMap/Graph/AssemblyScanner.cs trunk/Source/StructureMap/Graph/ITypeScanner.cs trunk/Source/StructureMap/ObjectFactory.cs trunk/Source/StructureMap.Testing/Graph/DefaultConventionScanningTester.cs trunk/Source/StructureMap.Testing/Graph/TestExplicitArguments.cs Modified: trunk/Source/StructureMap/Configuration/DSL/Registry.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2009-04-20 01:47:17 UTC (rev 240) +++ trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2009-05-18 21:40:09 UTC (rev 241) @@ -371,5 +371,24 @@ } + /// <summary> + /// Syntactic Sugar for saying ForRequestedType().TheDefault.IsThis( @object ) + /// </summary> + /// <typeparam name="PLUGINTYPE"></typeparam> + /// <param name="object"></param> + public void Register<PLUGINTYPE>(PLUGINTYPE @object) + { + ForRequestedType<PLUGINTYPE>().TheDefault.IsThis(@object); + } + + /// <summary> + /// Syntactic Sugar for saying ForRequestedType().TheDefault.IsThis( instance ) + /// </summary> + /// <typeparam name="PLUGINTYPE"></typeparam> + /// <param name="instance"></param> + public void Register<PLUGINTYPE>(Instance instance) + { + ForRequestedType<PLUGINTYPE>().TheDefault.IsThis(instance); + } } } \ No newline at end of file Modified: trunk/Source/StructureMap/Container.cs =================================================================== --- trunk/Source/StructureMap/Container.cs 2009-04-20 01:47:17 UTC (rev 240) +++ trunk/Source/StructureMap/Container.cs 2009-05-18 21:40:09 UTC (rev 241) @@ -434,6 +434,15 @@ return new ExplicitArgsExpression(this).With(argName); } + public ExplicitArgsExpression With(Action<ExplicitArgsExpression> action) + { + var expression = new ExplicitArgsExpression(this); + action(expression); + + return expression; + } + + /// <summary> /// Use with caution! Does a full environment test of the configuration of this container. Will try to create every configured /// instance and afterward calls any methods marked with the [ValidationMethod] attribute Modified: trunk/Source/StructureMap/Graph/AssemblyScanner.cs =================================================================== --- trunk/Source/StructureMap/Graph/AssemblyScanner.cs 2009-04-20 01:47:17 UTC (rev 240) +++ trunk/Source/StructureMap/Graph/AssemblyScanner.cs 2009-05-18 21:40:09 UTC (rev 241) @@ -160,6 +160,14 @@ // ... Other methods #endregion + /// <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); } public class AssemblyScanner : IAssemblyScanner @@ -377,6 +385,11 @@ Exclude(type => type == typeof (T)); } + public void ConnectImplementationsToTypesClosing(Type openGenericType) + { + With(new GenericConnectionScanner(openGenericType)); + } + public void AssembliesFromPath(string path) { AssembliesFromPath(path, a => true); Modified: trunk/Source/StructureMap/Graph/ITypeScanner.cs =================================================================== --- trunk/Source/StructureMap/Graph/ITypeScanner.cs 2009-04-20 01:47:17 UTC (rev 240) +++ trunk/Source/StructureMap/Graph/ITypeScanner.cs 2009-05-18 21:40:09 UTC (rev 241) @@ -1,4 +1,5 @@ using System; +using StructureMap; namespace StructureMap.Graph { @@ -31,4 +32,28 @@ return Array.Find(interfaces, t => t.Name == interfaceName); } } + + public class GenericConnectionScanner : ITypeScanner + { + private readonly Type _openType; + + public GenericConnectionScanner(Type openType) + { + _openType = openType; + + if (!_openType.IsGeneric()) + { + throw new ApplicationException("This scanning convention can only be used with open generic types"); + } + } + + public void Process(Type type, PluginGraph graph) + { + Type interfaceType = type.FindInterfaceThatCloses(_openType); + if (interfaceType != null) + { + graph.AddType(interfaceType, type); + } + } + } } \ No newline at end of file Modified: trunk/Source/StructureMap/ObjectFactory.cs =================================================================== --- trunk/Source/StructureMap/ObjectFactory.cs 2009-04-20 01:47:17 UTC (rev 240) +++ trunk/Source/StructureMap/ObjectFactory.cs 2009-05-18 21:40:09 UTC (rev 241) @@ -467,5 +467,12 @@ return container.ForObject(subject); } + public static IContainer Container + { + get + { + return container; + } + } } } \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/Graph/DefaultConventionScanningTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Graph/DefaultConventionScanningTester.cs 2009-04-20 01:47:17 UTC (rev 240) +++ trunk/Source/StructureMap.Testing/Graph/DefaultConventionScanningTester.cs 2009-05-18 21:40:09 UTC (rev 241) @@ -5,7 +5,51 @@ namespace StructureMap.Testing.Graph { + [TestFixture] + public class GenericConnectionScannerTester + { + private Container container; + + [SetUp] + public void SetUp() + { + container = new Container(x => + { + x.Scan(o => + { + o.TheCallingAssembly(); + o.ConnectImplementationsToTypesClosing(typeof (IFinder<>)); + }); + }); + } + + [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 { [Test] Modified: trunk/Source/StructureMap.Testing/Graph/TestExplicitArguments.cs =================================================================== --- trunk/Source/StructureMap.Testing/Graph/TestExplicitArguments.cs 2009-04-20 01:47:17 UTC (rev 240) +++ trunk/Source/StructureMap.Testing/Graph/TestExplicitArguments.cs 2009-05-18 21:40:09 UTC (rev 241) @@ -440,6 +440,17 @@ } [Test] + public void can_build_a_concrete_class_with_constructor_args_that_is_not_previously_registered_2() + { + var container = new Container(); + + container.With(x => + { + x.With("name").EqualTo("Jeremy"); + }).GetInstance<ConcreteThatNeedsString>().Name.ShouldEqual("Jeremy"); + } + + [Test] public void can_build_a_concrete_type_from_explicit_args_passed_into_a_named_instance() { var container = new Container(x => This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2009-04-20 01:47:22
|
Revision: 240 http://structuremap.svn.sourceforge.net/structuremap/?rev=240&view=rev Author: jeremydmiller Date: 2009-04-20 01:47:17 +0000 (Mon, 20 Apr 2009) Log Message: ----------- The big, big lifecycle refactoring Modified Paths: -------------- trunk/Source/StructureMap/BuildSession.cs trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs trunk/Source/StructureMap/Configuration/FamilyParser.cs trunk/Source/StructureMap/Diagnostics/WhatDoIHaveWriter.cs trunk/Source/StructureMap/Graph/IPluginFamily.cs trunk/Source/StructureMap/Graph/PluginFamily.cs trunk/Source/StructureMap/IInstanceFactory.cs trunk/Source/StructureMap/InstanceFactory.cs trunk/Source/StructureMap/Pipeline/Lifecycle.cs trunk/Source/StructureMap/PipelineGraph.cs trunk/Source/StructureMap/PluginTypeConfiguration.cs trunk/Source/StructureMap/StructureMap.csproj trunk/Source/StructureMap/SystemRegistry.cs trunk/Source/StructureMap.DebuggerVisualizers/ContainerVisualizerObjectSource.cs trunk/Source/StructureMap.DebuggerVisualizers.Testing/VisualizerTests.cs trunk/Source/StructureMap.Testing/Attributes/PluginFamilyAttributeTester.cs trunk/Source/StructureMap.Testing/Bugs/SpecifyScopeInConfigureTester.cs trunk/Source/StructureMap.Testing/Configuration/DSL/CreatePluginFamilyTester.cs trunk/Source/StructureMap.Testing/Configuration/DSL/GenericFamilyExpressionTester.cs trunk/Source/StructureMap.Testing/Configuration/FamilyParserTester.cs trunk/Source/StructureMap.Testing/Configuration/NormalGraphBuilderTester.cs trunk/Source/StructureMap.Testing/Graph/DynamicInjectionTester.cs trunk/Source/StructureMap.Testing/Graph/InstanceFactoryTester.cs trunk/Source/StructureMap.Testing/Graph/PluginFamilyTester.cs trunk/Source/StructureMap.Testing/Graph/PluginGraphBuilderTester.cs trunk/Source/StructureMap.Testing/PerRequestInterceptorTester.cs trunk/Source/StructureMap.Testing/Pipeline/BuildStrategiesTester.cs trunk/Source/StructureMap.Testing/Pipeline/ObjectBuilderTester.cs trunk/Source/StructureMap.Testing/Pipeline/ProfileManagerTester.cs trunk/Source/StructureMap.Testing/Pipeline/ProfileTester.cs trunk/Source/StructureMap.Testing/Pipeline/StubBuildSession.cs trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj Added Paths: ----------- trunk/Source/StructureMap/Pipeline/HttpSessionLifecycle.cs trunk/Source/StructureMap/Pipeline/HybridSessionLifecycle.cs trunk/Source/StructureMap/Pipeline/UniquePerRequestLifecycle.cs trunk/Source/StructureMap.Testing/Pipeline/HybridBuildLifecycleTester.cs trunk/Source/StructureMap.Testing/Pipeline/ThreadLocalStorageLifecycleTester.cs Removed Paths: ------------- trunk/Source/StructureMap/Pipeline/BuildPolicy.cs trunk/Source/StructureMap/Pipeline/CacheInterceptor.cs trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs trunk/Source/StructureMap/Pipeline/HybridBuildPolicy.cs trunk/Source/StructureMap/Pipeline/IBuildInterceptor.cs trunk/Source/StructureMap/Pipeline/IBuildPolicy.cs trunk/Source/StructureMap/Pipeline/SingletonPolicy.cs trunk/Source/StructureMap/Pipeline/ThreadLocalStoragePolicy.cs trunk/Source/StructureMap/Pipeline/UniquePerRequestInterceptor.cs trunk/Source/StructureMap.Testing/Pipeline/HybridBuildPolicyTester.cs trunk/Source/StructureMap.Testing/Pipeline/ThreadLocalStoragePolicyTester.cs Modified: trunk/Source/StructureMap/BuildSession.cs =================================================================== --- trunk/Source/StructureMap/BuildSession.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap/BuildSession.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -11,14 +11,15 @@ private readonly BuildStack _buildStack = new BuildStack(); private readonly InstanceCache _cache = new InstanceCache(); private readonly Cache<Type, Func<object>> _defaults; - private readonly InterceptorLibrary _interceptorLibrary; private readonly PipelineGraph _pipelineGraph; + private readonly ObjectBuilder _builder; public BuildSession(PipelineGraph pipelineGraph, InterceptorLibrary interceptorLibrary) { _pipelineGraph = pipelineGraph; - _interceptorLibrary = interceptorLibrary; + _builder = new ObjectBuilder(_pipelineGraph, interceptorLibrary, new NulloObjectCache()); + _defaults = new Cache<Type, Func<object>>(t => { Instance instance = _pipelineGraph.GetDefault(t); @@ -28,9 +29,7 @@ throw new StructureMapException(202, t); } - object createdInstance = CreateInstance(t, instance); - - return () => createdInstance; + return () => CreateInstance(t, instance); }); } @@ -129,9 +128,14 @@ if (result == null) { - result = forType(pluginType).Build(this, instance); + result = _builder.Resolve(pluginType, instance, this); - _cache.Set(pluginType, instance, result); + // TODO: HACK ATTACK!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + var isUnique = forType(pluginType).Lifecycle is UniquePerRequestLifecycle; + if (!isUnique) + { + _cache.Set(pluginType, instance, result); + } } return result; @@ -161,13 +165,6 @@ return _defaults[pluginType](); } - [Obsolete("get this inlined")] - public virtual object ApplyInterception(Type pluginType, object actualValue) - { - if (actualValue == null) return null; - return _interceptorLibrary.FindInterceptor(actualValue.GetType()).Process(actualValue, this); - } - public virtual void RegisterDefault(Type pluginType, Func<object> creator) { _defaults[pluginType] = creator; Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -261,30 +261,18 @@ } /// <summary> - /// Registers an IBuildInterceptor for this Plugin Type that executes before - /// any object of this PluginType is created. IBuildInterceptor's can be + /// Registers an ILifecycle for this Plugin Type that executes before + /// any object of this PluginType is created. ILifecycle's can be /// used to create a custom scope /// </summary> - /// <param name="interceptor"></param> + /// <param name="lifecycle"></param> /// <returns></returns> - public CreatePluginFamilyExpression<PLUGINTYPE> InterceptConstructionWith(IBuildInterceptor interceptor) + public CreatePluginFamilyExpression<PLUGINTYPE> LifecycleIs(ILifecycle lifecycle) { - _alterations.Add(family => family.AddInterceptor(interceptor)); + _alterations.Add(family => family.SetScopeTo(lifecycle)); return this; } - /// <summary> - /// Registers an IBuildInterceptor for this Plugin Type that executes before - /// any object of this PluginType is created. IBuildInterceptor's can be - /// used to create a custom scope - /// </summary> - /// <param name="interceptor"></param> - /// <returns></returns> - public CreatePluginFamilyExpression<PLUGINTYPE> BuildPolicyIs(IBuildInterceptor interceptor) - { - _alterations.Add(family => family.AddInterceptor(interceptor)); - return this; - } /// <summary> /// Largely deprecated and unnecessary with the ability to add Xml configuration files @@ -314,7 +302,7 @@ /// <returns></returns> public CreatePluginFamilyExpression<PLUGINTYPE> AlwaysUnique() { - return InterceptConstructionWith(new UniquePerRequestInterceptor()); + return this.LifecycleIs(new UniquePerRequestLifecycle()); } } } \ No newline at end of file Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -144,11 +144,11 @@ /// any object of this PluginType is created. IBuildInterceptor's can be /// used to create a custom scope /// </summary> - /// <param name="interceptor"></param> + /// <param name="lifecycle"></param> /// <returns></returns> - public GenericFamilyExpression InterceptConstructionWith(IBuildInterceptor interceptor) + public GenericFamilyExpression LifecycleIs(ILifecycle lifecycle) { - return alterAndContinue(family => family.AddInterceptor(interceptor)); + return alterAndContinue(family => family.SetScopeTo(lifecycle)); } /// <summary> Modified: trunk/Source/StructureMap/Configuration/FamilyParser.cs =================================================================== --- trunk/Source/StructureMap/Configuration/FamilyParser.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap/Configuration/FamilyParser.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -127,10 +127,12 @@ { var interceptorMemento = new XmlAttributeInstanceMemento(element); string context = contextBase + element.OuterXml; - _builder.WithSystemObject<IBuildInterceptor>( + + + _builder.WithSystemObject<ILifecycle>( interceptorMemento, context, - interceptor => family.AddInterceptor(interceptor)); + lifecycle => family.SetScopeTo(lifecycle)); }); } } Modified: trunk/Source/StructureMap/Diagnostics/WhatDoIHaveWriter.cs =================================================================== --- trunk/Source/StructureMap/Diagnostics/WhatDoIHaveWriter.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap/Diagnostics/WhatDoIHaveWriter.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -79,7 +79,14 @@ _writer.AddText(contents); - _writer.AddContent("Scoped as: " + pluginType.Policy); + if (pluginType.Lifecycle != null) + { + _writer.AddContent("Scoped as: " + pluginType.Lifecycle.GetType().Name); + } + else + { + _writer.AddContent("Scoped as: PerRequest"); + } foreach (IInstance instance in pluginType.Instances) { Modified: trunk/Source/StructureMap/Graph/IPluginFamily.cs =================================================================== --- trunk/Source/StructureMap/Graph/IPluginFamily.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap/Graph/IPluginFamily.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -19,6 +19,8 @@ void AddMementoSource(MementoSource source); void SetScopeTo(InstanceScope scope); - void AddInterceptor(IBuildInterceptor interceptor); + void SetScopeTo(ILifecycle lifecycle); + + ILifecycle Lifecycle {get; } } } \ No newline at end of file Modified: trunk/Source/StructureMap/Graph/PluginFamily.cs =================================================================== --- trunk/Source/StructureMap/Graph/PluginFamily.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap/Graph/PluginFamily.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -17,7 +17,7 @@ private readonly List<InstanceMemento> _mementoList = new List<InstanceMemento>(); private readonly Cache<string, Plugin> _pluggedTypes = new Cache<string, Plugin>(); private readonly Type _pluginType; - private IBuildPolicy _buildPolicy = new BuildPolicy(); + private ILifecycle _lifecycle = null; private string _defaultKey = string.Empty; private PluginGraph _parent; @@ -43,7 +43,16 @@ } } + public void SetScopeTo(ILifecycle lifecycle) + { + _lifecycle = lifecycle; + } + public ILifecycle Lifecycle + { + get { return _lifecycle; } + } + public PluginGraph Parent { get { return _parent; } @@ -59,40 +68,9 @@ public void SetScopeTo(InstanceScope scope) { - switch (scope) - { - case InstanceScope.Singleton: - AddInterceptor(new SingletonPolicy()); - break; - - case InstanceScope.HttpContext: - AddInterceptor(new HttpContextBuildPolicy()); - break; - - case InstanceScope.ThreadLocal: - AddInterceptor(new ThreadLocalStoragePolicy()); - break; - - case InstanceScope.Hybrid: - AddInterceptor(new HybridBuildPolicy()); - break; - - case InstanceScope.HttpSession: - AddInterceptor(new HybridSessionBuildPolicy()); - break; - - case InstanceScope.HybridHttpSession: - AddInterceptor(new HybridSessionBuildPolicy()); - break; - } + _lifecycle = Lifecycles.GetLifecycle(scope); } - [Obsolete("Kill!")] - public void AddInterceptor(IBuildInterceptor interceptor) - { - interceptor.InnerPolicy = _buildPolicy; - _buildPolicy = interceptor; - } #endregion @@ -292,7 +270,7 @@ Type templatedType = _pluginType.MakeGenericType(templateTypes); var templatedFamily = new PluginFamily(templatedType, Parent); templatedFamily.DefaultInstanceKey = DefaultInstanceKey; - templatedFamily.Policy = Policy.Clone(); + templatedFamily._lifecycle = _lifecycle; // TODO -- Got a big problem here. Intances need to be copied over @@ -330,7 +308,7 @@ { Default = GetDefaultInstance(), PluginType = PluginType, - Policy = _buildPolicy, + Lifecycle = _lifecycle, Instances = Instances }; } @@ -342,11 +320,7 @@ get { return _pluginType.IsGenericTypeDefinition || _pluginType.ContainsGenericParameters; } } - public IBuildPolicy Policy - { - get { return _buildPolicy; } - set { _buildPolicy = value; } - } + public int PluginCount { Modified: trunk/Source/StructureMap/IInstanceFactory.cs =================================================================== --- trunk/Source/StructureMap/IInstanceFactory.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap/IInstanceFactory.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -13,9 +13,6 @@ { Type PluginType { get; } IEnumerable<IInstance> Instances { get; } - - [Obsolete("Kill!!!!")] - IBuildPolicy Policy { get; } Instance MissingInstance { get; set; } Instance[] AllInstances @@ -26,12 +23,6 @@ void AddInstance(Instance instance); Instance AddType<T>(); - [Obsolete("Return the list of Instances instead")] - IList GetAllInstances(BuildSession session); - - [Obsolete("Kill!!!!")] - object Build(BuildSession session, Instance instance); - Instance FindInstance(string name); void ImportFrom(PluginFamily family); Modified: trunk/Source/StructureMap/InstanceFactory.cs =================================================================== --- trunk/Source/StructureMap/InstanceFactory.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap/InstanceFactory.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -16,7 +16,7 @@ new Cache<string, Instance>(delegate { return null; }); private readonly Type _pluginType; - private IBuildPolicy _policy = new BuildPolicy(); + private ILifecycle _lifecycle; #region constructor functions @@ -38,7 +38,7 @@ try { - _policy = family.Policy; + _lifecycle = family.Lifecycle; _pluginType = family.PluginType; MissingInstance = family.MissingInstance; @@ -95,14 +95,7 @@ } } - [Obsolete("Kill!!!!")] - public IBuildPolicy Policy - { - get { return _policy; } - set { _policy = value; } - } - public void AddInstance(Instance instance) { _instances[instance.Name] = instance; @@ -120,25 +113,6 @@ return instance; } - public IList GetAllInstances(BuildSession session) - { - IList list = new ArrayList(); - - _instances.Each(instance => - { - object builtObject = Build(session, instance); - list.Add(builtObject); - }); - - return list; - } - - [Obsolete("Kill!!!!")] - public object Build(BuildSession session, Instance instance) - { - return _policy.Build(session, PluginType, instance); - } - public Instance FindInstance(string name) { return _instances[name] ?? MissingInstance; @@ -146,10 +120,14 @@ public void ImportFrom(PluginFamily family) { - if (!_policy.GetType().Equals(family.Policy.GetType())) + if (_lifecycle == null) { + _lifecycle = family.Lifecycle; + } + else if (!_lifecycle.GetType().Equals(family.Lifecycle.GetType())) + { // TODO: Might need to clear out the existing policy when it's ejected - _policy = family.Policy; + _lifecycle = family.Lifecycle; } family.EachInstance(instance => _instances.Fill(instance.Name, instance)); @@ -162,13 +140,14 @@ public void EjectAllInstances() { - _policy.EjectAll(); + if (_lifecycle != null) _lifecycle.EjectAll(); _instances.Clear(); } public ILifecycle Lifecycle { - get { throw new NotImplementedException(); } + get { return _lifecycle; } + set { _lifecycle = value; } } #endregion Deleted: trunk/Source/StructureMap/Pipeline/BuildPolicy.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/BuildPolicy.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap/Pipeline/BuildPolicy.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -1,65 +0,0 @@ -using System; -using StructureMap.Attributes; - -namespace StructureMap.Pipeline -{ - [Obsolete("Kill!")] - public sealed class BuildPolicy : IBuildPolicy - { - #region IBuildPolicy Members - - public object Build(BuildSession buildSession, Type pluginType, Instance instance) - { - if (buildSession == null) - { - throw new ArgumentNullException("buildSession"); - } - - object builtObject = instance.Build(pluginType, buildSession); - - try - { - return buildSession.ApplyInterception(pluginType, builtObject); - } - catch (Exception e) - { - throw new StructureMapException(308, e, instance.Name, builtObject.GetType()); - } - } - - public IBuildPolicy Clone() - { - return this; - } - - public void EjectAll() - { - // no-op. Unlike other Container's, StructureMap doesn't hang on to - // objects it created as "Transients" - } - - #endregion - - public bool Equals(BuildPolicy obj) - { - return !ReferenceEquals(null, obj); - } - - public override bool Equals(object obj) - { - if (ReferenceEquals(null, obj)) return false; - if (ReferenceEquals(this, obj)) return true; - return obj is BuildPolicy; - } - - public override int GetHashCode() - { - return 0; - } - - public override string ToString() - { - return InstanceScope.PerRequest.ToString(); - } - } -} \ No newline at end of file Deleted: trunk/Source/StructureMap/Pipeline/CacheInterceptor.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/CacheInterceptor.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap/Pipeline/CacheInterceptor.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -1,86 +0,0 @@ -using System; -using StructureMap.Util; - -namespace StructureMap.Pipeline -{ - - - - [Obsolete("Kill! in favor of MainObjectCache")] - public class ObjectCache : Cache<InstanceKey, object> - { - public ObjectCache(IBuildPolicy innerPolicy) : base(key => innerPolicy.Build(key.Session, key.PluginType, key.Instance)) - { - } - - public void DisposeAndClear() - { - Each(o => - { - IDisposable disposable = o as IDisposable; - if (disposable != null) - { - try - { - disposable.Dispose(); - } - catch (Exception) { } - } - }); - Clear(); - } - } - - public abstract class CacheInterceptor : IBuildInterceptor - { - private IBuildPolicy _innerPolicy = new BuildPolicy(); - - #region IBuildInterceptor Members - - public IBuildPolicy InnerPolicy - { - get { return _innerPolicy; } - set { _innerPolicy = value; } - } - - protected ObjectCache buildNewCache() - { - return new ObjectCache(_innerPolicy); - } - - protected abstract ObjectCache findCache(); - - public object Build(BuildSession buildSession, Type pluginType, Instance instance) - { - var key = new InstanceKey{Instance = instance, PluginType = pluginType, Session = buildSession}; - return findCache()[key]; - } - - public IBuildPolicy Clone() - { - CacheInterceptor clonedCache = clone(); - clonedCache.InnerPolicy = _innerPolicy.Clone(); - - return clonedCache; - } - - public void EjectAll() - { - ejectAll(); - _innerPolicy.EjectAll(); - } - - protected virtual void ejectAll() - { - } - - #endregion - - protected abstract CacheInterceptor clone(); - - public override string ToString() - { - return GetType().FullName + " / " + _innerPolicy; - } - } -} \ No newline at end of file Deleted: trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -1,59 +0,0 @@ -using System; -using System.Collections; -using System.Web; -using StructureMap.Attributes; - -namespace StructureMap.Pipeline -{ - public class HttpContextBuildPolicy : CacheInterceptor - { - public static readonly string ITEM_NAME = "STRUCTUREMAP-INSTANCES"; - - - public static bool HasContext() - { - return HttpContext.Current != null; - } - - public static void DisposeAndClearAll() - { - new HttpContextBuildPolicy().findCache().DisposeAndClear(); - } - - protected override ObjectCache findCache() - { - IDictionary items = findHttpDictionary(); - - if (!items.Contains(ITEM_NAME)) - { - lock (items.SyncRoot) - { - if (!items.Contains(ITEM_NAME)) - { - ObjectCache cache = buildNewCache(); - items.Add(ITEM_NAME, cache); - - return cache; - } - } - } - - return (ObjectCache) items[ITEM_NAME]; - } - - protected virtual IDictionary findHttpDictionary() - { - return HttpContext.Current.Items; - } - - protected override CacheInterceptor clone() - { - return this; - } - - public override string ToString() - { - return InstanceScope.HttpContext.ToString(); - } - } -} Added: trunk/Source/StructureMap/Pipeline/HttpSessionLifecycle.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/HttpSessionLifecycle.cs (rev 0) +++ trunk/Source/StructureMap/Pipeline/HttpSessionLifecycle.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -0,0 +1,13 @@ +using System.Collections; +using System.Web; + +namespace StructureMap.Pipeline +{ + public class HttpSessionLifecycle : HttpContextLifecycle + { + protected override IDictionary findHttpDictionary() + { + return new SessionWrapper(HttpContext.Current.Session); + } + } +} \ No newline at end of file Deleted: trunk/Source/StructureMap/Pipeline/HybridBuildPolicy.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/HybridBuildPolicy.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap/Pipeline/HybridBuildPolicy.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -1,74 +0,0 @@ -using System; -using StructureMap.Attributes; - -namespace StructureMap.Pipeline -{ - public abstract class HttpBuildPolicyBase<HTTP, NONHTTP> : IBuildInterceptor - where HTTP : IBuildInterceptor, new() - where NONHTTP : IBuildInterceptor, new() - { - private readonly IBuildInterceptor _http; - private readonly IBuildInterceptor _nonHttp; - - public HttpBuildPolicyBase() - { - _http = new HTTP(); - _nonHttp = new NONHTTP(); - } - - - private IBuildPolicy _innerPolicy; - - - private IBuildInterceptor interceptor - { - get - { - return HttpContextBuildPolicy.HasContext() - ? _http - : _nonHttp; - } - } - - public IBuildPolicy InnerPolicy - { - get { return _innerPolicy; } - set - { - _http.InnerPolicy = value; - _nonHttp.InnerPolicy = value; - _innerPolicy = value; - } - } - - public object Build(BuildSession buildSession, Type pluginType, Instance instance) - { - return interceptor.Build(buildSession, pluginType, instance); - } - - public abstract IBuildPolicy Clone(); - public void EjectAll() - { - _http.EjectAll(); - _nonHttp.EjectAll(); - } - } - - - - - - public class HybridBuildPolicy : HttpBuildPolicyBase<HttpContextBuildPolicy, ThreadLocalStoragePolicy> - { - public override IBuildPolicy Clone() - { - return new HybridBuildPolicy(){InnerPolicy = InnerPolicy.Clone()}; - } - - public override string ToString() - { - return InstanceScope.Hybrid.ToString(); - } - } - -} \ No newline at end of file Added: trunk/Source/StructureMap/Pipeline/HybridSessionLifecycle.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/HybridSessionLifecycle.cs (rev 0) +++ trunk/Source/StructureMap/Pipeline/HybridSessionLifecycle.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -0,0 +1,7 @@ +namespace StructureMap.Pipeline +{ + public class HybridSessionLifecycle : HttpLifecycleBase<HttpSessionLifecycle, ThreadLocalStorageLifecycle> + { + + } +} \ No newline at end of file Deleted: trunk/Source/StructureMap/Pipeline/IBuildInterceptor.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/IBuildInterceptor.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap/Pipeline/IBuildInterceptor.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -1,10 +0,0 @@ -namespace StructureMap.Pipeline -{ - /// <summary> - /// Plugin interface to create custom build or lifecycle policies for a Plugin Type - /// </summary> - public interface IBuildInterceptor : IBuildPolicy - { - IBuildPolicy InnerPolicy { get; set; } - } -} \ No newline at end of file Deleted: trunk/Source/StructureMap/Pipeline/IBuildPolicy.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/IBuildPolicy.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap/Pipeline/IBuildPolicy.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -1,15 +0,0 @@ -using System; - -namespace StructureMap.Pipeline -{ - /// <summary> - /// An object that specifies a "Policy" about how Instance's are invoked. - /// </summary> - [Obsolete("Kill!")] - public interface IBuildPolicy - { - object Build(BuildSession buildSession, Type pluginType, Instance instance); - IBuildPolicy Clone(); - void EjectAll(); - } -} \ No newline at end of file Modified: trunk/Source/StructureMap/Pipeline/Lifecycle.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/Lifecycle.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap/Pipeline/Lifecycle.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -9,6 +9,12 @@ public interface IObjectCache { object Locker { get; } + + int Count + { + get; + } + object Get(Type pluginType, Instance instance); void Set(Type pluginType, Instance instance, object value); void DisposeAndClear(); @@ -21,6 +27,11 @@ get { return new object(); } } + public int Count + { + get { return 0; } + } + public object Get(Type pluginType, Instance instance) { return null; @@ -47,6 +58,11 @@ get { return _locker; } } + public int Count + { + get { return _objects.Count; } + } + public object Get(Type pluginType, Instance instance) { var key = new InstanceKey(instance, pluginType); @@ -95,6 +111,9 @@ { switch (scope) { + case InstanceScope.PerRequest: + return null; + case InstanceScope.Singleton: return new SingletonLifecycle(); @@ -133,7 +152,7 @@ public object Resolve(Type pluginType, Instance instance, BuildSession session) { - var cache = FindCache(instance, session); + var cache = FindCache(pluginType, instance, session); lock (cache.Locker) { var returnValue = cache.Get(pluginType, instance); @@ -171,9 +190,12 @@ } - public IObjectCache FindCache(Instance instance, BuildSession session) + public IObjectCache FindCache(Type pluginType, Instance instance, BuildSession session) { - throw new NotImplementedException(); + var lifecycle = _pipeline.ForType(pluginType).Lifecycle; + return lifecycle == null + ? _defaultCache + : lifecycle.FindCache(); } } } \ No newline at end of file Deleted: trunk/Source/StructureMap/Pipeline/SingletonPolicy.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/SingletonPolicy.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap/Pipeline/SingletonPolicy.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -1,54 +0,0 @@ -using System; -using StructureMap.Attributes; - -namespace StructureMap.Pipeline -{ - [Obsolete("Kill!")] - public class SingletonPolicy : CacheInterceptor - { - private readonly object _locker = new object(); - private ObjectCache _cache; - - protected override ObjectCache findCache() - { - if (_cache == null) - { - lock (_locker) - { - if (_cache == null) - { - _cache = buildNewCache(); - } - } - } - - return _cache; - } - - public ObjectCache Cache - { - get - { - return findCache(); - } - } - - protected override void ejectAll() - { - lock (_locker) - { - _cache.DisposeAndClear(); - } - } - - protected override CacheInterceptor clone() - { - return new SingletonPolicy(); - } - - public override string ToString() - { - return InstanceScope.Singleton.ToString(); - } - } -} \ No newline at end of file Deleted: trunk/Source/StructureMap/Pipeline/ThreadLocalStoragePolicy.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/ThreadLocalStoragePolicy.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap/Pipeline/ThreadLocalStoragePolicy.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -1,46 +0,0 @@ -using System; -using StructureMap.Attributes; - -namespace StructureMap.Pipeline -{ - public class ThreadLocalStoragePolicy : CacheInterceptor - { - [ThreadStatic] private static ObjectCache _cache; - private readonly object _locker = new object(); - - public static void DisposeAndClearAll() - { - _cache.DisposeAndClear(); - } - - private void guaranteeHashExists() - { - if (_cache == null) - { - lock (_locker) - { - if (_cache == null) - { - _cache = buildNewCache(); - } - } - } - } - - protected override ObjectCache findCache() - { - guaranteeHashExists(); - return _cache; - } - - protected override CacheInterceptor clone() - { - return this; - } - - public override string ToString() - { - return InstanceScope.Hybrid.ToString(); - } - } -} \ No newline at end of file Deleted: trunk/Source/StructureMap/Pipeline/UniquePerRequestInterceptor.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/UniquePerRequestInterceptor.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap/Pipeline/UniquePerRequestInterceptor.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -1,46 +0,0 @@ -using System; - -namespace StructureMap.Pipeline -{ - /// <summary> - /// Makes sure that every request for this object returns a unique object - /// </summary> - public class UniquePerRequestInterceptor : IBuildInterceptor - { - - #region IBuildInterceptor Members - - private IBuildPolicy _innerPolicy = new BuildPolicy(); - - public IBuildPolicy InnerPolicy - { - get { return _innerPolicy; } - set { _innerPolicy = value; } - } - - #endregion - - #region IBuildPolicy Members - - public object Build(BuildSession buildSession, Type pluginType, Instance instance) - { - //insert a default object creator - buildSession.RegisterDefault(pluginType, () => InnerPolicy.Build(buildSession, pluginType, instance)); - - //build this object for the first time - return buildSession.CreateInstance(pluginType); - } - - public IBuildPolicy Clone() - { - return new UniquePerRequestInterceptor(); - } - - public void EjectAll() - { - InnerPolicy.EjectAll(); - } - - #endregion - } -} Copied: trunk/Source/StructureMap/Pipeline/UniquePerRequestLifecycle.cs (from rev 234, trunk/Source/StructureMap/Pipeline/UniquePerRequestInterceptor.cs) =================================================================== --- trunk/Source/StructureMap/Pipeline/UniquePerRequestLifecycle.cs (rev 0) +++ trunk/Source/StructureMap/Pipeline/UniquePerRequestLifecycle.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -0,0 +1,55 @@ +using System; + +namespace StructureMap.Pipeline +{ + /// <summary> + /// Makes sure that every request for this object returns a unique object + /// </summary> + public class UniquePerRequestLifecycle : ILifecycle + { + public void EjectAll() + { + + } + + public IObjectCache FindCache() + { + return new NulloObjectCache(); + } + + //#region IBuildInterceptor Members + + //private IBuildPolicy _innerPolicy = new BuildPolicy(); + + //public IBuildPolicy InnerPolicy + //{ + // get { return _innerPolicy; } + // set { _innerPolicy = value; } + //} + + //#endregion + + //#region IBuildPolicy Members + + //public object Build(BuildSession buildSession, Type pluginType, Instance instance) + //{ + // //insert a default object creator + // buildSession.RegisterDefault(pluginType, () => InnerPolicy.Build(buildSession, pluginType, instance)); + + // //build this object for the first time + // return buildSession.CreateInstance(pluginType); + //} + + //public IBuildPolicy Clone() + //{ + // return new UniquePerRequestInterceptor(); + //} + + //public void EjectAll() + //{ + // InnerPolicy.EjectAll(); + //} + + //#endregion + } +} Modified: trunk/Source/StructureMap/PipelineGraph.cs =================================================================== --- trunk/Source/StructureMap/PipelineGraph.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap/PipelineGraph.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -75,7 +75,7 @@ { Default = _profileManager.GetDefault(factory.PluginType), PluginType = factory.PluginType, - Policy = factory.Policy, + Lifecycle = factory.Lifecycle, Instances = factory.Instances }; } Modified: trunk/Source/StructureMap/PluginTypeConfiguration.cs =================================================================== --- trunk/Source/StructureMap/PluginTypeConfiguration.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap/PluginTypeConfiguration.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -20,7 +20,7 @@ /// <summary> /// The build "policy" for this PluginType. Used by the WhatDoIHave() diagnostics methods /// </summary> - public IBuildPolicy Policy { get; set; } + public ILifecycle Lifecycle { get; set; } /// <summary> /// All of the <see cref="StructureMap.Pipeline.IInstance">IInstance</see>'s registered Modified: trunk/Source/StructureMap/StructureMap.csproj =================================================================== --- trunk/Source/StructureMap/StructureMap.csproj 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap/StructureMap.csproj 2009-04-20 01:47:17 UTC (rev 240) @@ -157,15 +157,10 @@ <Compile Include="InstanceFamily.cs" /> <Compile Include="Interceptors\MatchedTypeInterceptor.cs" /> <Compile Include="PipelineGraph.cs" /> - <Compile Include="Pipeline\BuildPolicy.cs" /> - <Compile Include="Pipeline\CacheInterceptor.cs" /> <Compile Include="Pipeline\ConfiguredInstance.cs" /> <Compile Include="Pipeline\ConfiguredInstance.Expressions.cs" /> <Compile Include="Pipeline\ConstructorInstance.cs" /> <Compile Include="Pipeline\DefaultInstance.cs" /> - <Compile Include="Pipeline\HybridBuildPolicy.cs" /> - <Compile Include="Pipeline\IBuildInterceptor.cs" /> - <Compile Include="Pipeline\IBuildPolicy.cs" /> <Compile Include="Pipeline\IConfiguredInstance.cs" /> <Compile Include="Pipeline\ILocationPolicy.cs" /> <Compile Include="Pipeline\Instance.cs" /> @@ -175,8 +170,6 @@ <Compile Include="Pipeline\ProfileManager.cs" /> <Compile Include="Pipeline\PrototypeInstance.cs" /> <Compile Include="Pipeline\ReferencedInstance.cs" /> - <Compile Include="Pipeline\SingletonPolicy.cs" /> - <Compile Include="Pipeline\ThreadLocalStoragePolicy.cs" /> <Compile Include="Pipeline\UserControlInstance.cs" /> <Compile Include="Properties\AssemblyInfo.cs"> <SubType>Code</SubType> @@ -409,12 +402,13 @@ <Compile Include="Pipeline\ConditionalInstance.cs" /> <Compile Include="Pipeline\HttpContextLifecycle.cs" /> <Compile Include="Pipeline\HttpLifecycleBase.cs" /> - <Compile Include="Pipeline\HttpSessionBuildPolicy.cs" /> + <Compile Include="Pipeline\HttpSessionLifecycle.cs" /> + <Compile Include="Pipeline\HybridSessionLifecycle.cs" /> <Compile Include="Pipeline\Lifecycle.cs" /> <Compile Include="Pipeline\SessionWrapper.cs" /> <Compile Include="Pipeline\SingletonLifecycle.cs" /> <Compile Include="Pipeline\ThreadLocalStorageLifecycle.cs" /> - <Compile Include="Pipeline\UniquePerRequestInterceptor.cs" /> + <Compile Include="Pipeline\UniquePerRequestLifecycle.cs" /> <Compile Include="TypeExtensions.cs" /> <Compile Include="IBootstrapper.cs" /> <Compile Include="InitializationExpression.cs" /> @@ -422,7 +416,6 @@ <Compile Include="Pipeline\BuildFrame.cs" /> <Compile Include="Pipeline\BuildStack.cs" /> <Compile Include="Pipeline\ConfiguredInstanceBase.cs" /> - <Compile Include="Pipeline\HttpContextBuildPolicy.cs" /> <Compile Include="Pipeline\InstanceKey.cs" /> <Compile Include="Pipeline\IStructuredInstance.cs" /> <Compile Include="Pipeline\PropertyExpression.cs" /> Modified: trunk/Source/StructureMap/SystemRegistry.cs =================================================================== --- trunk/Source/StructureMap/SystemRegistry.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap/SystemRegistry.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -9,7 +9,7 @@ { public SystemRegistry() { - addExpression(graph => graph.AddType(typeof(MementoSource), typeof(XmlFileMementoSource), "XmlFile")); + addExpression(graph => graph.AddType(typeof (MementoSource), typeof (XmlFileMementoSource), "XmlFile")); ForRequestedType<MementoSource>().TheDefaultIsConcreteType<MemoryMementoSource>(); AddMementoSourceType<DirectoryXmlMementoSource>("DirectoryXml"); @@ -19,23 +19,23 @@ AddMementoSourceType<XmlAttributeFileMementoSource>("XmlAttributeFile"); AddMementoSourceType<XmlFileMementoSource>("XmlFile"); + AddLifecycleType<SingletonLifecycle>(InstanceScope.Singleton); + AddLifecycleType<HttpContextLifecycle>(InstanceScope.HttpContext); + AddLifecycleType<HttpSessionLifecycle>(InstanceScope.HttpSession); + AddLifecycleType<HybridLifecycle>(InstanceScope.Hybrid); + AddLifecycleType<HybridSessionLifecycle>(InstanceScope.HybridHttpSession); + AddLifecycleType<ThreadLocalStorageLifecycle>(InstanceScope.ThreadLocal); + } - AddInterceptorType<SingletonPolicy>(InstanceScope.Singleton); - AddInterceptorType<ThreadLocalStoragePolicy>(InstanceScope.ThreadLocal); - AddInterceptorType<HttpContextBuildPolicy>(InstanceScope.HttpContext); - AddInterceptorType<HttpSessionBuildPolicy>(InstanceScope.HttpSession); - AddInterceptorType<HybridBuildPolicy>(InstanceScope.Hybrid); + private void AddLifecycleType<T>(InstanceScope scope) where T : ILifecycle + { + addExpression(graph => graph.AddType(typeof(ILifecycle), typeof(T), scope.ToString())); } private void AddMementoSourceType<T>(string name) { - addExpression(graph => graph.AddType(typeof(MementoSource), typeof(T), name)); + addExpression(graph => graph.AddType(typeof (MementoSource), typeof (T), name)); } - - private void AddInterceptorType<T>(InstanceScope scope) - { - addExpression(graph => graph.AddType(typeof(IBuildInterceptor), typeof(T), scope.ToString())); - } } } \ No newline at end of file Modified: trunk/Source/StructureMap.DebuggerVisualizers/ContainerVisualizerObjectSource.cs =================================================================== --- trunk/Source/StructureMap.DebuggerVisualizers/ContainerVisualizerObjectSource.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap.DebuggerVisualizers/ContainerVisualizerObjectSource.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -37,7 +37,7 @@ instances.Add(buildInstanceDetail(instance)); } - var pluginTypeDetail = new PluginTypeDetail(pluginType.PluginType, pluginType.Policy.GetType(), instances.ToArray()); + var pluginTypeDetail = new PluginTypeDetail(pluginType.PluginType, pluginType.Lifecycle.GetType(), instances.ToArray()); pluginTypeDetails.Add(pluginTypeDetail); } Modified: trunk/Source/StructureMap.DebuggerVisualizers.Testing/VisualizerTests.cs =================================================================== --- trunk/Source/StructureMap.DebuggerVisualizers.Testing/VisualizerTests.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap.DebuggerVisualizers.Testing/VisualizerTests.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -12,7 +12,7 @@ [Test] public void can_serialize_container_details() { - var pluginTypeDetails = new[]{ new PluginTypeDetail(typeof(string), typeof(BuildPolicy), new[]{ new InstanceDetail("First", "First Instance", typeof(string)), }) }; + var pluginTypeDetails = new[]{ new PluginTypeDetail(typeof(string), typeof(object), new[]{ new InstanceDetail("First", "First Instance", typeof(string)), }) }; var wrapper = new ContainerDetail(new[]{"config"}, pluginTypeDetails); var binaryFormatter = new BinaryFormatter(); Stream stream = new MemoryStream(); Modified: trunk/Source/StructureMap.Testing/Attributes/PluginFamilyAttributeTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Attributes/PluginFamilyAttributeTester.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap.Testing/Attributes/PluginFamilyAttributeTester.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -19,7 +19,7 @@ var family = new PluginFamily(typeof (TypeThatDoesNotHaveCustomMementoSource)); att.Configure(family); - Assert.IsInstanceOfType(interceptorType, family.Policy); + Assert.IsInstanceOfType(interceptorType, family.Lifecycle); } [PluginFamily] @@ -120,10 +120,10 @@ [Test] public void ScopeToInterceptorTypes() { - assertScopeLeadsToInterceptor(InstanceScope.HttpContext, typeof (HttpContextBuildPolicy)); - assertScopeLeadsToInterceptor(InstanceScope.Hybrid, typeof (HybridBuildPolicy)); - assertScopeLeadsToInterceptor(InstanceScope.Singleton, typeof (SingletonPolicy)); - assertScopeLeadsToInterceptor(InstanceScope.ThreadLocal, typeof (ThreadLocalStoragePolicy)); + assertScopeLeadsToInterceptor(InstanceScope.HttpContext, typeof (HttpContextLifecycle)); + assertScopeLeadsToInterceptor(InstanceScope.Hybrid, typeof (HybridLifecycle)); + assertScopeLeadsToInterceptor(InstanceScope.Singleton, typeof (SingletonLifecycle)); + assertScopeLeadsToInterceptor(InstanceScope.ThreadLocal, typeof (ThreadLocalStorageLifecycle)); } [Test] Modified: trunk/Source/StructureMap.Testing/Bugs/SpecifyScopeInConfigureTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Bugs/SpecifyScopeInConfigureTester.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap.Testing/Bugs/SpecifyScopeInConfigureTester.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -1,25 +1,18 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using NUnit.Framework; +using NUnit.Framework; using StructureMap.Attributes; using StructureMap.Testing.Widget3; namespace StructureMap.Testing.Bugs { - [TestFixture] - public class SpecifyScopeInConfigureTester + [TestFixture] public class SpecifyScopeInConfigureTester { - [Test] - public void specify_the_scope_in_a_Configure_if_it_is_not_already_set() + [Test] public void specify_the_scope_in_a_Configure_if_it_is_not_already_set() { var container = new Container(x => { }); container.Configure(x => { x.ForRequestedType<IGateway>().CacheBy(InstanceScope.Singleton) .TheDefaultIsConcreteType<DefaultGateway>(); - }); var gateway1 = container.GetInstance<IGateway>(); @@ -30,4 +23,4 @@ gateway1.ShouldBeTheSameAs(gateway3); } } -} +} \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/Configuration/DSL/CreatePluginFamilyTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Configuration/DSL/CreatePluginFamilyTester.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap.Testing/Configuration/DSL/CreatePluginFamilyTester.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -110,7 +110,8 @@ PluginGraph pluginGraph = registry.Build(); PluginFamily family = pluginGraph.FindFamily(typeof (IGateway)); - Assert.IsInstanceOfType(typeof (ThreadLocalStoragePolicy), family.Policy); + + family.Lifecycle.ShouldBeOfType<ThreadLocalStorageLifecycle>(); } @@ -136,7 +137,7 @@ PluginGraph pluginGraph = registry.Build(); PluginFamily family = pluginGraph.FindFamily(typeof (IGateway)); - Assert.IsInstanceOfType(typeof (BuildPolicy), family.Policy); + family.Lifecycle.ShouldBeNull(); } [Test] @@ -149,7 +150,7 @@ PluginGraph pluginGraph = registry.Build(); PluginFamily family = pluginGraph.FindFamily(typeof (IGateway)); - Assert.IsInstanceOfType(typeof (SingletonPolicy), family.Policy); + family.Lifecycle.ShouldBeOfType<SingletonLifecycle>(); } [Test] @@ -198,14 +199,14 @@ [Test] public void PutAnInterceptorIntoTheInterceptionChainOfAPluginFamilyInTheDSL() { - var factoryInterceptor = new StubbedInstanceFactoryInterceptor(); + var lifecycle = new StubbedLifecycle(); var registry = new Registry(); - registry.BuildInstancesOf<IGateway>().InterceptConstructionWith(factoryInterceptor); + registry.BuildInstancesOf<IGateway>().LifecycleIs(lifecycle); PluginGraph pluginGraph = registry.Build(); - Assert.AreSame(pluginGraph.FindFamily(typeof (IGateway)).Policy, factoryInterceptor); + pluginGraph.FindFamily(typeof (IGateway)).Lifecycle.ShouldBeTheSameAs(lifecycle); } [Test] @@ -270,31 +271,16 @@ } } - public class StubbedInstanceFactoryInterceptor : IBuildInterceptor + public class StubbedLifecycle : ILifecycle { - #region IBuildInterceptor Members - - public IBuildPolicy InnerPolicy + public void EjectAll() { - get { throw new NotImplementedException(); } - set { } - } - - public object Build(BuildSession buildSession, Type pluginType, Instance instance) - { throw new NotImplementedException(); } - public IBuildPolicy Clone() + public IObjectCache FindCache() { throw new NotImplementedException(); } - - public void EjectAll() - { - throw new System.NotImplementedException(); - } - - #endregion } } \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/Configuration/DSL/GenericFamilyExpressionTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Configuration/DSL/GenericFamilyExpressionTester.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap.Testing/Configuration/DSL/GenericFamilyExpressionTester.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -41,34 +41,7 @@ } } - public class TestingBuildPolicy : IBuildInterceptor - { - #region IBuildInterceptor Members - public IBuildPolicy InnerPolicy - { - get { throw new NotImplementedException(); } - set { } - } - - public object Build(BuildSession buildSession, Type pluginType, Instance instance) - { - throw new NotImplementedException(); - } - - public IBuildPolicy Clone() - { - throw new NotImplementedException(); - } - - public void EjectAll() - { - throw new System.NotImplementedException(); - } - - #endregion - } - public interface IRepository<T> { void Save(T subject); @@ -188,17 +161,6 @@ } [Test] - public void Intercept_construction_with() - { - var registry = new Registry(); - var policy = new TestingBuildPolicy(); - registry.ForRequestedType(typeof (ITarget)).InterceptConstructionWith(policy); - PluginGraph graph = registry.Build(); - - Assert.AreSame(policy, graph.FindFamily(typeof (ITarget)).Policy); - } - - [Test] public void On_creation() { ITarget created = null; @@ -219,7 +181,7 @@ registry.ForRequestedType(typeof (ITarget)).CacheBy(InstanceScope.ThreadLocal); PluginGraph graph = registry.Build(); - Assert.IsInstanceOfType(typeof (ThreadLocalStoragePolicy), graph.FindFamily(typeof (ITarget)).Policy); + graph.FindFamily(typeof (ITarget)).Lifecycle.ShouldBeOfType<ThreadLocalStorageLifecycle>(); } } } \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/Configuration/FamilyParserTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Configuration/FamilyParserTester.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap.Testing/Configuration/FamilyParserTester.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -44,19 +44,21 @@ private Type thePluginType; private PluginGraph _graph; - private void assertThatTheFamilyPolicyIs<T>() + private void assertThatTheFamilyLifecycleIs<T>() { _parser.ParseFamily(_familyElement); PluginFamily family = _graph.FindFamily(thePluginType); - Assert.IsInstanceOfType(typeof (T), family.Policy); + Assert.IsInstanceOfType(typeof (T), family.Lifecycle); } [Test] public void ScopeIsBlank() { - assertThatTheFamilyPolicyIs<BuildPolicy>(); + _parser.ParseFamily(_familyElement); + + _graph.FindFamily(thePluginType).Lifecycle.ShouldBeNull(); } @@ -64,7 +66,9 @@ public void ScopeIsBlank2() { _familyElement.SetAttribute(XmlConstants.SCOPE, ""); - assertThatTheFamilyPolicyIs<BuildPolicy>(); + _parser.ParseFamily(_familyElement); + + _graph.FindFamily(thePluginType).Lifecycle.ShouldBeNull(); } @@ -72,7 +76,7 @@ public void ScopeIsSingleton() { _familyElement.SetAttribute(XmlConstants.SCOPE, InstanceScope.Singleton.ToString()); - assertThatTheFamilyPolicyIs<SingletonPolicy>(); + assertThatTheFamilyLifecycleIs<SingletonLifecycle>(); } @@ -80,7 +84,7 @@ public void ScopeIsThreadLocal() { _familyElement.SetAttribute(XmlConstants.SCOPE, InstanceScope.ThreadLocal.ToString()); - assertThatTheFamilyPolicyIs<ThreadLocalStoragePolicy>(); + assertThatTheFamilyLifecycleIs<ThreadLocalStorageLifecycle>(); } } } \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/Configuration/NormalGraphBuilderTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Configuration/NormalGraphBuilderTester.cs 2009-04-19 23:48:02 UTC (rev 239) +++ trunk/Source/StructureMap.Testing/Configuration/NormalGraphBuilderTester.cs 2009-04-20 01:47:17 UTC (rev 240) @@ -3,6 +3,7 @@ using StructureMap.Configuration.DSL; using StructureMap.Graph; using StructureMap.Pipeline; +using StructureMap.Source; using StructureMap.Testing.Widget3; namespace StructureMap.Testing.Configuration @@ -57,14 +58,18 @@ [Test] public void Create_system_object_successfully_and_call_the_requested_action() { - var memento = new MemoryInstanceMemento("Singleton", "anything"); + var memento = new MemoryInstanceMemento("XmlFile", "anything"); + memento.SetProperty("FilePath", "something"); + memento.SetProperty("XPath", "nodeName"); + memento.SetProperty("NodeName", "something"); + bool iWasCalled = false; var builder = new GraphBuilder(new Registry[0]); - builder.WithSystemObject<IBuildInterceptor>(memento, "singleton", policy => + builder.WithSystemObject<MementoSource>(memento, "some xml", policy => { - Assert.IsInstanceOfType(typeof (SingletonPolicy), policy); + Assert.IsInstanceOfType(typeof(XmlFileMementoSource), policy); iWasCalled = true; }); Modified: trunk/Source/StructureMap.Testing/Graph/DynamicInjectionTester.cs =================================================================== --- trunk/Source/StructureMa... [truncated message content] |
From: <jer...@us...> - 2009-04-19 23:48:14
|
Revision: 239 http://structuremap.svn.sourceforge.net/structuremap/?rev=239&view=rev Author: jeremydmiller Date: 2009-04-19 23:48:02 +0000 (Sun, 19 Apr 2009) Log Message: ----------- just about to HACK, HACK, HACK!!!! Modified Paths: -------------- trunk/Source/StructureMap/BuildSession.cs trunk/Source/StructureMap/Graph/PluginFamily.cs trunk/Source/StructureMap/IInstanceFactory.cs trunk/Source/StructureMap/InstanceFactory.cs trunk/Source/StructureMap/Pipeline/BuildPolicy.cs trunk/Source/StructureMap/Pipeline/CacheInterceptor.cs trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs trunk/Source/StructureMap/Pipeline/HttpSessionBuildPolicy.cs trunk/Source/StructureMap/Pipeline/HybridBuildPolicy.cs trunk/Source/StructureMap/Pipeline/IBuildPolicy.cs trunk/Source/StructureMap/Pipeline/InstanceKey.cs trunk/Source/StructureMap/Pipeline/SingletonPolicy.cs trunk/Source/StructureMap/StructureMap.csproj trunk/Source/StructureMap/Util/Cache.cs trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj Added Paths: ----------- trunk/Source/StructureMap/Pipeline/HttpContextLifecycle.cs trunk/Source/StructureMap/Pipeline/HttpLifecycleBase.cs trunk/Source/StructureMap/Pipeline/Lifecycle.cs trunk/Source/StructureMap/Pipeline/SingletonLifecycle.cs trunk/Source/StructureMap/Pipeline/ThreadLocalStorageLifecycle.cs trunk/Source/StructureMap.Testing/Pipeline/ObjectBuilderTester.cs Modified: trunk/Source/StructureMap/BuildSession.cs =================================================================== --- trunk/Source/StructureMap/BuildSession.cs 2009-04-19 22:07:52 UTC (rev 238) +++ trunk/Source/StructureMap/BuildSession.cs 2009-04-19 23:48:02 UTC (rev 239) @@ -161,6 +161,7 @@ return _defaults[pluginType](); } + [Obsolete("get this inlined")] public virtual object ApplyInterception(Type pluginType, object actualValue) { if (actualValue == null) return null; Modified: trunk/Source/StructureMap/Graph/PluginFamily.cs =================================================================== --- trunk/Source/StructureMap/Graph/PluginFamily.cs 2009-04-19 22:07:52 UTC (rev 238) +++ trunk/Source/StructureMap/Graph/PluginFamily.cs 2009-04-19 23:48:02 UTC (rev 239) @@ -87,6 +87,7 @@ } } + [Obsolete("Kill!")] public void AddInterceptor(IBuildInterceptor interceptor) { interceptor.InnerPolicy = _buildPolicy; Modified: trunk/Source/StructureMap/IInstanceFactory.cs =================================================================== --- trunk/Source/StructureMap/IInstanceFactory.cs 2009-04-19 22:07:52 UTC (rev 238) +++ trunk/Source/StructureMap/IInstanceFactory.cs 2009-04-19 23:48:02 UTC (rev 239) @@ -13,6 +13,8 @@ { Type PluginType { get; } IEnumerable<IInstance> Instances { get; } + + [Obsolete("Kill!!!!")] IBuildPolicy Policy { get; } Instance MissingInstance { get; set; } @@ -27,12 +29,18 @@ [Obsolete("Return the list of Instances instead")] IList GetAllInstances(BuildSession session); + [Obsolete("Kill!!!!")] object Build(BuildSession session, Instance instance); + Instance FindInstance(string name); void ImportFrom(PluginFamily family); + + [Obsolete("Kill!!!!")] void EjectAllInstances(); + ILifecycle Lifecycle {get; } + } } \ No newline at end of file Modified: trunk/Source/StructureMap/InstanceFactory.cs =================================================================== --- trunk/Source/StructureMap/InstanceFactory.cs 2009-04-19 22:07:52 UTC (rev 238) +++ trunk/Source/StructureMap/InstanceFactory.cs 2009-04-19 23:48:02 UTC (rev 239) @@ -95,6 +95,7 @@ } } + [Obsolete("Kill!!!!")] public IBuildPolicy Policy { get { return _policy; } @@ -132,6 +133,7 @@ return list; } + [Obsolete("Kill!!!!")] public object Build(BuildSession session, Instance instance) { return _policy.Build(session, PluginType, instance); @@ -164,6 +166,11 @@ _instances.Clear(); } + public ILifecycle Lifecycle + { + get { throw new NotImplementedException(); } + } + #endregion } } \ No newline at end of file Modified: trunk/Source/StructureMap/Pipeline/BuildPolicy.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/BuildPolicy.cs 2009-04-19 22:07:52 UTC (rev 238) +++ trunk/Source/StructureMap/Pipeline/BuildPolicy.cs 2009-04-19 23:48:02 UTC (rev 239) @@ -3,6 +3,7 @@ namespace StructureMap.Pipeline { + [Obsolete("Kill!")] public sealed class BuildPolicy : IBuildPolicy { #region IBuildPolicy Members Modified: trunk/Source/StructureMap/Pipeline/CacheInterceptor.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/CacheInterceptor.cs 2009-04-19 22:07:52 UTC (rev 238) +++ trunk/Source/StructureMap/Pipeline/CacheInterceptor.cs 2009-04-19 23:48:02 UTC (rev 239) @@ -3,6 +3,10 @@ namespace StructureMap.Pipeline { + + + + [Obsolete("Kill! in favor of MainObjectCache")] public class ObjectCache : Cache<InstanceKey, object> { public ObjectCache(IBuildPolicy innerPolicy) : base(key => innerPolicy.Build(key.Session, key.PluginType, key.Instance)) Modified: trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs 2009-04-19 22:07:52 UTC (rev 238) +++ trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs 2009-04-19 23:48:02 UTC (rev 239) @@ -1,3 +1,4 @@ +using System; using System.Collections; using System.Web; using StructureMap.Attributes; Added: trunk/Source/StructureMap/Pipeline/HttpContextLifecycle.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/HttpContextLifecycle.cs (rev 0) +++ trunk/Source/StructureMap/Pipeline/HttpContextLifecycle.cs 2009-04-19 23:48:02 UTC (rev 239) @@ -0,0 +1,53 @@ +using System.Collections; +using System.Web; + +namespace StructureMap.Pipeline +{ + public class HttpContextLifecycle : ILifecycle + { + public static readonly string ITEM_NAME = "STRUCTUREMAP-INSTANCES"; + + + public static bool HasContext() + { + return HttpContext.Current != null; + } + + public static void DisposeAndClearAll() + { + new HttpContextLifecycle().FindCache().DisposeAndClear(); + } + + public void EjectAll() + { + FindCache().DisposeAndClear(); + } + + public IObjectCache FindCache() + { + IDictionary items = findHttpDictionary(); + + if (!items.Contains(ITEM_NAME)) + { + lock (items.SyncRoot) + { + if (!items.Contains(ITEM_NAME)) + { + MainObjectCache cache = new MainObjectCache(); + items.Add(ITEM_NAME, cache); + + return cache; + } + } + } + + return (IObjectCache)items[ITEM_NAME]; + } + + + protected virtual IDictionary findHttpDictionary() + { + return HttpContext.Current.Items; + } + } +} \ No newline at end of file Added: trunk/Source/StructureMap/Pipeline/HttpLifecycleBase.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/HttpLifecycleBase.cs (rev 0) +++ trunk/Source/StructureMap/Pipeline/HttpLifecycleBase.cs 2009-04-19 23:48:02 UTC (rev 239) @@ -0,0 +1,33 @@ +namespace StructureMap.Pipeline +{ + public abstract class HttpLifecycleBase<HTTP, NONHTTP> : ILifecycle + where HTTP : ILifecycle, new() + where NONHTTP : ILifecycle, new() + { + private readonly ILifecycle _http; + private readonly ILifecycle _nonHttp; + + public HttpLifecycleBase() + { + _http = new HTTP(); + _nonHttp = new NONHTTP(); + } + + public void EjectAll() + { + _http.EjectAll(); + _nonHttp.EjectAll(); + } + + public IObjectCache FindCache() + { + return HttpContextLifecycle.HasContext() + ? _http.FindCache() + : _nonHttp.FindCache(); + } + } + + public class HybridLifecycle : HttpLifecycleBase<HttpContextLifecycle, ThreadLocalStorageLifecycle> + { + } +} \ No newline at end of file Modified: trunk/Source/StructureMap/Pipeline/HttpSessionBuildPolicy.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/HttpSessionBuildPolicy.cs 2009-04-19 22:07:52 UTC (rev 238) +++ trunk/Source/StructureMap/Pipeline/HttpSessionBuildPolicy.cs 2009-04-19 23:48:02 UTC (rev 239) @@ -1,3 +1,4 @@ +using System; using System.Collections; using System.Web; using StructureMap.Attributes; @@ -17,6 +18,20 @@ } } + + public class HttpSessionLifecycle : HttpContextLifecycle + { + protected override IDictionary findHttpDictionary() + { + return new SessionWrapper(HttpContext.Current.Session); + } + } + + public class HybridSessionLifecycle : HttpLifecycleBase<HttpSessionLifecycle, ThreadLocalStorageLifecycle> + { + + } + public class HybridSessionBuildPolicy : HttpBuildPolicyBase<HttpSessionBuildPolicy, ThreadLocalStoragePolicy> { public override IBuildPolicy Clone() Modified: trunk/Source/StructureMap/Pipeline/HybridBuildPolicy.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/HybridBuildPolicy.cs 2009-04-19 22:07:52 UTC (rev 238) +++ trunk/Source/StructureMap/Pipeline/HybridBuildPolicy.cs 2009-04-19 23:48:02 UTC (rev 239) @@ -55,6 +55,9 @@ } + + + public class HybridBuildPolicy : HttpBuildPolicyBase<HttpContextBuildPolicy, ThreadLocalStoragePolicy> { public override IBuildPolicy Clone() Modified: trunk/Source/StructureMap/Pipeline/IBuildPolicy.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/IBuildPolicy.cs 2009-04-19 22:07:52 UTC (rev 238) +++ trunk/Source/StructureMap/Pipeline/IBuildPolicy.cs 2009-04-19 23:48:02 UTC (rev 239) @@ -5,6 +5,7 @@ /// <summary> /// An object that specifies a "Policy" about how Instance's are invoked. /// </summary> + [Obsolete("Kill!")] public interface IBuildPolicy { object Build(BuildSession buildSession, Type pluginType, Instance instance); Modified: trunk/Source/StructureMap/Pipeline/InstanceKey.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/InstanceKey.cs 2009-04-19 22:07:52 UTC (rev 238) +++ trunk/Source/StructureMap/Pipeline/InstanceKey.cs 2009-04-19 23:48:02 UTC (rev 239) @@ -6,21 +6,29 @@ { public string Name { get; set; } public Type PluginType { get; set; } + [Obsolete("Kill!")] private WeakReference _session; + [Obsolete("Kill!")] private WeakReference _instance; public InstanceKey() { } + public InstanceKey(Instance instance, Type pluginType) + { + Name = instance.Name; + PluginType = pluginType; + } - + [Obsolete("Kill!")] public BuildSession Session { get { return (BuildSession) _session.Target; } set { _session = new WeakReference(value); } } + [Obsolete("Kill!")] public Instance Instance { get Added: trunk/Source/StructureMap/Pipeline/Lifecycle.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/Lifecycle.cs (rev 0) +++ trunk/Source/StructureMap/Pipeline/Lifecycle.cs 2009-04-19 23:48:02 UTC (rev 239) @@ -0,0 +1,179 @@ +using System; +using System.Collections.Generic; +using StructureMap.Attributes; +using StructureMap.Interceptors; +using StructureMap.Util; + +namespace StructureMap.Pipeline +{ + public interface IObjectCache + { + object Locker { get; } + object Get(Type pluginType, Instance instance); + void Set(Type pluginType, Instance instance, object value); + void DisposeAndClear(); + } + + public class NulloObjectCache : IObjectCache + { + public object Locker + { + get { return new object(); } + } + + public object Get(Type pluginType, Instance instance) + { + return null; + } + + public void Set(Type pluginType, Instance instance, object value) + { + // no-op + } + + public void DisposeAndClear() + { + // no-op + } + } + + public class MainObjectCache : IObjectCache + { + private readonly IDictionary<InstanceKey, object> _objects = new Dictionary<InstanceKey,object>(); + private readonly object _locker = new object(); + + public object Locker + { + get { return _locker; } + } + + public object Get(Type pluginType, Instance instance) + { + var key = new InstanceKey(instance, pluginType); + return _objects.ContainsKey(key) ? _objects[key] : null; + } + + public void Set(Type pluginType, Instance instance, object value) + { + var key = new InstanceKey(instance, pluginType); + _objects.Add(key, value); + } + + public void DisposeAndClear() + { + + lock (Locker) + { + foreach (var @object in _objects.Values) + { + IDisposable disposable = @object as IDisposable; + if (disposable != null) + { + try + { + disposable.Dispose(); + } + catch (Exception) { } + } + } + + _objects.Clear(); + } + } + } + + + public interface ILifecycle + { + void EjectAll(); + IObjectCache FindCache(); + } + + public static class Lifecycles + { + public static ILifecycle GetLifecycle(InstanceScope scope) + { + switch (scope) + { + case InstanceScope.Singleton: + return new SingletonLifecycle(); + + case InstanceScope.HttpContext: + return new HttpContextLifecycle(); + + case InstanceScope.ThreadLocal: + return new ThreadLocalStorageLifecycle(); + + case InstanceScope.Hybrid: + return new HybridLifecycle(); + + case InstanceScope.HttpSession: + return new HttpSessionLifecycle(); + + case InstanceScope.HybridHttpSession: + return new HybridSessionLifecycle(); + } + + throw new ArgumentOutOfRangeException("scope"); + } + } + + public class ObjectBuilder + { + private readonly PipelineGraph _pipeline; + private readonly InterceptorLibrary _library; + private readonly IObjectCache _defaultCache; + + public ObjectBuilder(PipelineGraph pipeline, InterceptorLibrary library, IObjectCache defaultCache) + { + _pipeline = pipeline; + _library = library; + _defaultCache = defaultCache; + } + + public object Resolve(Type pluginType, Instance instance, BuildSession session) + { + var cache = FindCache(instance, session); + lock (cache.Locker) + { + var returnValue = cache.Get(pluginType, instance); + if (returnValue == null) + { + returnValue = ConstructNew(pluginType, instance, session); + + + cache.Set(pluginType, instance, returnValue); + } + + return returnValue; + } + } + + public object ConstructNew(Type pluginType, Instance instance, BuildSession session) + { + object returnValue = instance.Build(pluginType, session); + return ApplyInterception(pluginType, returnValue, session, instance); + } + + public virtual object ApplyInterception(Type pluginType, object actualValue, BuildSession session, Instance instance) + { + if (actualValue == null) return null; + + try + { + return _library.FindInterceptor(actualValue.GetType()).Process(actualValue, session); + } + catch (Exception e) + { + throw new StructureMapException(308, e, instance.Name, actualValue.GetType()); + } + + + } + + public IObjectCache FindCache(Instance instance, BuildSession session) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file Added: trunk/Source/StructureMap/Pipeline/SingletonLifecycle.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/SingletonLifecycle.cs (rev 0) +++ trunk/Source/StructureMap/Pipeline/SingletonLifecycle.cs 2009-04-19 23:48:02 UTC (rev 239) @@ -0,0 +1,17 @@ +namespace StructureMap.Pipeline +{ + public class SingletonLifecycle : ILifecycle + { + private readonly MainObjectCache _cache = new MainObjectCache(); + + public void EjectAll() + { + _cache.DisposeAndClear(); + } + + public IObjectCache FindCache() + { + return _cache; + } + } +} \ No newline at end of file Modified: trunk/Source/StructureMap/Pipeline/SingletonPolicy.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/SingletonPolicy.cs 2009-04-19 22:07:52 UTC (rev 238) +++ trunk/Source/StructureMap/Pipeline/SingletonPolicy.cs 2009-04-19 23:48:02 UTC (rev 239) @@ -3,6 +3,7 @@ namespace StructureMap.Pipeline { + [Obsolete("Kill!")] public class SingletonPolicy : CacheInterceptor { private readonly object _locker = new object(); Added: trunk/Source/StructureMap/Pipeline/ThreadLocalStorageLifecycle.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/ThreadLocalStorageLifecycle.cs (rev 0) +++ trunk/Source/StructureMap/Pipeline/ThreadLocalStorageLifecycle.cs 2009-04-19 23:48:02 UTC (rev 239) @@ -0,0 +1,37 @@ +using System; + +namespace StructureMap.Pipeline +{ + public class ThreadLocalStorageLifecycle : ILifecycle + { + private readonly object _locker = new object(); + + [ThreadStatic] + private static MainObjectCache _cache; + + public void EjectAll() + { + FindCache().DisposeAndClear(); + } + + public IObjectCache FindCache() + { + guaranteeHashExists(); + return _cache; + } + + private void guaranteeHashExists() + { + if (_cache == null) + { + lock (_locker) + { + if (_cache == null) + { + _cache = new MainObjectCache(); + } + } + } + } + } +} \ No newline at end of file Modified: trunk/Source/StructureMap/StructureMap.csproj =================================================================== --- trunk/Source/StructureMap/StructureMap.csproj 2009-04-19 22:07:52 UTC (rev 238) +++ trunk/Source/StructureMap/StructureMap.csproj 2009-04-19 23:48:02 UTC (rev 239) @@ -407,8 +407,13 @@ <Compile Include="Graph\PluginCache.cs" /> <Compile Include="IContext.cs" /> <Compile Include="Pipeline\ConditionalInstance.cs" /> + <Compile Include="Pipeline\HttpContextLifecycle.cs" /> + <Compile Include="Pipeline\HttpLifecycleBase.cs" /> <Compile Include="Pipeline\HttpSessionBuildPolicy.cs" /> + <Compile Include="Pipeline\Lifecycle.cs" /> <Compile Include="Pipeline\SessionWrapper.cs" /> + <Compile Include="Pipeline\SingletonLifecycle.cs" /> + <Compile Include="Pipeline\ThreadLocalStorageLifecycle.cs" /> <Compile Include="Pipeline\UniquePerRequestInterceptor.cs" /> <Compile Include="TypeExtensions.cs" /> <Compile Include="IBootstrapper.cs" /> Modified: trunk/Source/StructureMap/Util/Cache.cs =================================================================== --- trunk/Source/StructureMap/Util/Cache.cs 2009-04-19 22:07:52 UTC (rev 238) +++ trunk/Source/StructureMap/Util/Cache.cs 2009-04-19 23:48:02 UTC (rev 239) @@ -38,6 +38,11 @@ _values = dictionary; } + public object Locker + { + get { return _locker; } + } + public Func<KEY, VALUE> OnMissing { set { _onMissing = value; } Added: trunk/Source/StructureMap.Testing/Pipeline/ObjectBuilderTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Pipeline/ObjectBuilderTester.cs (rev 0) +++ trunk/Source/StructureMap.Testing/Pipeline/ObjectBuilderTester.cs 2009-04-19 23:48:02 UTC (rev 239) @@ -0,0 +1,33 @@ +using NUnit.Framework; +using Rhino.Mocks; +using StructureMap.Graph; +using StructureMap.Interceptors; +using StructureMap.Pipeline; + +namespace StructureMap.Testing.Pipeline +{ + [TestFixture] public class ObjectBuilderTester + { + private PluginGraph graph; + private PipelineGraph pipeline; + private InterceptorLibrary library; + private IObjectCache theDefaultCache; + private ObjectBuilder builder; + + [SetUp] public void SetUp() + { + graph = new PluginGraph(); + pipeline = new PipelineGraph(graph); + library = new InterceptorLibrary(); + + theDefaultCache = MockRepository.GenerateMock<IObjectCache>(); + + builder = new ObjectBuilder(pipeline, library, theDefaultCache); + } + + [Test] public void FIRSTTEST() + { + + } + } +} \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj =================================================================== --- trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-04-19 22:07:52 UTC (rev 238) +++ trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-04-19 23:48:02 UTC (rev 239) @@ -353,6 +353,7 @@ <Compile Include="Pipeline\InstanceTester.cs" /> <Compile Include="Pipeline\LiteralInstanceTester.cs" /> <Compile Include="Pipeline\MissingInstanceTester.cs" /> + <Compile Include="Pipeline\ObjectBuilderTester.cs" /> <Compile Include="Pipeline\OptionalSetterInjectionTester.cs" /> <Compile Include="Pipeline\ProfileManagerMergeTester.cs" /> <Compile Include="Pipeline\ProfileManagerTester.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2009-04-19 22:08:01
|
Revision: 238 http://structuremap.svn.sourceforge.net/structuremap/?rev=238&view=rev Author: jeremydmiller Date: 2009-04-19 22:07:52 +0000 (Sun, 19 Apr 2009) Log Message: ----------- little refactoring before starting the big restructuring around lifecycle Modified Paths: -------------- trunk/Source/StructureMap/Pipeline/CacheInterceptor.cs trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs trunk/Source/StructureMap/Pipeline/SingletonPolicy.cs trunk/Source/StructureMap/Pipeline/ThreadLocalStoragePolicy.cs Modified: trunk/Source/StructureMap/Pipeline/CacheInterceptor.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/CacheInterceptor.cs 2009-04-19 20:45:09 UTC (rev 237) +++ trunk/Source/StructureMap/Pipeline/CacheInterceptor.cs 2009-04-19 22:07:52 UTC (rev 238) @@ -3,9 +3,9 @@ namespace StructureMap.Pipeline { - public class InstanceCache : Cache<InstanceKey, object> + public class ObjectCache : Cache<InstanceKey, object> { - public InstanceCache(IBuildPolicy innerPolicy) : base(key => innerPolicy.Build(key.Session, key.PluginType, key.Instance)) + public ObjectCache(IBuildPolicy innerPolicy) : base(key => innerPolicy.Build(key.Session, key.PluginType, key.Instance)) { } @@ -29,7 +29,6 @@ public abstract class CacheInterceptor : IBuildInterceptor { - private readonly object _locker = new object(); private IBuildPolicy _innerPolicy = new BuildPolicy(); #region IBuildInterceptor Members @@ -40,12 +39,12 @@ set { _innerPolicy = value; } } - protected InstanceCache buildNewCache() + protected ObjectCache buildNewCache() { - return new InstanceCache(_innerPolicy); + return new ObjectCache(_innerPolicy); } - protected abstract InstanceCache findCache(); + protected abstract ObjectCache findCache(); public object Build(BuildSession buildSession, Type pluginType, Instance instance) { Modified: trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs 2009-04-19 20:45:09 UTC (rev 237) +++ trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs 2009-04-19 22:07:52 UTC (rev 238) @@ -19,7 +19,7 @@ new HttpContextBuildPolicy().findCache().DisposeAndClear(); } - protected override InstanceCache findCache() + protected override ObjectCache findCache() { IDictionary items = findHttpDictionary(); @@ -29,7 +29,7 @@ { if (!items.Contains(ITEM_NAME)) { - InstanceCache cache = buildNewCache(); + ObjectCache cache = buildNewCache(); items.Add(ITEM_NAME, cache); return cache; @@ -37,7 +37,7 @@ } } - return (InstanceCache) items[ITEM_NAME]; + return (ObjectCache) items[ITEM_NAME]; } protected virtual IDictionary findHttpDictionary() Modified: trunk/Source/StructureMap/Pipeline/SingletonPolicy.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/SingletonPolicy.cs 2009-04-19 20:45:09 UTC (rev 237) +++ trunk/Source/StructureMap/Pipeline/SingletonPolicy.cs 2009-04-19 22:07:52 UTC (rev 238) @@ -6,9 +6,9 @@ public class SingletonPolicy : CacheInterceptor { private readonly object _locker = new object(); - private InstanceCache _cache; + private ObjectCache _cache; - protected override InstanceCache findCache() + protected override ObjectCache findCache() { if (_cache == null) { @@ -24,7 +24,7 @@ return _cache; } - public InstanceCache Cache + public ObjectCache Cache { get { Modified: trunk/Source/StructureMap/Pipeline/ThreadLocalStoragePolicy.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/ThreadLocalStoragePolicy.cs 2009-04-19 20:45:09 UTC (rev 237) +++ trunk/Source/StructureMap/Pipeline/ThreadLocalStoragePolicy.cs 2009-04-19 22:07:52 UTC (rev 238) @@ -5,7 +5,7 @@ { public class ThreadLocalStoragePolicy : CacheInterceptor { - [ThreadStatic] private static InstanceCache _cache; + [ThreadStatic] private static ObjectCache _cache; private readonly object _locker = new object(); public static void DisposeAndClearAll() @@ -27,7 +27,7 @@ } } - protected override InstanceCache findCache() + protected override ObjectCache findCache() { guaranteeHashExists(); return _cache; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2009-04-19 20:45:14
|
Revision: 237 http://structuremap.svn.sourceforge.net/structuremap/?rev=237&view=rev Author: jeremydmiller Date: 2009-04-19 20:45:09 +0000 (Sun, 19 Apr 2009) Log Message: ----------- Fixing missing instance, PhatBoyG's patch Modified Paths: -------------- trunk/Source/StructureMap/Graph/PluginFamily.cs trunk/Source/StructureMap/InstanceFactory.cs trunk/Source/StructureMap.Testing/GenericsAcceptanceTester.cs trunk/Source/StructureMap.Testing/Pipeline/BuildStrategiesTester.cs trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj Added Paths: ----------- trunk/Source/StructureMap.Testing/Bugs/MixedConfigureAndInitializeMissingInstanceProblem.cs Modified: trunk/Source/StructureMap/Graph/PluginFamily.cs =================================================================== --- trunk/Source/StructureMap/Graph/PluginFamily.cs 2009-04-19 19:17:16 UTC (rev 236) +++ trunk/Source/StructureMap/Graph/PluginFamily.cs 2009-04-19 20:45:09 UTC (rev 237) @@ -20,7 +20,6 @@ private IBuildPolicy _buildPolicy = new BuildPolicy(); private string _defaultKey = string.Empty; private PluginGraph _parent; - private IBuildPolicy _policy; public PluginFamily(Type pluginType) : this(pluginType, new PluginGraph()) @@ -260,6 +259,11 @@ { source.EachInstance(instance => _instances.Fill(instance.Name, instance)); source._pluggedTypes.Each((key, plugin) => _pluggedTypes.Fill(key, plugin)); + + if (source.MissingInstance != null) + { + MissingInstance = source.MissingInstance; + } } public Instance FirstInstance() @@ -340,7 +344,7 @@ public IBuildPolicy Policy { get { return _buildPolicy; } - set { _policy = value; } + set { _buildPolicy = value; } } public int PluginCount Modified: trunk/Source/StructureMap/InstanceFactory.cs =================================================================== --- trunk/Source/StructureMap/InstanceFactory.cs 2009-04-19 19:17:16 UTC (rev 236) +++ trunk/Source/StructureMap/InstanceFactory.cs 2009-04-19 20:45:09 UTC (rev 237) @@ -151,6 +151,11 @@ } family.EachInstance(instance => _instances.Fill(instance.Name, instance)); + + if (family.MissingInstance != null) + { + MissingInstance = family.MissingInstance; + } } public void EjectAllInstances() Added: trunk/Source/StructureMap.Testing/Bugs/MixedConfigureAndInitializeMissingInstanceProblem.cs =================================================================== --- trunk/Source/StructureMap.Testing/Bugs/MixedConfigureAndInitializeMissingInstanceProblem.cs (rev 0) +++ trunk/Source/StructureMap.Testing/Bugs/MixedConfigureAndInitializeMissingInstanceProblem.cs 2009-04-19 20:45:09 UTC (rev 237) @@ -0,0 +1,49 @@ +using NUnit.Framework; +using StructureMap.Testing.Widget; + +namespace StructureMap.Testing.Bugs +{ + [TestFixture] public class MixedConfigureAndInitializeMissingInstanceProblem + { + private Container container; + + [SetUp] public void SetUp() + { + container = new Container(x => + { + x.ForRequestedType<IWidget>().MissingNamedInstanceIs.Conditional(o => + { + o.TheDefault.Is.ConstructedBy(c => new ColorWidget(c.RequestedName)); + }); + }); + } + + [Test] public void configure_again_and_try_to_fetch_the_missing_instance() + { + container.Configure(x => + { + x.ForRequestedType<IWidget>().TheDefaultIsConcreteType<AWidget>(); + }); + + container.GetInstance<IWidget>("Red").ShouldBeOfType<ColorWidget>().Color.ShouldEqual("Red"); + } + + [Test] public void configure_the_missing_method_instance_in_the_configure() + { + container = new Container(x => + { + x.ForRequestedType<IWidget>().TheDefaultIsConcreteType<AWidget>(); + }); + + container.Configure(x => + { + x.ForRequestedType<IWidget>().MissingNamedInstanceIs.Conditional(o => + { + o.TheDefault.Is.ConstructedBy(c => new ColorWidget(c.RequestedName)); + }); + }); + + container.GetInstance<IWidget>("Red").ShouldBeOfType<ColorWidget>().Color.ShouldEqual("Red"); + } + } +} \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/GenericsAcceptanceTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/GenericsAcceptanceTester.cs 2009-04-19 19:17:16 UTC (rev 236) +++ trunk/Source/StructureMap.Testing/GenericsAcceptanceTester.cs 2009-04-19 20:45:09 UTC (rev 237) @@ -7,7 +7,9 @@ namespace StructureMap.Testing { - [TestFixture] + using StructureMap.Attributes; + + [TestFixture] public class GenericsAcceptanceTester { #region Setup/Teardown @@ -216,6 +218,22 @@ { Assert.IsTrue(GenericsPluginGraph.CanBeCast(typeof (ITarget<,>), typeof (DisposableTarget<,>))); } + + [Test] + public void CanGetTheSameInstanceOfGenericInterfaceWithSingletonScope() + { + Container con = new Container(x => + { + x.ForRequestedType(typeof (IService<>)) + .CacheBy(InstanceScope.Singleton) + .TheDefaultIsConcreteType(typeof (Service<>)); + }); + + var first = con.GetInstance<IService<string>>(); + var second = con.GetInstance<IService<string>>(); + + Assert.AreSame(first, second, "The objects are not the same instance"); + } } @@ -295,4 +313,4 @@ return typeof (T); } } -} \ No newline at end of file +} Modified: trunk/Source/StructureMap.Testing/Pipeline/BuildStrategiesTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Pipeline/BuildStrategiesTester.cs 2009-04-19 19:17:16 UTC (rev 236) +++ trunk/Source/StructureMap.Testing/Pipeline/BuildStrategiesTester.cs 2009-04-19 20:45:09 UTC (rev 237) @@ -95,11 +95,13 @@ [Test] public void CloneSingleton() { + var inner = new BuildPolicy(); var policy = new SingletonPolicy(); + policy.InnerPolicy = inner; - var clone = (SingletonPolicy) policy.Clone(); - Assert.AreNotSame(policy, clone); - Assert.IsInstanceOfType(typeof (BuildPolicy), clone.InnerPolicy); + var clone = policy.Clone().ShouldBeOfType<SingletonPolicy>(); + clone.ShouldNotBeTheSameAs(policy); + clone.InnerPolicy.ShouldBeOfType<BuildPolicy>(); } Modified: trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj =================================================================== --- trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-04-19 19:17:16 UTC (rev 236) +++ trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-04-19 20:45:09 UTC (rev 237) @@ -182,6 +182,7 @@ <Compile Include="Bugs\HttpSessionNullRefBug.cs" /> <Compile Include="Bugs\IDictionaryAndXmlBugTester.cs" /> <Compile Include="Bugs\LambdaCreatesNullBugTester.cs" /> + <Compile Include="Bugs\MixedConfigureAndInitializeMissingInstanceProblem.cs" /> <Compile Include="Bugs\ScanIndexerBugTester.cs" /> <Compile Include="Bugs\SingletonShouldBeLazy.cs" /> <Compile Include="Bugs\SpecifyScopeInConfigureTester.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2009-04-19 19:17:21
|
Revision: 236 http://structuremap.svn.sourceforge.net/structuremap/?rev=236&view=rev Author: jeremydmiller Date: 2009-04-19 19:17:16 +0000 (Sun, 19 Apr 2009) Log Message: ----------- Trying to fix a 400 bug related to a lambda returning null Modified Paths: -------------- trunk/Source/StructureMap/Graph/PluginCache.cs trunk/Source/StructureMap/InstanceCache.cs trunk/Source/StructureMap/StructureMapException.resx trunk/Source/StructureMap/Util/Cache.cs trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj Added Paths: ----------- trunk/Source/StructureMap.Testing/Bugs/LambdaCreatesNullBugTester.cs Modified: trunk/Source/StructureMap/Graph/PluginCache.cs =================================================================== --- trunk/Source/StructureMap/Graph/PluginCache.cs 2009-04-19 18:40:49 UTC (rev 235) +++ trunk/Source/StructureMap/Graph/PluginCache.cs 2009-04-19 19:17:16 UTC (rev 236) @@ -30,8 +30,15 @@ _builders = new Cache<Type, InstanceBuilder>(t => { - Plugin plugin = _plugins[t]; - return new InstanceBuilderAssembly(new[] {plugin}).Compile()[0]; + try + { + Plugin plugin = _plugins[t]; + return new InstanceBuilderAssembly(new[] {plugin}).Compile()[0]; + } + catch (Exception e) + { + throw new StructureMapException(245, t.AssemblyQualifiedName, e); + } }); } Modified: trunk/Source/StructureMap/InstanceCache.cs =================================================================== --- trunk/Source/StructureMap/InstanceCache.cs 2009-04-19 18:40:49 UTC (rev 235) +++ trunk/Source/StructureMap/InstanceCache.cs 2009-04-19 19:17:16 UTC (rev 236) @@ -38,6 +38,8 @@ public void Set(Type pluginType, Instance Instance, object result) { + if (result == null) return; + Dictionary<Instance, object> cache = getCache(pluginType); if (cache.ContainsKey(Instance)) Modified: trunk/Source/StructureMap/StructureMapException.resx =================================================================== --- trunk/Source/StructureMap/StructureMapException.resx 2009-04-19 18:40:49 UTC (rev 235) +++ trunk/Source/StructureMap/StructureMapException.resx 2009-04-19 19:17:16 UTC (rev 236) @@ -274,4 +274,7 @@ <data name="295" xml:space="preserve"> <value>Bidirectional Dependency Problem detected with {0}. The BuildStack is: {1}</value> </data> + <data name="245" xml:space="preserve"> + <value>Error while trying to create an InstanceBuilder for {0}</value> + </data> </root> \ No newline at end of file Modified: trunk/Source/StructureMap/Util/Cache.cs =================================================================== --- trunk/Source/StructureMap/Util/Cache.cs 2009-04-19 18:40:49 UTC (rev 235) +++ trunk/Source/StructureMap/Util/Cache.cs 2009-04-19 19:17:16 UTC (rev 236) @@ -81,7 +81,9 @@ VALUE value = _onMissing(key); //Check to make sure that the onMissing didn't cache this already if(!_values.ContainsKey(key)) + { _values.Add(key, value); + } } } } @@ -90,14 +92,17 @@ } set { - if (_values.ContainsKey(key)) + lock (_locker) { - _values[key] = value; + if (_values.ContainsKey(key)) + { + _values[key] = value; + } + else + { + _values.Add(key, value); + } } - else - { - _values.Add(key, value); - } } } Added: trunk/Source/StructureMap.Testing/Bugs/LambdaCreatesNullBugTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Bugs/LambdaCreatesNullBugTester.cs (rev 0) +++ trunk/Source/StructureMap.Testing/Bugs/LambdaCreatesNullBugTester.cs 2009-04-19 19:17:16 UTC (rev 236) @@ -0,0 +1,43 @@ +using System.Security.Principal; +using NUnit.Framework; + +namespace StructureMap.Testing.Bugs +{ + + [TestFixture] public class LambdaCreatesNullBugTester + { + [SetUp] public void SetUp() + { + + } + + [Test] + public void Returning_null_values_in_contructed_by_generates_a_duplicate_cache_entry() + { + var container = new Container(x => + { + x.ForRequestedType<IPrincipal>().TheDefault.Is.ConstructedBy(() => null); + + x.ForRequestedType<TestClass>().TheDefaultIsConcreteType<TestClass>(); + }); + + container.GetInstance<TestClass>().ShouldNotBeNull(); + + + //this throws a duplicate cache entry exception + container.AssertConfigurationIsValid(); + } + } + + + public class TestClass + { + private IPrincipal principal; + + public TestClass(IPrincipal principal) + { + this.principal = principal; + } + + } +} \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj =================================================================== --- trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-04-19 18:40:49 UTC (rev 235) +++ trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-04-19 19:17:16 UTC (rev 236) @@ -181,6 +181,7 @@ <Compile Include="Bugs\BuildUpBug.cs" /> <Compile Include="Bugs\HttpSessionNullRefBug.cs" /> <Compile Include="Bugs\IDictionaryAndXmlBugTester.cs" /> + <Compile Include="Bugs\LambdaCreatesNullBugTester.cs" /> <Compile Include="Bugs\ScanIndexerBugTester.cs" /> <Compile Include="Bugs\SingletonShouldBeLazy.cs" /> <Compile Include="Bugs\SpecifyScopeInConfigureTester.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2009-04-19 18:40:59
|
Revision: 235 http://structuremap.svn.sourceforge.net/structuremap/?rev=235&view=rev Author: jeremydmiller Date: 2009-04-19 18:40:49 +0000 (Sun, 19 Apr 2009) Log Message: ----------- Making StructureMap throw a clean error when a cyclic dependency is detected Modified Paths: -------------- trunk/Source/StructureMap/BuildSession.cs trunk/Source/StructureMap/CloseGenericTypeExpression.cs trunk/Source/StructureMap/Container.cs trunk/Source/StructureMap/IInstanceFactory.cs trunk/Source/StructureMap/InstanceCache.cs trunk/Source/StructureMap/InstanceFactory.cs trunk/Source/StructureMap/Pipeline/BuildFrame.cs trunk/Source/StructureMap/Pipeline/BuildStack.cs trunk/Source/StructureMap/Pipeline/Instance.cs trunk/Source/StructureMap/StructureMap.csproj trunk/Source/StructureMap/StructureMapException.resx trunk/Source/StructureMap/TypeExtensions.cs trunk/Source/StructureMap.Testing/Pipeline/BuildStackTester.cs trunk/Source/StructureMap.Testing/Pipeline/GenericsHelperExpressionTester.cs trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj Added Paths: ----------- trunk/Source/StructureMap/IContext.cs trunk/Source/StructureMap.Testing/BidirectionalDependencies.cs Modified: trunk/Source/StructureMap/BuildSession.cs =================================================================== --- trunk/Source/StructureMap/BuildSession.cs 2009-02-24 03:18:29 UTC (rev 234) +++ trunk/Source/StructureMap/BuildSession.cs 2009-04-19 18:40:49 UTC (rev 235) @@ -1,5 +1,4 @@ using System; -using System.Collections; using StructureMap.Graph; using StructureMap.Interceptors; using StructureMap.Pipeline; @@ -7,68 +6,6 @@ namespace StructureMap { - public interface IContext - { - /// <summary> - /// Gets a reference to the <see cref="BuildStack">BuildStack</see> for this build session - /// </summary> - BuildStack BuildStack { get; } - - /// <summary> - /// The concrete type of the immediate parent object in the object graph - /// </summary> - Type ParentType { get; } - - /// <summary> - /// Get the object of type T that is valid for this build session. - /// </summary> - /// <typeparam name="T"></typeparam> - /// <returns></returns> - T GetInstance<T>(); - - /// <summary> - /// Get the object of type T that is valid for this build session by name. - /// </summary> - /// <typeparam name="T"></typeparam> - /// <returns></returns> - T GetInstance<T>(string name); - - /// <summary> - /// Gets the root "frame" of the object request - /// </summary> - BuildFrame Root { get; } - - /// <summary> - /// The requested instance name of the object graph - /// </summary> - string RequestedName { get; } - - /// <summary> - /// Register a default object for the given PluginType that will - /// be used throughout the rest of the current object request - /// </summary> - /// <param name="pluginType"></param> - /// <param name="defaultObject"></param> - void RegisterDefault(Type pluginType, object defaultObject); - - /// <summary> - /// Same as GetInstance, but can gracefully return null if - /// the Type does not already exist - /// </summary> - /// <typeparam name="T"></typeparam> - /// <returns></returns> - T TryGetInstance<T>() where T : class; - - /// <summary> - /// Same as GetInstance(name), but can gracefully return null if - /// the Type and name does not already exist - /// </summary> - /// <typeparam name="T"></typeparam> - /// <param name="name"></param> - /// <returns></returns> - T TryGetInstance<T>(string name) where T : class; - } - public class BuildSession : IContext { private readonly BuildStack _buildStack = new BuildStack(); @@ -102,13 +39,12 @@ { } - public BuildSession() : this(new PluginGraph()) + public BuildSession() + : this(new PluginGraph()) { } - public string RequestedName { get; set; } - protected PipelineGraph pipelineGraph { get { return _pipelineGraph; } @@ -116,6 +52,12 @@ #region IContext Members + public string RequestedName + { + get; + set; + } + public BuildStack BuildStack { get { return _buildStack; } @@ -145,6 +87,28 @@ get { return _buildStack.Root; } } + public virtual void RegisterDefault(Type pluginType, object defaultObject) + { + RegisterDefault(pluginType, () => defaultObject); + } + + public T TryGetInstance<T>() where T : class + { + if (_defaults.Has(typeof (T))) + { + return (T) _defaults[typeof (T)](); + } + + return _pipelineGraph.HasDefaultForPluginType(typeof (T)) + ? ((IContext) this).GetInstance<T>() + : null; + } + + public T TryGetInstance<T>(string name) where T : class + { + return _pipelineGraph.HasInstance(typeof (T), name) ? ((IContext) this).GetInstance<T>(name) : null; + } + #endregion public virtual object CreateInstance(Type pluginType, string name) @@ -158,6 +122,7 @@ return CreateInstance(pluginType, instance); } + // This is where all Creation happens public virtual object CreateInstance(Type pluginType, Instance instance) { object result = _cache.Get(pluginType, instance); @@ -175,27 +140,17 @@ public virtual Array CreateInstanceArray(Type pluginType, Instance[] instances) { - Array array; - if (instances == null) { - IList list = forType(pluginType).GetAllInstances(this); - array = Array.CreateInstance(pluginType, list.Count); - for (int i = 0; i < list.Count; i++) - { - array.SetValue(list[i], i); - } + instances = forType(pluginType).AllInstances; } - else - { - array = Array.CreateInstance(pluginType, instances.Length); - for (int i = 0; i < instances.Length; i++) - { - Instance instance = instances[i]; - object arrayValue = forType(pluginType).Build(this, instance); - array.SetValue(arrayValue, i); - } + Array array = Array.CreateInstance(pluginType, instances.Length); + for (int i = 0; i < instances.Length; i++) + { + Instance instance = instances[i]; + object arrayValue = CreateInstance(pluginType, instance); + array.SetValue(arrayValue, i); } return array; @@ -212,37 +167,15 @@ return _interceptorLibrary.FindInterceptor(actualValue.GetType()).Process(actualValue, this); } - public virtual void RegisterDefault(Type pluginType, object defaultObject) - { - RegisterDefault(pluginType, () => defaultObject); - } - public virtual void RegisterDefault(Type pluginType, Func<object> creator) { _defaults[pluginType] = creator; } - public T TryGetInstance<T>() where T : class - { - if (_defaults.Has(typeof(T))) - { - return (T) _defaults[typeof (T)](); - } - return _pipelineGraph.HasDefaultForPluginType(typeof (T)) - ? ((IContext) this).GetInstance<T>() - : null; - } - - public T TryGetInstance<T>(string name) where T : class - { - return _pipelineGraph.HasInstance(typeof (T), name) ? ((IContext) this).GetInstance<T>(name) : null; - } - - private IInstanceFactory forType(Type pluginType) { return _pipelineGraph.ForType(pluginType); } } -} +} \ No newline at end of file Modified: trunk/Source/StructureMap/CloseGenericTypeExpression.cs =================================================================== --- trunk/Source/StructureMap/CloseGenericTypeExpression.cs 2009-02-24 03:18:29 UTC (rev 234) +++ trunk/Source/StructureMap/CloseGenericTypeExpression.cs 2009-04-19 18:40:49 UTC (rev 235) @@ -1,4 +1,6 @@ using System; +using System.Collections; +using System.Collections.Generic; namespace StructureMap { @@ -7,8 +9,13 @@ T As<T>(); } - public class CloseGenericTypeExpression : OpenGenericTypeSpecificationExpression + public interface OpenGenericTypeListSpecificationExpression { + IList<T> As<T>(); + } + + public class CloseGenericTypeExpression : OpenGenericTypeSpecificationExpression, OpenGenericTypeListSpecificationExpression + { private readonly object _subject; private readonly IContainer _container; private Type _pluginType; @@ -26,13 +33,18 @@ /// <returns></returns> public OpenGenericTypeSpecificationExpression GetClosedTypeOf(Type type) { + closeType(type); + return this; + } + + private void closeType(Type type) + { if (!type.IsGeneric()) { throw new StructureMapException(285); } _pluginType = type.MakeGenericType(_subject.GetType()); - return this; } /// <summary> @@ -44,5 +56,23 @@ { return (T) _container.With(_subject.GetType(), _subject).GetInstance(_pluginType); } + + public OpenGenericTypeListSpecificationExpression GetAllClosedTypesOf(Type type) + { + closeType(type); + return this; + } + + IList<T> OpenGenericTypeListSpecificationExpression.As<T>() + { + IList list = _container.With(_subject.GetType(), _subject).GetAllInstances(_pluginType); + var returnValue = new List<T>(); + foreach (var o in list) + { + returnValue.Add((T) o); + } + + return returnValue; + } } } \ No newline at end of file Modified: trunk/Source/StructureMap/Container.cs =================================================================== --- trunk/Source/StructureMap/Container.cs 2009-02-24 03:18:29 UTC (rev 234) +++ trunk/Source/StructureMap/Container.cs 2009-04-19 18:40:49 UTC (rev 235) @@ -11,7 +11,6 @@ namespace StructureMap { - public class Container : TypeRules, IContainer { private InterceptorLibrary _interceptorLibrary; @@ -147,7 +146,8 @@ args.RegisterDefaults(session); - return forType(type).GetAllInstances(session); + var instances = session.CreateInstanceArray(type, null); + return new ArrayList(instances); } @@ -365,7 +365,8 @@ /// <returns></returns> public IList GetAllInstances(Type pluginType) { - return forType(pluginType).GetAllInstances(withNewSession(Plugin.DEFAULT)); + var instances = withNewSession(Plugin.DEFAULT).CreateInstanceArray(pluginType, null); + return new ArrayList(instances); } /// <summary> @@ -482,7 +483,7 @@ private IList<T> getListOfTypeWithSession<T>(BuildSession session) { var list = new List<T>(); - foreach (T instance in forType(typeof (T)).GetAllInstances(session)) + foreach (T instance in session.CreateInstanceArray(typeof(T), null)) { list.Add(instance); } @@ -505,12 +506,6 @@ return new BuildSession(_pipelineGraph, _interceptorLibrary){RequestedName = name}; } - - protected IInstanceFactory forType(Type type) - { - return _pipelineGraph.ForType(type); - } - /// <summary> /// Convenience method to request an object using an Open Generic /// Type and its parameter Types Added: trunk/Source/StructureMap/IContext.cs =================================================================== --- trunk/Source/StructureMap/IContext.cs (rev 0) +++ trunk/Source/StructureMap/IContext.cs 2009-04-19 18:40:49 UTC (rev 235) @@ -0,0 +1,67 @@ +using System; +using StructureMap.Pipeline; + +namespace StructureMap +{ + public interface IContext + { + /// <summary> + /// Gets a reference to the <see cref="BuildStack">BuildStack</see> for this build session + /// </summary> + BuildStack BuildStack { get; } + + /// <summary> + /// The concrete type of the immediate parent object in the object graph + /// </summary> + Type ParentType { get; } + + /// <summary> + /// Get the object of type T that is valid for this build session. + /// </summary> + /// <typeparam name="T"></typeparam> + /// <returns></returns> + T GetInstance<T>(); + + /// <summary> + /// Get the object of type T that is valid for this build session by name. + /// </summary> + /// <typeparam name="T"></typeparam> + /// <returns></returns> + T GetInstance<T>(string name); + + /// <summary> + /// Gets the root "frame" of the object request + /// </summary> + BuildFrame Root { get; } + + /// <summary> + /// The requested instance name of the object graph + /// </summary> + string RequestedName { get; } + + /// <summary> + /// Register a default object for the given PluginType that will + /// be used throughout the rest of the current object request + /// </summary> + /// <param name="pluginType"></param> + /// <param name="defaultObject"></param> + void RegisterDefault(Type pluginType, object defaultObject); + + /// <summary> + /// Same as GetInstance, but can gracefully return null if + /// the Type does not already exist + /// </summary> + /// <typeparam name="T"></typeparam> + /// <returns></returns> + T TryGetInstance<T>() where T : class; + + /// <summary> + /// Same as GetInstance(name), but can gracefully return null if + /// the Type and name does not already exist + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="name"></param> + /// <returns></returns> + T TryGetInstance<T>(string name) where T : class; + } +} \ No newline at end of file Modified: trunk/Source/StructureMap/IInstanceFactory.cs =================================================================== --- trunk/Source/StructureMap/IInstanceFactory.cs 2009-02-24 03:18:29 UTC (rev 234) +++ trunk/Source/StructureMap/IInstanceFactory.cs 2009-04-19 18:40:49 UTC (rev 235) @@ -16,15 +16,23 @@ IBuildPolicy Policy { get; } Instance MissingInstance { get; set; } + Instance[] AllInstances + { + get; + } + void AddInstance(Instance instance); Instance AddType<T>(); + [Obsolete("Return the list of Instances instead")] IList GetAllInstances(BuildSession session); + object Build(BuildSession session, Instance instance); Instance FindInstance(string name); - void ForEachInstance(Action<Instance> action); void ImportFrom(PluginFamily family); void EjectAllInstances(); + + } } \ No newline at end of file Modified: trunk/Source/StructureMap/InstanceCache.cs =================================================================== --- trunk/Source/StructureMap/InstanceCache.cs 2009-02-24 03:18:29 UTC (rev 234) +++ trunk/Source/StructureMap/InstanceCache.cs 2009-04-19 18:40:49 UTC (rev 235) @@ -39,6 +39,14 @@ public void Set(Type pluginType, Instance Instance, object result) { Dictionary<Instance, object> cache = getCache(pluginType); + + if (cache.ContainsKey(Instance)) + { + string message = string.Format("Duplicate Objects detected for Instance {0} of Type {1}", Instance.Name, + pluginType.AssemblyQualifiedName); + throw new ApplicationException(message); + + } cache.Add(Instance, result); } } Modified: trunk/Source/StructureMap/InstanceFactory.cs =================================================================== --- trunk/Source/StructureMap/InstanceFactory.cs 2009-02-24 03:18:29 UTC (rev 234) +++ trunk/Source/StructureMap/InstanceFactory.cs 2009-04-19 18:40:49 UTC (rev 235) @@ -87,16 +87,20 @@ get { return _instances.GetAll(); } } + public Instance[] AllInstances + { + get + { + return _instances.GetAll(); + } + } + public IBuildPolicy Policy { get { return _policy; } set { _policy = value; } } - public void ForEachInstance(Action<Instance> action) - { - _instances.Each(action); - } public void AddInstance(Instance instance) { Modified: trunk/Source/StructureMap/Pipeline/BuildFrame.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/BuildFrame.cs 2009-02-24 03:18:29 UTC (rev 234) +++ trunk/Source/StructureMap/Pipeline/BuildFrame.cs 2009-04-19 18:40:49 UTC (rev 235) @@ -115,5 +115,30 @@ return result; } } + + public bool Contains(BuildFrame frame) + { + if (_requestedType == frame._requestedType && _name == frame._name) + { + return true; + } + + return _next == null ? false : _next.Contains(frame); + } + + public string ToStackString() + { + string message = "\n1.) " + ToString(); + var next = _next; + + int i = 2; + while (next != null) + { + message += "\n{0}.) {1}".ToFormat(i++, next); + next = next._next; + } + + return message; + } } } \ No newline at end of file Modified: trunk/Source/StructureMap/Pipeline/BuildStack.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/BuildStack.cs 2009-02-24 03:18:29 UTC (rev 234) +++ trunk/Source/StructureMap/Pipeline/BuildStack.cs 2009-04-19 18:40:49 UTC (rev 235) @@ -1,3 +1,5 @@ +using System; + namespace StructureMap.Pipeline { /// <summary> @@ -45,6 +47,13 @@ } else { + if (_root.Contains(frame)) + { + + + throw new StructureMapException(295, frame.ToString(), _root.ToStackString()); + } + _current.Attach(frame); _current = frame; } Modified: trunk/Source/StructureMap/Pipeline/Instance.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/Instance.cs 2009-02-24 03:18:29 UTC (rev 234) +++ trunk/Source/StructureMap/Pipeline/Instance.cs 2009-04-19 18:40:49 UTC (rev 235) @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using StructureMap.Diagnostics; using StructureMap.Graph; using StructureMap.Interceptors; @@ -124,7 +125,8 @@ { if (!doesRecordOnTheStack) return; - session.BuildStack.Push(new BuildFrame(pluginType, Name, getConcreteType(pluginType))); + var frame = new BuildFrame(pluginType, Name, getConcreteType(pluginType)); + session.BuildStack.Push(frame); } private object createRawObject(Type pluginType, BuildSession session) Modified: trunk/Source/StructureMap/StructureMap.csproj =================================================================== --- trunk/Source/StructureMap/StructureMap.csproj 2009-02-24 03:18:29 UTC (rev 234) +++ trunk/Source/StructureMap/StructureMap.csproj 2009-04-19 18:40:49 UTC (rev 235) @@ -405,6 +405,7 @@ <Compile Include="Graph\ITypeScanner.cs" /> <Compile Include="Graph\PluggableAttributeScanner.cs" /> <Compile Include="Graph\PluginCache.cs" /> + <Compile Include="IContext.cs" /> <Compile Include="Pipeline\ConditionalInstance.cs" /> <Compile Include="Pipeline\HttpSessionBuildPolicy.cs" /> <Compile Include="Pipeline\SessionWrapper.cs" /> Modified: trunk/Source/StructureMap/StructureMapException.resx =================================================================== --- trunk/Source/StructureMap/StructureMapException.resx 2009-02-24 03:18:29 UTC (rev 234) +++ trunk/Source/StructureMap/StructureMapException.resx 2009-04-19 18:40:49 UTC (rev 235) @@ -271,4 +271,7 @@ <data name="290" xml:space="preserve"> <value>Could not load the designated Registry class '{0}'</value> </data> + <data name="295" xml:space="preserve"> + <value>Bidirectional Dependency Problem detected with {0}. The BuildStack is: {1}</value> + </data> </root> \ No newline at end of file Modified: trunk/Source/StructureMap/TypeExtensions.cs =================================================================== --- trunk/Source/StructureMap/TypeExtensions.cs 2009-02-24 03:18:29 UTC (rev 234) +++ trunk/Source/StructureMap/TypeExtensions.cs 2009-04-19 18:40:49 UTC (rev 235) @@ -72,6 +72,16 @@ return pluggedType.BaseType == typeof(object) ? null : pluggedType.BaseType.FindInterfaceThatCloses(templateType); } + public static bool IsNullable(this Type type) + { + return type.IsGenericType && type.GetGenericTypeDefinition() == typeof (Nullable<>); + } + + public static Type GetInnerTypeFromNullable(this Type nullableType) + { + return nullableType.GetGenericArguments()[0]; + } + public static string GetName(this Type type) { if (type.IsGenericType) Added: trunk/Source/StructureMap.Testing/BidirectionalDependencies.cs =================================================================== --- trunk/Source/StructureMap.Testing/BidirectionalDependencies.cs (rev 0) +++ trunk/Source/StructureMap.Testing/BidirectionalDependencies.cs 2009-04-19 18:40:49 UTC (rev 235) @@ -0,0 +1,68 @@ +using System; +using System.Diagnostics; +using NUnit.Framework; + +namespace StructureMap.Testing +{ + [TestFixture] public class BidirectionalDependencies + { + private Container container; + + [SetUp] public void SetUp() + { + container = new Container(x => + { + x.ForRequestedType<IBiView>().TheDefaultIsConcreteType<BiView>(); + x.ForRequestedType<IBiPresenter>().TheDefaultIsConcreteType<BiPresenter>(); + }); + } + + [Test] public void do_not_blow_up_with_a_stack_overflow_problem() + { + try + { + container.GetInstance<BiView>(); + Assert.Fail("Should have thrown error"); + } + catch (StructureMapException e) + { + Debug.WriteLine(e.ToString()); + e.ErrorCode.ShouldEqual(295); + } + } + } + + + public interface IBiView{} + public interface IBiPresenter{} + + public class BiView : IBiView + { + private readonly IBiPresenter _presenter; + + public BiView(IBiPresenter presenter) + { + _presenter = presenter; + } + + public IBiPresenter Presenter + { + get { return _presenter; } + } + } + + public class BiPresenter : IBiPresenter + { + private readonly IBiView _view; + + public BiPresenter(IBiView view) + { + _view = view; + } + + public IBiView View + { + get { return _view; } + } + } +} \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/Pipeline/BuildStackTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Pipeline/BuildStackTester.cs 2009-02-24 03:18:29 UTC (rev 234) +++ trunk/Source/StructureMap.Testing/Pipeline/BuildStackTester.cs 2009-04-19 18:40:49 UTC (rev 235) @@ -43,4 +43,26 @@ stack.Current.ShouldBeTheSameAs(root); } } + + [TestFixture] public class when_using_build_frame_contains + { + [SetUp] public void SetUp() + { + + } + + [Test] public void true_if_matching() + { + var frame1 = new BuildFrame(typeof (IWidget), "red", typeof (ColorWidget)); + var frame2 = new BuildFrame(typeof (IWidget), "red", typeof (ColorWidget)); + var frame3 = new BuildFrame(typeof (IWidget), "green", typeof (ColorWidget)); + + frame1.Contains(frame2).ShouldBeTrue(); + frame1.Contains(frame3).ShouldBeFalse(); + + frame3.Attach(frame2); + + frame3.Contains(frame1).ShouldBeTrue(); + } + } } \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/Pipeline/GenericsHelperExpressionTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Pipeline/GenericsHelperExpressionTester.cs 2009-02-24 03:18:29 UTC (rev 234) +++ trunk/Source/StructureMap.Testing/Pipeline/GenericsHelperExpressionTester.cs 2009-04-19 18:40:49 UTC (rev 235) @@ -1,3 +1,4 @@ +using System.Collections.Generic; using NUnit.Framework; namespace StructureMap.Testing.Pipeline @@ -182,6 +183,30 @@ } } + [TestFixture] + public class when_getting_all_closed_type_from_an_open_generic_type_by_providing_an_input_parameter + { + [Test] + public void fetch_the_objects() + { + var container = new Container(x => + { + x.ForRequestedType<IHandler<Shipment>>().TheDefaultIsConcreteType<ShipmentHandler>(); + x.ForRequestedType<IHandler<Shipment>>().AddConcreteType<ShipmentHandler2>(); + }); + + var shipment = new Shipment(); + + IList<IHandler> handlers = container + .ForObject(shipment) + .GetAllClosedTypesOf(typeof(IHandler<>)) + .As<IHandler>(); + + handlers[0].ShouldBeOfType<ShipmentHandler>(); + handlers[1].ShouldBeOfType<ShipmentHandler2>(); + } + } + public class Shipment { @@ -211,4 +236,19 @@ get { return _shipment; } } } + + public class ShipmentHandler2 : IHandler<Shipment> + { + private readonly Shipment _shipment; + + public ShipmentHandler2(Shipment shipment) + { + _shipment = shipment; + } + + public Shipment Shipment + { + get { return _shipment; } + } + } } \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj =================================================================== --- trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-02-24 03:18:29 UTC (rev 234) +++ trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-04-19 18:40:49 UTC (rev 235) @@ -177,6 +177,7 @@ <Compile Include="AutoMocking\RhinoAutoMockerTester.cs" /> <Compile Include="AutoMocking\RhinoMockRepositoryProxyTester.cs" /> <Compile Include="AutoWiringExamples.cs" /> + <Compile Include="BidirectionalDependencies.cs" /> <Compile Include="Bugs\BuildUpBug.cs" /> <Compile Include="Bugs\HttpSessionNullRefBug.cs" /> <Compile Include="Bugs\IDictionaryAndXmlBugTester.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fli...@us...> - 2009-02-24 03:18:32
|
Revision: 234 http://structuremap.svn.sourceforge.net/structuremap/?rev=234&view=rev Author: flimflan Date: 2009-02-24 03:18:29 +0000 (Tue, 24 Feb 2009) Log Message: ----------- Added LICENSE.TXT Added Paths: ----------- trunk/LICENSE.TXT Added: trunk/LICENSE.TXT =================================================================== --- trunk/LICENSE.TXT (rev 0) +++ trunk/LICENSE.TXT 2009-02-24 03:18:29 UTC (rev 234) @@ -0,0 +1,194 @@ +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 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2009-02-05 15:39:04
|
Revision: 233 http://structuremap.svn.sourceforge.net/structuremap/?rev=233&view=rev Author: jeremydmiller Date: 2009-02-05 15:38:53 +0000 (Thu, 05 Feb 2009) Log Message: ----------- picking up missed files, some extensions to the With() syntax Modified Paths: -------------- trunk/Source/CommonAssemblyInfo.cs trunk/Source/HTML/ScanningAssemblies.htm trunk/Source/StructureMap/Container.cs trunk/Source/StructureMap/ExplicitArgsExpression.cs trunk/Source/StructureMap/IContainer.cs trunk/Source/StructureMap/ObjectFactory.cs trunk/Source/StructureMap/Pipeline/ExplicitArguments.cs trunk/Source/StructureMap/StructureMap.csproj trunk/Source/StructureMap/TypeExtensions.cs trunk/Source/StructureMap.Testing/Graph/TestExplicitArguments.cs trunk/Source/StructureMap.Testing/Pipeline/GenericsHelperExpressionTester.cs trunk/Source/StructureMap.sln trunk/cruise.build Added Paths: ----------- trunk/Source/StructureMap/CloseGenericTypeExpression.cs trunk/Source/StructureMap.Prism/Properties/ trunk/Source/StructureMap.Prism/Properties/AssemblyInfo.cs trunk/Source/StructureMap.Prism/StructureMap.Prism.csproj trunk/Source/StructureMap.Testing.Prism/Properties/ trunk/Source/StructureMap.Testing.Prism/Properties/AssemblyInfo.cs trunk/Source/StructureMap.Testing.Prism/StructureMap.Testing.Prism.csproj trunk/bin/Prism/ trunk/bin/Prism/Prism1/ trunk/bin/Prism/Prism1/Microsoft.Practices.Composite.UnityExtensions.dll trunk/bin/Prism/Prism1/Microsoft.Practices.Composite.UnityExtensions.pdb trunk/bin/Prism/Prism1/Microsoft.Practices.Composite.UnityExtensions.xml trunk/bin/Prism/Prism1/Microsoft.Practices.Composite.Wpf.dll trunk/bin/Prism/Prism1/Microsoft.Practices.Composite.Wpf.pdb trunk/bin/Prism/Prism1/Microsoft.Practices.Composite.Wpf.xml trunk/bin/Prism/Prism1/Microsoft.Practices.Composite.dll trunk/bin/Prism/Prism1/Microsoft.Practices.Composite.pdb trunk/bin/Prism/Prism1/Microsoft.Practices.Composite.xml trunk/bin/Prism/Prism1/Microsoft.Practices.EnterpriseLibrary.Common.dll trunk/bin/Prism/Prism1/Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.Logging.dll trunk/bin/Prism/Prism1/Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll trunk/bin/Prism/Prism1/Microsoft.Practices.EnterpriseLibrary.Logging.dll Modified: trunk/Source/CommonAssemblyInfo.cs =================================================================== --- trunk/Source/CommonAssemblyInfo.cs 2009-02-01 20:03:18 UTC (rev 232) +++ trunk/Source/CommonAssemblyInfo.cs 2009-02-05 15:38:53 UTC (rev 233) @@ -13,11 +13,11 @@ //------------------------------------------------------------------------------ [assembly: ComVisibleAttribute(false)] -[assembly: AssemblyVersionAttribute("2.5.3.0000")] +[assembly: AssemblyVersionAttribute("2.5.4.0000")] [assembly: AssemblyCopyrightAttribute("Copyright (c) 2003-2008, Jeremy D. Miller")] [assembly: AssemblyProductAttribute("StructureMap")] [assembly: AssemblyCompanyAttribute("")] [assembly: AssemblyConfigurationAttribute("release")] -[assembly: AssemblyInformationalVersionAttribute("2.5.3.0000")] -[assembly: AssemblyFileVersionAttribute("2.5.3.0000")] +[assembly: AssemblyInformationalVersionAttribute("2.5.4.0000")] +[assembly: AssemblyFileVersionAttribute("2.5.4.0000")] Modified: trunk/Source/HTML/ScanningAssemblies.htm =================================================================== --- trunk/Source/HTML/ScanningAssemblies.htm 2009-02-01 20:03:18 UTC (rev 232) +++ trunk/Source/HTML/ScanningAssemblies.htm 2009-02-05 15:38:53 UTC (rev 233) @@ -1148,7 +1148,7 @@ <p style="margin: 0px;"> }</p> <p style="margin: 0px;"> -& }</p> + }</p> </div> <!--EndFragment--> <p>You apply the custom ITypeScanner by simply calling With() inside of a Scan() Added: trunk/Source/StructureMap/CloseGenericTypeExpression.cs =================================================================== --- trunk/Source/StructureMap/CloseGenericTypeExpression.cs (rev 0) +++ trunk/Source/StructureMap/CloseGenericTypeExpression.cs 2009-02-05 15:38:53 UTC (rev 233) @@ -0,0 +1,48 @@ +using System; + +namespace StructureMap +{ + public interface OpenGenericTypeSpecificationExpression + { + T As<T>(); + } + + public class CloseGenericTypeExpression : OpenGenericTypeSpecificationExpression + { + private readonly object _subject; + private readonly IContainer _container; + private Type _pluginType; + + public CloseGenericTypeExpression(object subject, IContainer container) + { + _subject = subject; + _container = container; + } + + /// <summary> + /// Specify the open generic type that should have a single generic parameter + /// </summary> + /// <param name="type"></param> + /// <returns></returns> + public OpenGenericTypeSpecificationExpression GetClosedTypeOf(Type type) + { + if (!type.IsGeneric()) + { + throw new StructureMapException(285); + } + + _pluginType = type.MakeGenericType(_subject.GetType()); + return this; + } + + /// <summary> + /// specify what type you'd like the service returned as + /// </summary> + /// <typeparam name="T"></typeparam> + /// <returns></returns> + T OpenGenericTypeSpecificationExpression.As<T>() + { + return (T) _container.With(_subject.GetType(), _subject).GetInstance(_pluginType); + } + } +} \ No newline at end of file Modified: trunk/Source/StructureMap/Container.cs =================================================================== --- trunk/Source/StructureMap/Container.cs 2009-02-01 20:03:18 UTC (rev 232) +++ trunk/Source/StructureMap/Container.cs 2009-02-05 15:38:53 UTC (rev 233) @@ -411,6 +411,18 @@ } /// <summary> + /// Starts a request for an instance or instances with explicitly configured arguments. Specifies that any dependency + /// of type T should be "arg" + /// </summary> + /// <param name="pluginType"></param> + /// <param name="arg"></param> + /// <returns></returns> + public ExplicitArgsExpression With(Type pluginType, object arg) + { + return new ExplicitArgsExpression(this).With(pluginType, arg); + } + + /// <summary> /// Starts a request for an instance or instances with explicitly configured arguments. Specifies that any dependency or primitive argument /// with the designated name should be the next value. /// </summary> @@ -549,5 +561,23 @@ { T GetInstanceAs<T>(); } + + /// <summary> + /// Shortcut syntax for using an object to find a service that handles + /// that type of object by using an open generic type + /// </summary> + /// <example> + /// IHandler handler = container.ForObject(shipment) + /// .GetClosedTypeOf(typeof (IHandler<>)) + /// .As<IHandler>(); + /// </example> + /// <param name="subject"></param> + /// <returns></returns> + public CloseGenericTypeExpression ForObject(object subject) + { + return new CloseGenericTypeExpression(subject, this); + } } + + } \ No newline at end of file Modified: trunk/Source/StructureMap/ExplicitArgsExpression.cs =================================================================== --- trunk/Source/StructureMap/ExplicitArgsExpression.cs 2009-02-01 20:03:18 UTC (rev 232) +++ trunk/Source/StructureMap/ExplicitArgsExpression.cs 2009-02-05 15:38:53 UTC (rev 233) @@ -49,6 +49,18 @@ } /// <summary> + /// Pass in additional arguments by type + /// </summary> + /// <typeparam name="T"></typeparam> + /// <param name="arg"></param> + /// <returns></returns> + public ExplicitArgsExpression With(Type pluginType, object arg) + { + _args.Set(pluginType, arg); + return this; + } + + /// <summary> /// Pass in additional arguments by name /// </summary> /// <param name="argName"></param> Modified: trunk/Source/StructureMap/IContainer.cs =================================================================== --- trunk/Source/StructureMap/IContainer.cs 2009-02-01 20:03:18 UTC (rev 232) +++ trunk/Source/StructureMap/IContainer.cs 2009-02-05 15:38:53 UTC (rev 233) @@ -246,5 +246,27 @@ /// <param name="name"></param> /// <returns></returns> T GetInstance<T>(ExplicitArguments args, string name); + + /// <summary> + /// Starts a request for an instance or instances with explicitly configured arguments. Specifies that any dependency + /// of type T should be "arg" + /// </summary> + /// <param name="pluginType"></param> + /// <param name="arg"></param> + /// <returns></returns> + ExplicitArgsExpression With(Type pluginType, object arg); + + /// <summary> + /// Shortcut syntax for using an object to find a service that handles + /// that type of object by using an open generic type + /// </summary> + /// <example> + /// IHandler handler = container.ForObject(shipment) + /// .GetClosedTypeOf(typeof (IHandler<>)) + /// .As<IHandler>(); + /// </example> + /// <param name="subject"></param> + /// <returns></returns> + CloseGenericTypeExpression ForObject(object subject); } } \ No newline at end of file Modified: trunk/Source/StructureMap/ObjectFactory.cs =================================================================== --- trunk/Source/StructureMap/ObjectFactory.cs 2009-02-01 20:03:18 UTC (rev 232) +++ trunk/Source/StructureMap/ObjectFactory.cs 2009-02-05 15:38:53 UTC (rev 233) @@ -257,6 +257,18 @@ } /// <summary> + /// Starts a request for an instance or instances with explicitly configured arguments. Specifies that any dependency + /// of type T should be "arg" + /// </summary> + /// <param name="pluginType"></param> + /// <param name="arg"></param> + /// <returns></returns> + public static ExplicitArgsExpression With(Type pluginType, object arg) + { + return container.With(pluginType, arg); + } + + /// <summary> /// Removes all configured instances of type T from the Container. Use with caution! /// </summary> /// <typeparam name="T"></typeparam> @@ -438,5 +450,22 @@ return container.ForGenericType(templateType); } + + /// <summary> + /// Shortcut syntax for using an object to find a service that handles + /// that type of object by using an open generic type + /// </summary> + /// <example> + /// IHandler handler = container.ForObject(shipment) + /// .GetClosedTypeOf(typeof (IHandler<>)) + /// .As<IHandler>(); + /// </example> + /// <param name="subject"></param> + /// <returns></returns> + public static CloseGenericTypeExpression ForObject(object subject) + { + return container.ForObject(subject); + } + } } \ No newline at end of file Modified: trunk/Source/StructureMap/Pipeline/ExplicitArguments.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/ExplicitArguments.cs 2009-02-01 20:03:18 UTC (rev 232) +++ trunk/Source/StructureMap/Pipeline/ExplicitArguments.cs 2009-02-05 15:38:53 UTC (rev 233) @@ -29,9 +29,14 @@ public void Set<T>(T arg) { - _children.Add(typeof (T), arg); + Set(typeof (T), arg); } + public void Set(Type pluginType, object arg) + { + _children.Add(pluginType, arg); + } + public void SetArg(string key, object argValue) { _args.Add(key, argValue); Modified: trunk/Source/StructureMap/StructureMap.csproj =================================================================== --- trunk/Source/StructureMap/StructureMap.csproj 2009-02-01 20:03:18 UTC (rev 232) +++ trunk/Source/StructureMap/StructureMap.csproj 2009-02-05 15:38:53 UTC (rev 233) @@ -56,7 +56,7 @@ <DebugSymbols>true</DebugSymbols> <FileAlignment>4096</FileAlignment> <NoStdLib>false</NoStdLib> - <NoWarn>618,1591</NoWarn> + <NoWarn>618,1591,1573,1711,1570</NoWarn> <Optimize>false</Optimize> <RegisterForComInterop>false</RegisterForComInterop> <RemoveIntegerChecks>false</RemoveIntegerChecks> @@ -77,7 +77,7 @@ <DebugSymbols>true</DebugSymbols> <FileAlignment>4096</FileAlignment> <NoStdLib>false</NoStdLib> - <NoWarn>618,1591</NoWarn> + <NoWarn>618,1591,1573,1711,1570</NoWarn> <Optimize>true</Optimize> <RegisterForComInterop>false</RegisterForComInterop> <RemoveIntegerChecks>false</RemoveIntegerChecks> @@ -381,6 +381,7 @@ <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\Expressions\InstanceExpression.cs" /> Modified: trunk/Source/StructureMap/TypeExtensions.cs =================================================================== --- trunk/Source/StructureMap/TypeExtensions.cs 2009-02-01 20:03:18 UTC (rev 232) +++ trunk/Source/StructureMap/TypeExtensions.cs 2009-02-05 15:38:53 UTC (rev 233) @@ -69,7 +69,7 @@ } } - return null; + return pluggedType.BaseType == typeof(object) ? null : pluggedType.BaseType.FindInterfaceThatCloses(templateType); } public static string GetName(this Type type) Added: trunk/Source/StructureMap.Prism/Properties/AssemblyInfo.cs =================================================================== --- trunk/Source/StructureMap.Prism/Properties/AssemblyInfo.cs (rev 0) +++ trunk/Source/StructureMap.Prism/Properties/AssemblyInfo.cs 2009-02-05 15:38:53 UTC (rev 233) @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("StructureMap.Prism")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("StructureMap.Prism")] +[assembly: AssemblyCopyright("Copyright © 2009")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("2b71f182-5fdb-4df8-913e-76c95445fd1f")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] Added: trunk/Source/StructureMap.Prism/StructureMap.Prism.csproj =================================================================== --- trunk/Source/StructureMap.Prism/StructureMap.Prism.csproj (rev 0) +++ trunk/Source/StructureMap.Prism/StructureMap.Prism.csproj 2009-02-05 15:38:53 UTC (rev 233) @@ -0,0 +1,80 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>9.0.30729</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{150CACB1-7F59-4C68-8830-F277E0E98A3F}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>StructureMap.Prism</RootNamespace> + <AssemblyName>StructureMap.Prism</AssemblyName> + <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <SignAssembly>false</SignAssembly> + <AssemblyOriginatorKeyFile>structuremap.snk</AssemblyOriginatorKeyFile> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="Microsoft.Practices.Composite, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\bin\Prism\Prism1\Microsoft.Practices.Composite.dll</HintPath> + </Reference> + <Reference Include="Microsoft.Practices.Composite.Wpf, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\bin\Prism\Prism1\Microsoft.Practices.Composite.Wpf.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Core"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Xml.Linq"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data.DataSetExtensions"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="DefaultRegistry.cs" /> + <Compile Include="PrismBootstrapper.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="StructureMapContainerFacade.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="structuremap.snk" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\StructureMap\StructureMap.csproj"> + <Project>{3F36EA80-2F9A-4DAD-BA27-5AC6163A2EE3}</Project> + <Name>StructureMap</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/Graph/TestExplicitArguments.cs =================================================================== --- trunk/Source/StructureMap.Testing/Graph/TestExplicitArguments.cs 2009-02-01 20:03:18 UTC (rev 232) +++ trunk/Source/StructureMap.Testing/Graph/TestExplicitArguments.cs 2009-02-05 15:38:53 UTC (rev 233) @@ -179,6 +179,53 @@ } [Test] + public void Fill_in_argument_by_type() + { + var container = new Container(x => + { + x.ForRequestedType<IView>().TheDefaultIsConcreteType<View>(); + }); + + var theNode = new SpecialNode(); + var theTrade = new Trade(); + + var command = container + .With(typeof(Node), theNode) + .With(theTrade) + .GetInstance<Command>(); + + Assert.IsInstanceOfType(typeof(View), command.View); + Assert.AreSame(theNode, command.Node); + Assert.AreSame(theTrade, command.Trade); + } + + [Test] + public void Fill_in_argument_by_type_with_ObjectFactory() + { + ObjectFactory.Initialize(x => + { + x.ForRequestedType<IView>().TheDefaultIsConcreteType<View>(); + }); + + var theNode = new SpecialNode(); + var theTrade = new Trade(); + + var command = ObjectFactory + .With(typeof(Node), theNode) + .With(theTrade) + .GetInstance<Command>(); + + Assert.IsInstanceOfType(typeof(View), command.View); + Assert.AreSame(theNode, command.Node); + Assert.AreSame(theTrade, command.Trade); + } + + public class SpecialNode : Node + { + + } + + [Test] public void NowDoItWithObjectFactoryItself() { ObjectFactory.Initialize(x => Modified: trunk/Source/StructureMap.Testing/Pipeline/GenericsHelperExpressionTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Pipeline/GenericsHelperExpressionTester.cs 2009-02-01 20:03:18 UTC (rev 232) +++ trunk/Source/StructureMap.Testing/Pipeline/GenericsHelperExpressionTester.cs 2009-02-05 15:38:53 UTC (rev 233) @@ -140,4 +140,75 @@ return null; } } + + + [TestFixture] + public class when_getting_a_closed_type_from_an_open_generic_type_by_providing_an_input_parameter + { + [Test] + public void fetch_the_object() + { + var container = new Container(x => + { + x.ForRequestedType<IHandler<Shipment>>().TheDefaultIsConcreteType<ShipmentHandler>(); + }); + + var shipment = new Shipment(); + + IHandler handler = container + .ForObject(shipment) + .GetClosedTypeOf(typeof (IHandler<>)) + .As<IHandler>(); + + handler.ShouldBeOfType<ShipmentHandler>().Shipment.ShouldBeTheSameAs(shipment); + } + } + + [TestFixture] + public class when_getting_a_closed_type_from_an_open_generic_type_by_providing_an_input_parameter_from_ObjectFactory + { + [Test] + public void fetch_the_object() + { + ObjectFactory.Initialize(x => + { + x.ForRequestedType<IHandler<Shipment>>().TheDefaultIsConcreteType<ShipmentHandler>(); + }); + + var shipment = new Shipment(); + IHandler handler = ObjectFactory.ForObject(shipment).GetClosedTypeOf(typeof(IHandler<>)).As<IHandler>(); + + handler.ShouldBeOfType<ShipmentHandler>().Shipment.ShouldBeTheSameAs(shipment); + } + } + + public class Shipment + { + + } + + public interface IHandler<T> : IHandler + { + + } + + public interface IHandler + { + + } + + public class ShipmentHandler : IHandler<Shipment> + { + private readonly Shipment _shipment; + + public ShipmentHandler(Shipment shipment) + { + _shipment = shipment; + } + + public Shipment Shipment + { + get { return _shipment; } + } + } } \ No newline at end of file Added: trunk/Source/StructureMap.Testing.Prism/Properties/AssemblyInfo.cs =================================================================== --- trunk/Source/StructureMap.Testing.Prism/Properties/AssemblyInfo.cs (rev 0) +++ trunk/Source/StructureMap.Testing.Prism/Properties/AssemblyInfo.cs 2009-02-05 15:38:53 UTC (rev 233) @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("StructureMap.Testing.Prism")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("StructureMap.Testing.Prism")] +[assembly: AssemblyCopyright("Copyright © 2009")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("f0176eaa-10fe-453d-abe0-2fb3df709cde")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] Added: trunk/Source/StructureMap.Testing.Prism/StructureMap.Testing.Prism.csproj =================================================================== --- trunk/Source/StructureMap.Testing.Prism/StructureMap.Testing.Prism.csproj (rev 0) +++ trunk/Source/StructureMap.Testing.Prism/StructureMap.Testing.Prism.csproj 2009-02-05 15:38:53 UTC (rev 233) @@ -0,0 +1,86 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>9.0.30729</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{7F72EFA9-B575-462A-855F-132F8DBC6E9D}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>StructureMap.Testing.Prism</RootNamespace> + <AssemblyName>StructureMap.Testing.Prism</AssemblyName> + <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="Microsoft.Practices.Composite, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\bin\Prism\Prism1\Microsoft.Practices.Composite.dll</HintPath> + </Reference> + <Reference Include="Microsoft.Practices.Composite.Wpf, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\bin\Prism\Prism1\Microsoft.Practices.Composite.Wpf.dll</HintPath> + </Reference> + <Reference Include="nunit.framework, Version=2.4.0.2, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\bin\NUnit\nunit.framework.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Core"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Xml.Linq"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data.DataSetExtensions"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="DefaultRegistryTester.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + <Compile Include="StructureMapContainerFacadeTester.cs" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\StructureMap.Prism\StructureMap.Prism.csproj"> + <Project>{150CACB1-7F59-4C68-8830-F277E0E98A3F}</Project> + <Name>StructureMap.Prism</Name> + </ProjectReference> + <ProjectReference Include="..\StructureMap.Testing\StructureMap.Testing.csproj"> + <Project>{63C2742D-B6E2-484F-AFDB-346873075C5E}</Project> + <Name>StructureMap.Testing</Name> + </ProjectReference> + <ProjectReference Include="..\StructureMap\StructureMap.csproj"> + <Project>{3F36EA80-2F9A-4DAD-BA27-5AC6163A2EE3}</Project> + <Name>StructureMap</Name> + </ProjectReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file Modified: trunk/Source/StructureMap.sln =================================================================== --- trunk/Source/StructureMap.sln 2009-02-01 20:03:18 UTC (rev 232) +++ trunk/Source/StructureMap.sln 2009-02-05 15:38:53 UTC (rev 233) @@ -57,10 +57,6 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TableOfContentsBuilder", "TableOfContentsBuilder\TableOfContentsBuilder.csproj", "{8A9EAE91-F3F5-4919-86FC-6D98D00FC77F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureMap.Prism", "StructureMap.Prism\StructureMap.Prism.csproj", "{150CACB1-7F59-4C68-8830-F277E0E98A3F}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureMap.Testing.Prism", "StructureMap.Testing.Prism\StructureMap.Testing.Prism.csproj", "{7F72EFA9-B575-462A-855F-132F8DBC6E9D}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Build|.NET = Build|.NET @@ -296,36 +292,6 @@ {8A9EAE91-F3F5-4919-86FC-6D98D00FC77F}.Release|Any CPU.Build.0 = Release|Any CPU {8A9EAE91-F3F5-4919-86FC-6D98D00FC77F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {8A9EAE91-F3F5-4919-86FC-6D98D00FC77F}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Build|.NET.ActiveCfg = Release|Any CPU - {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Build|Any CPU.ActiveCfg = Release|Any CPU - {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Build|Any CPU.Build.0 = Release|Any CPU - {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Build|Mixed Platforms.ActiveCfg = Release|Any CPU - {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Build|Mixed Platforms.Build.0 = Release|Any CPU - {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Debug|.NET.ActiveCfg = Debug|Any CPU - {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Release|.NET.ActiveCfg = Release|Any CPU - {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Release|Any CPU.Build.0 = Release|Any CPU - {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Release|Mixed Platforms.Build.0 = Release|Any CPU - {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Build|.NET.ActiveCfg = Release|Any CPU - {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Build|Any CPU.ActiveCfg = Release|Any CPU - {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Build|Any CPU.Build.0 = Release|Any CPU - {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Build|Mixed Platforms.ActiveCfg = Release|Any CPU - {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Build|Mixed Platforms.Build.0 = Release|Any CPU - {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Debug|.NET.ActiveCfg = Debug|Any CPU - {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU - {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU - {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Release|.NET.ActiveCfg = Release|Any CPU - {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Release|Any CPU.Build.0 = Release|Any CPU - {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU - {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Release|Mixed Platforms.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE Added: trunk/bin/Prism/Prism1/Microsoft.Practices.Composite.UnityExtensions.dll =================================================================== (Binary files differ) Property changes on: trunk/bin/Prism/Prism1/Microsoft.Practices.Composite.UnityExtensions.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/bin/Prism/Prism1/Microsoft.Practices.Composite.UnityExtensions.pdb =================================================================== (Binary files differ) Property changes on: trunk/bin/Prism/Prism1/Microsoft.Practices.Composite.UnityExtensions.pdb ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/bin/Prism/Prism1/Microsoft.Practices.Composite.UnityExtensions.xml =================================================================== --- trunk/bin/Prism/Prism1/Microsoft.Practices.Composite.UnityExtensions.xml (rev 0) +++ trunk/bin/Prism/Prism1/Microsoft.Practices.Composite.UnityExtensions.xml 2009-02-05 15:38:53 UTC (rev 233) @@ -0,0 +1,230 @@ +<?xml version="1.0"?> +<doc> + <assembly> + <name>Microsoft.Practices.Composite.UnityExtensions</name> + </assembly> + <members> + <member name="T:Microsoft.Practices.Composite.UnityExtensions.Properties.Resources"> + <summary> + A strongly-typed resource class, for looking up localized strings, etc. + </summary> + </member> + <member name="P:Microsoft.Practices.Composite.UnityExtensions.Properties.Resources.ResourceManager"> + <summary> + Returns the cached ResourceManager instance used by this class. + </summary> + </member> + <member name="P:Microsoft.Practices.Composite.UnityExtensions.Properties.Resources.Culture"> + <summary> + Overrides the current thread's CurrentUICulture property for all + resource lookups using this strongly typed resource class. + </summary> + </member> + <member name="P:Microsoft.Practices.Composite.UnityExtensions.Properties.Resources.NotOverwrittenGetModuleEnumeratorException"> + <summary> + Looks up a localized string similar to The method 'GetModuleEnumerator' of the bootstrapper must be overwritten in order to use the default module initialization logic.. + </summary> + </member> + <member name="P:Microsoft.Practices.Composite.UnityExtensions.Properties.Resources.NullLoggerFacadeException"> + <summary> + Looks up a localized string similar to The ILoggerFacade is required and cannot be null.. + </summary> + </member> + <member name="P:Microsoft.Practices.Composite.UnityExtensions.Properties.Resources.NullModuleEnumeratorException"> + <summary> + Looks up a localized string similar to The IModuleEnumerator is required and cannot be null in order to initialize the modules.. + </summary> + </member> + <member name="P:Microsoft.Practices.Composite.UnityExtensions.Properties.Resources.NullModuleLoaderException"> + <summary> + Looks up a localized string similar to The IModuleLoader is required and cannot be null in order to initialize the modules.. + </summary> + </member> + <member name="P:Microsoft.Practices.Composite.UnityExtensions.Properties.Resources.NullUnityContainerException"> + <summary> + Looks up a localized string similar to The IUnityContainer is required and cannot be null.. + </summary> + </member> + <member name="P:Microsoft.Practices.Composite.UnityExtensions.Properties.Resources.TypeMappingAlreadyRegistered"> + <summary> + Looks up a localized string similar to Type '{0}' was already registered by the application. Skipping.... + </summary> + </member> + <member name="T:Microsoft.Practices.Composite.UnityExtensions.UnityContainerHelper"> + <summary> + Extensions methods to extend and facilitate the usage of <see cref="T:Microsoft.Practices.Unity.IUnityContainer"/>. + </summary> + </member> + <member name="M:Microsoft.Practices.Composite.UnityExtensions.UnityContainerHelper.IsTypeRegistered(Microsoft.Practices.Unity.IUnityContainer,System.Type)"> + <summary> + Returns whether a specified type has a type mapping registered in the container. + </summary> + <param name="container">The <see cref="T:Microsoft.Practices.Unity.IUnityContainer"/> to check for the type mapping.</param> + <param name="type">The type to check if there is a type mapping for.</param> + <returns><see langword="true"/> if there is a type mapping registered for <paramref name="type"/>.</returns> + <remarks>In order to use this extension method, you first need to add the + <see cref="T:Microsoft.Practices.Unity.IUnityContainer"/> extension to the <see cref="T:Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapperExtension"/>. + </remarks> + </member> + <member name="M:Microsoft.Practices.Composite.UnityExtensions.UnityContainerHelper.TryResolve``1(Microsoft.Practices.Unity.IUnityContainer)"> + <summary> + Utility method to try to resolve a service from the container avoiding an exception if the container cannot build the type. + </summary> + <param name="container">The cointainer that will be used to resolve the type.</param> + <typeparam name="T">The type to resolve.</typeparam> + <returns>The instance of <typeparamref name="T"/> built up by the container.</returns> + </member> + <member name="M:Microsoft.Practices.Composite.UnityExtensions.UnityContainerHelper.TryResolve(Microsoft.Practices.Unity.IUnityContainer,System.Type)"> + <summary> + Utility method to try to resolve a service from the container avoiding an exception if the container cannot build the type. + </summary> + <param name="container">The cointainer that will be used to resolve the type.</param> + <param name="typeToResolve">The type to resolve.</param> + <returns>The instance of <paramref name="typeToResolve"/> built up by the container.</returns> + </member> + <member name="T:Microsoft.Practices.Composite.UnityExtensions.UnityContainerAdapter"> + <summary> + Defines a <seealso cref="T:Microsoft.Practices.Unity.IUnityContainer"/> adapter for + the <see cref="T:Microsoft.Practices.Composite.IContainerFacade"/> interface + to be used by the Composite Application Library. + </summary> + </member> + <member name="M:Microsoft.Practices.Composite.UnityExtensions.UnityContainerAdapter.#ctor(Microsoft.Practices.Unity.IUnityContainer)"> + <summary> + Initializes a new instance of <see cref="T:Microsoft.Practices.Composite.UnityExtensions.UnityContainerAdapter"/>. + </summary> + <param name="unityContainer">The <seealso cref="T:Microsoft.Practices.Unity.IUnityContainer"/> that will be used + by the <see cref="M:Microsoft.Practices.Composite.UnityExtensions.UnityContainerAdapter.Resolve(System.Type)"/> and <see cref="M:Microsoft.Practices.Composite.UnityExtensions.UnityContainerAdapter.TryResolve(System.Type)"/> methods.</param> + </member> + <member name="M:Microsoft.Practices.Composite.UnityExtensions.UnityContainerAdapter.Resolve(System.Type)"> + <summary> + Resolve an instance of the requested type from the container. + </summary> + <param name="type">The type of object to get from the container.</param> + <returns>An instance of <paramref name="type"/>.</returns> + <exception cref="T:Microsoft.Practices.Unity.ResolutionFailedException"><paramref name="type"/> cannot be resolved by the container.</exception> + </member> + <member name="M:Microsoft.Practices.Composite.UnityExtensions.UnityContainerAdapter.TryResolve(System.Type)"> + <summary> + Tries to resolve an instance of the requested type from the container. + </summary> + <param name="type">The type of object to get from the container.</param> + <returns> + An instance of <paramref name="type"/>. + If the type cannot be resolved it will return a <see langword="null"/> value. + </returns> + </member> + <member name="T:Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper"> + <summary> + Base class that provides a basic bootstrapping sequence that + registers most of the Composite Application Library assets + in a <see cref="T:Microsoft.Practices.Unity.IUnityContainer"/>. + </summary> + <remarks> + This class must be overriden to provide application specific configuration. + </remarks> + </member> + <member name="M:Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.Run"> + <summary> + Runs the bootstrapper process. + </summary> + </member> + <member name="M:Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.Run(System.Boolean)"> + <summary> + Run the bootstrapper process. + </summary> + <param name="useDefaultConfiguration">If <see langword="true"/>, registers default Composite Application Library services in the container. This is the default behavior.</param> + </member> + <member name="M:Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.ConfigureContainer"> + <summary> + Configures the <see cref="T:Microsoft.Practices.Unity.IUnityContainer"/>. May be overwritten in a derived class to add specific + type mappings required by the application. + </summary> + </member> + <member name="M:Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.ConfigureRegionAdapterMappings"> + <summary> + Configures the default region adapter mappings to use in the application, in order + to adapt UI controls defined in XAML to use a region and register it automatically. + May be overwritten in a derived class to add specific mappings required by the application. + </summary> + <returns>The <see cref="T:Microsoft.Practices.Composite.Wpf.Regions.RegionAdapterMappings"/> instance containing all the mappings.</returns> + </member> + <member name="M:Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.InitializeModules"> + <summary> + Initializes the modules. May be overwritten in a derived class to use custom + module loading and avoid using an <seealso cref="T:Microsoft.Practices.Composite.Modularity.IModuleLoader"/> and + <seealso cref="T:Microsoft.Practices.Composite.Modularity.IModuleEnumerator"/>. + </summary> + </member> + <member name="M:Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.CreateContainer"> + <summary> + Creates the <see cref="T:Microsoft.Practices.Unity.IUnityContainer"/> that will be used as the default container. + </summary> + <returns>A new instance of <see cref="T:Microsoft.Practices.Unity.IUnityContainer"/>.</returns> + </member> + <member name="M:Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.GetModuleEnumerator"> + <summary> + Returns the module enumerator that will be used to initialize the modules. + </summary> + <remarks> + When using the default initialization behavior, this method must be overwritten by a derived class. + </remarks> + <returns>An instance of <see cref="T:Microsoft.Practices.Composite.Modularity.IModuleEnumerator"/> that will be used to initialize the modules.</returns> + </member> + <member name="M:Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.RegisterTypeIfMissing(System.Type,System.Type,System.Boolean)"> + <summary> + Registers a type in the container only if that type was not already registered. + </summary> + <param name="fromType">The interface type to register.</param> + <param name="toType">The type implementing the interface.</param> + <param name="registerAsSingleton">Registers the type as a singleton.</param> + </member> + <member name="M:Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.CreateShell"> + <summary> + Creates the shell or main window of the application. + </summary> + <returns>The shell of the application.</returns> + <remarks> + If the returned instance is a <see cref="T:System.Windows.DependencyObject"/>, the + <see cref="T:Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper"/> will attach the default <seealso cref="T:Microsoft.Practices.Composite.Regions.IRegionManager"/> of + the application in its <see cref="F:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.RegionManagerProperty"/> attached property + in order to be able to add regions by using the <seealso cref="F:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.RegionNameProperty"/> + attached property from XAML. + </remarks> + </member> + <member name="P:Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.Container"> + <summary> + Gets the default <see cref="T:Microsoft.Practices.Unity.IUnityContainer"/> for the application. + </summary> + <value>The default <see cref="T:Microsoft.Practices.Unity.IUnityContainer"/> instance.</value> + </member> + <member name="P:Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapper.LoggerFacade"> + <summary> + Gets the default <see cref="T:Microsoft.Practices.Composite.Logging.ILoggerFacade"/> for the application. + </summary> + <value>A <see cref="T:Microsoft.Practices.Composite.Logging.ILoggerFacade"/> instance.</value> + </member> + <member name="T:Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapperExtension"> + <summary> + Implements a <see cref="T:Microsoft.Practices.Unity.UnityContainerExtension"/> that checks if a specific type was registered with the container. + </summary> + </member> + <member name="M:Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapperExtension.IsTypeRegistered(Microsoft.Practices.Unity.IUnityContainer,System.Type)"> + <summary> + Evaluates if a specified type was registered in the container. + </summary> + <param name="container">The container to check if the type was registered in.</param> + <param name="type">The type to check if it was registered.</param> + <returns><see langword="true"/> if the <paramref name="type"/> was registered with the container.</returns> + <remarks> + In order to use this extension, you must first call <see cref="M:Microsoft.Practices.Unity.IUnityContainer.AddNewExtension``1"/> + and specify <see cref="T:Microsoft.Practices.Unity.UnityContainerExtension"/> as the extension type. + </remarks> + </member> + <member name="M:Microsoft.Practices.Composite.UnityExtensions.UnityBootstrapperExtension.Initialize"> + <summary> + Initializes the container with this extension's functionality. + </summary> + </member> + </members> +</doc> Added: trunk/bin/Prism/Prism1/Microsoft.Practices.Composite.Wpf.dll =================================================================== (Binary files differ) Property changes on: trunk/bin/Prism/Prism1/Microsoft.Practices.Composite.Wpf.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/bin/Prism/Prism1/Microsoft.Practices.Composite.Wpf.pdb =================================================================== (Binary files differ) Property changes on: trunk/bin/Prism/Prism1/Microsoft.Practices.Composite.Wpf.pdb ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/bin/Prism/Prism1/Microsoft.Practices.Composite.Wpf.xml =================================================================== --- trunk/bin/Prism/Prism1/Microsoft.Practices.Composite.Wpf.xml (rev 0) +++ trunk/bin/Prism/Prism1/Microsoft.Practices.Composite.Wpf.xml 2009-02-05 15:38:53 UTC (rev 233) @@ -0,0 +1,881 @@ +<?xml version="1.0"?> +<doc> + <assembly> + <name>Microsoft.Practices.Composite.Wpf</name> + </assembly> + <members> + <member name="T:Microsoft.Practices.Composite.Wpf.Regions.RegionManager"> + <summary> + This class is responsible for maintaining a collection of regions and attaching regions to controls. + </summary> + <remarks> + This class supplies the attached properties that can be used for simple region creation from XAML. + It finds an adapter mapped to a WPF control and associates a new region to that control by calling + <see cref="M:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.AttachNewRegion(System.Object,System.String)"/> automatically. + </remarks> + </member> + <member name="F:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.RegionNameProperty"> + <summary> + Identifies the RegionName attached property. + </summary> + <remarks> + When a control has both the <see cref="F:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.RegionNameProperty"/> and + <see cref="F:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.RegionManagerProperty"/> attached properties set to + a value different than <see langword="null"/> and there is a + <see cref="T:Microsoft.Practices.Composite.Regions.IRegionAdapter"/> mapping registered for the control, it + will create and adapt a new region for that control, and register it + in the <see cref="T:Microsoft.Practices.Composite.Regions.IRegionManager"/> with the specified region name. + </remarks> + </member> + <member name="M:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.SetRegionName(System.Windows.DependencyObject,System.String)"> + <summary> + Sets the <see cref="F:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.RegionNameProperty"/> attached property. + </summary> + <param name="regionTarget">The object to adapt. This is typically a container (i.e a control).</param> + <param name="regionName">The name of the region to register.</param> + </member> + <member name="M:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.GetRegionName(System.Windows.DependencyObject)"> + <summary> + Gets the value for the <see cref="F:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.RegionNameProperty"/> attached property. + </summary> + <param name="regionTarget">The object to adapt. This is typically a container (i.e a control).</param> + <returns>The name of the region that should be created when + <see cref="F:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.RegionManagerProperty"/> is also set in this element.</returns> + </member> + <member name="F:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.RegionManagerProperty"> + <summary> + Identifies the RegionManager attached property. + </summary> + <remarks> + When a control has both the <see cref="F:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.RegionNameProperty"/> and + <see cref="F:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.RegionManagerProperty"/> attached properties set to + a value different than <see langword="null"/> and there is a + <see cref="T:Microsoft.Practices.Composite.Regions.IRegionAdapter"/> mapping registered for the control, it + will create and adapt a new region for that control, and register it + in the <see cref="T:Microsoft.Practices.Composite.Regions.IRegionManager"/> with the specified region name. + </remarks> + </member> + <member name="M:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.GetRegionManager(System.Windows.DependencyObject)"> + <summary> + Gets the value of the <see cref="F:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.RegionNameProperty"/> attached property. + </summary> + <param name="target">The target element.</param> + <returns>The <see cref="T:Microsoft.Practices.Composite.Regions.IRegionManager"/> attached to the <paramref name="target"/> element.</returns> + </member> + <member name="M:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.SetRegionManager(System.Windows.DependencyObject,Microsoft.Practices.Composite.Regions.IRegionManager)"> + <summary> + Sets the <see cref="F:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.RegionManagerProperty"/> attached property. + </summary> + <param name="target">The target element.</param> + <param name="value">The value.</param> + </member> + <member name="M:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.#ctor"> + <summary> + Initializes a new instance of <see cref="T:Microsoft.Practices.Composite.Wpf.Regions.RegionManager"/>. + </summary> + </member> + <member name="M:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.#ctor(Microsoft.Practices.Composite.Wpf.Regions.RegionAdapterMappings)"> + <summary> + Initializes a new instance of <see cref="T:Microsoft.Practices.Composite.Wpf.Regions.RegionManager"/>. + </summary> + <param name="mappings">The <see cref="T:Microsoft.Practices.Composite.Wpf.Regions.RegionAdapterMappings"/> that + will be used when calling <see cref="M:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.AttachNewRegion(System.Object,System.String)"/> explicitly + or by creating regions by using attached properties through XAML. + </param> + </member> + <member name="M:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.AttachNewRegion(System.Object,System.String)"> + <summary> + Attaches a region to an object and adds it to the region manager. + </summary> + <param name="regionTarget">The object to adapt. This is typically a container (i.e a control).</param> + <param name="regionName">The name of the region to register.</param> + <exception cref="T:System.ArgumentException">When regions collection already has a region registered using <paramref name="regionName"/>.</exception> + </member> + <member name="M:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.CreateRegionManager"> + <summary> + Creates a new region manager. + </summary> + <returns>A new region manager that can be used as a different scope from the current region manager.</returns> + </member> + <member name="P:Microsoft.Practices.Composite.Wpf.Regions.RegionManager.Regions"> + <summary> + Gets a dictionary of <see cref="T:Microsoft.Practices.Composite.Regions.IRegion"/> that identify each region by name. + You can use this dictionary to add or remove regions to the current region manager. + </summary> + <value>An <see cref="T:System.Collections.Generic.IDictionary`2"/> with all the registered regions.</value> + </member> + <member name="T:Microsoft.Practices.Composite.Wpf.Regions.RegionAdapterMappings"> + <summary> + This class maps <see cref="T:System.Type"/> with <see cref="T:Microsoft.Practices.Composite.Regions.IRegionAdapter"/>. + </summary> + </member> + <member name="M:Microsoft.Practices.Composite.Wpf.Regions.RegionAdapterMappings.RegisterMapping(System.Type,Microsoft.Practices.Composite.Regions.IRegionAdapter)"> + <summary> + Registers the mapping between a type and an adapter. + </summary> + <param name="controlType">The type of the control.</param> + <param name="adapter">The adapter to use with the <paramref name="controlType"/> type.</param> + <exception cref="T:System.ArgumentNullException">When any of <paramref name="controlType"/> or <paramref name="adapter"/> are <see langword="null"/>.</exception> + <exception cref="T:System.InvalidOperationException">If a mapping for <paramref name="controlType"/> already exists.</exception> + </member> + <member name="M:Microsoft.Practices.Composite.Wpf.Regions.RegionAdapterMappings.... [truncated message content] |
From: <jer...@us...> - 2009-02-01 20:05:16
|
Revision: 232 http://structuremap.svn.sourceforge.net/structuremap/?rev=232&view=rev Author: jeremydmiller Date: 2009-02-01 20:03:18 +0000 (Sun, 01 Feb 2009) Log Message: ----------- made a copy Added Paths: ----------- branches/2.5.3/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2009-02-01 20:02:18
|
Revision: 231 http://structuremap.svn.sourceforge.net/structuremap/?rev=231&view=rev Author: jeremydmiller Date: 2009-02-01 20:02:05 +0000 (Sun, 01 Feb 2009) Log Message: ----------- added <Registry> to the xml configuration. Finishing the 2.5.3 release Modified Paths: -------------- trunk/Source/HTML/XmlConfiguration.htm trunk/Source/StructureMap/BuildSession.cs trunk/Source/StructureMap/Configuration/ConfigurationParser.cs trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs trunk/Source/StructureMap/Configuration/GraphBuilder.cs trunk/Source/StructureMap/Configuration/IGraphBuilder.cs trunk/Source/StructureMap/Configuration/XmlConstants.cs trunk/Source/StructureMap/PluginGraphBuilder.cs trunk/Source/StructureMap/StructureMapException.resx trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj Added Paths: ----------- trunk/Source/StructureMap.Testing/Examples/AddRegistryInXml.xml trunk/Source/StructureMap.Testing/ReadingRegistriesFromXmlTester.cs Modified: trunk/Source/HTML/XmlConfiguration.htm =================================================================== --- trunk/Source/HTML/XmlConfiguration.htm 2009-02-01 18:34:03 UTC (rev 230) +++ trunk/Source/HTML/XmlConfiguration.htm 2009-02-01 20:02:05 UTC (rev 231) @@ -542,8 +542,43 @@ </div> <!--EndFragment--> <hr /> - + <h2>Referencing Registries from Xml</h2> + <p>StructureMap 2.5.3 adds the ability to include Registry configuration through Xml + configuration. This may be valuable in systems where you might be + completely unable to do programmatic bootstrapping or modify the application + startup to add bootstrapping. Just add a <Registry> node to Xml + configuration and put the assembly qualified name of the Registry class into the + @Type attribute like this:</p> +<!-- +{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Courier New;}}{\colortbl;??\red0\green0\blue255;\red255\green255\blue255;\red163\green21\blue21;\red255\green0\blue0;\red0\green0\blue0;\red0\green128\blue0;}??\fs20 \cf1 <?\cf3 xml\cf1 \cf4 version\cf1 =\cf0 "\cf1 1.0\cf0 "\cf1 \cf4 encoding\cf1 =\cf0 "\cf1 utf-8\cf0 "\cf1 ?>\par ??<\cf3 StructureMap\cf1 >\par ?? <!--\cf6 Configure a Registry by just specifying the Assembly Qualified Name of a Registry Type \cf1 -->\par ?? <\cf3 Registry\cf1 \cf4 Type\cf1 =\cf0 "\cf1 StructureMap.Testing.XmlFileRegistry, StructureMap.Testing\cf0 "\cf1 ></\cf3 Registry\cf1 >\par ??</\cf3 StructureMap\cf1 >} +--> + <div style="font-family: Courier New; font-size: 10pt; color: black; background: white; border: black thin solid;"> + <p style="margin: 0px;"> + <span style="color: blue;"><?</span><span style="color: #a31515;">xml</span><span + style="color: blue;"> </span><span style="color: red;">version</span><span + style="color: blue;">=</span>"<span style="color: blue;">1.0</span>"<span + style="color: blue;"> </span><span style="color: red;">encoding</span><span + style="color: blue;">=</span>"<span style="color: blue;">utf-8</span>"<span + style="color: blue;"> ?></span></p> + <p style="margin: 0px;"> + <span style="color: blue;"><</span><span style="color: #a31515;">StructureMap</span><span + style="color: blue;">></span></p> + <p style="margin: 0px;"> + <span style="color: blue;"> <!--</span><span style="color: green;"> + Configure a Registry by just specifying the Assembly Qualified Name of a + Registry Type </span><span style="color: blue;">--></span></p> + <p style="margin: 0px;"> + <span style="color: blue;"> <</span><span style="color: #a31515;">Registry</span><span + style="color: blue;"> </span><span style="color: red;">Type</span><span + style="color: blue;">=</span>"<span style="color: blue;">StructureMap.Testing.XmlFileRegistry, + StructureMap.Testing</span>"<span style="color: blue;">></</span><span + style="color: #a31515;">Registry</span><span style="color: blue;">></span></p> + <p style="margin: 0px;"> + <span style="color: blue;"></</span><span style="color: #a31515;">StructureMap</span><span + style="color: blue;">></span></p> + </div> +<!--EndFragment--> +<hr /> - </body> </html> \ No newline at end of file Modified: trunk/Source/StructureMap/BuildSession.cs =================================================================== --- trunk/Source/StructureMap/BuildSession.cs 2009-02-01 18:34:03 UTC (rev 230) +++ trunk/Source/StructureMap/BuildSession.cs 2009-02-01 20:02:05 UTC (rev 231) @@ -123,7 +123,11 @@ public Type ParentType { - get { return _buildStack.Parent.ConcreteType; } + get + { + if (_buildStack.Parent != null) return _buildStack.Parent.ConcreteType; + return null; + } } T IContext.GetInstance<T>() Modified: trunk/Source/StructureMap/Configuration/ConfigurationParser.cs =================================================================== --- trunk/Source/StructureMap/Configuration/ConfigurationParser.cs 2009-02-01 18:34:03 UTC (rev 230) +++ trunk/Source/StructureMap/Configuration/ConfigurationParser.cs 2009-02-01 20:02:05 UTC (rev 231) @@ -96,7 +96,12 @@ _structureMapNode.ForTextInChild("Assembly/@Name").Do(name => builder.AddAssembly(name)); } + public void ParseRegistries(IGraphBuilder builder) + { + _structureMapNode.ForTextInChild("Registry/@Type").Do(name => builder.AddRegistry(name)); + } + private XmlExtensions.XmlNodeExpression forEachNode(string xpath) { return _structureMapNode.ForEachChild(xpath); Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2009-02-01 18:34:03 UTC (rev 230) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2009-02-01 20:02:05 UTC (rev 231) @@ -152,6 +152,11 @@ return this; } + /// <summary> + /// Adds an Interceptor to only this PluginType + /// </summary> + /// <param name="interceptor"></param> + /// <returns></returns> public CreatePluginFamilyExpression<PLUGINTYPE> InterceptWith(InstanceInterceptor interceptor) { _children.Add( @@ -302,6 +307,11 @@ }); } + /// <summary> + /// Forces StructureMap to always use a unique instance to + /// stop the "BuildSession" caching + /// </summary> + /// <returns></returns> public CreatePluginFamilyExpression<PLUGINTYPE> AlwaysUnique() { return InterceptConstructionWith(new UniquePerRequestInterceptor()); Modified: trunk/Source/StructureMap/Configuration/GraphBuilder.cs =================================================================== --- trunk/Source/StructureMap/Configuration/GraphBuilder.cs 2009-02-01 18:34:03 UTC (rev 230) +++ trunk/Source/StructureMap/Configuration/GraphBuilder.cs 2009-02-01 20:02:05 UTC (rev 231) @@ -58,6 +58,16 @@ } } + public void AddRegistry(string registryTypeName) + { + _pluginGraph.Log.Try(()=> + { + var type = new TypePath(registryTypeName).FindType(); + Registry registry = (Registry) Activator.CreateInstance(type); + registry.ConfigurePluginGraph(_pluginGraph); + }).AndReportErrorAs(290, registryTypeName); + } + public IProfileBuilder GetProfileBuilder() { return new ProfileBuilder(_pluginGraph); Modified: trunk/Source/StructureMap/Configuration/IGraphBuilder.cs =================================================================== --- trunk/Source/StructureMap/Configuration/IGraphBuilder.cs 2009-02-01 18:34:03 UTC (rev 230) +++ trunk/Source/StructureMap/Configuration/IGraphBuilder.cs 2009-02-01 20:02:05 UTC (rev 231) @@ -17,6 +17,7 @@ { PluginGraph PluginGraph { get; } void AddAssembly(string assemblyName); + void AddRegistry(string registryTypeName); void FinishFamilies(); Modified: trunk/Source/StructureMap/Configuration/XmlConstants.cs =================================================================== --- trunk/Source/StructureMap/Configuration/XmlConstants.cs 2009-02-01 18:34:03 UTC (rev 230) +++ trunk/Source/StructureMap/Configuration/XmlConstants.cs 2009-02-01 20:02:05 UTC (rev 231) @@ -32,5 +32,6 @@ public const string SCOPE = "Scope"; public const string STRUCTUREMAP = "StructureMap"; public const string TYPE_ATTRIBUTE = "Type"; + public const string REGISTRY = "Registry"; } } \ No newline at end of file Modified: trunk/Source/StructureMap/PluginGraphBuilder.cs =================================================================== --- trunk/Source/StructureMap/PluginGraphBuilder.cs 2009-02-01 18:34:03 UTC (rev 230) +++ trunk/Source/StructureMap/PluginGraphBuilder.cs 2009-02-01 20:02:05 UTC (rev 231) @@ -62,6 +62,7 @@ { _graph.Log.StartSource(p.Description); p.ParseAssemblies(graphBuilder); + p.ParseRegistries(graphBuilder); }); forAllParsers(p => p.Parse(graphBuilder)); Modified: trunk/Source/StructureMap/StructureMapException.resx =================================================================== --- trunk/Source/StructureMap/StructureMapException.resx 2009-02-01 18:34:03 UTC (rev 230) +++ trunk/Source/StructureMap/StructureMapException.resx 2009-02-01 20:02:05 UTC (rev 231) @@ -268,4 +268,7 @@ <data name="285" xml:space="preserve"> <value>Only open generic types can be used in the call to Container.ForGenericType(type)</value> </data> + <data name="290" xml:space="preserve"> + <value>Could not load the designated Registry class '{0}'</value> + </data> </root> \ No newline at end of file Added: trunk/Source/StructureMap.Testing/Examples/AddRegistryInXml.xml =================================================================== --- trunk/Source/StructureMap.Testing/Examples/AddRegistryInXml.xml (rev 0) +++ trunk/Source/StructureMap.Testing/Examples/AddRegistryInXml.xml 2009-02-01 20:02:05 UTC (rev 231) @@ -0,0 +1,5 @@ +<?xml version="1.0" encoding="utf-8" ?> +<StructureMap> + <!-- Configure a Registry by just specifying the Assembly Qualified Name of a Registry Type --> + <Registry Type="StructureMap.Testing.XmlFileRegistry, StructureMap.Testing"></Registry> +</StructureMap> \ No newline at end of file Added: trunk/Source/StructureMap.Testing/ReadingRegistriesFromXmlTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/ReadingRegistriesFromXmlTester.cs (rev 0) +++ trunk/Source/StructureMap.Testing/ReadingRegistriesFromXmlTester.cs 2009-02-01 20:02:05 UTC (rev 231) @@ -0,0 +1,78 @@ +using System; +using System.Diagnostics; +using System.Xml; +using NUnit.Framework; +using StructureMap.Configuration; +using StructureMap.Configuration.DSL; +using StructureMap.Graph; +using StructureMap.Testing.Widget; + +namespace StructureMap.Testing +{ + [TestFixture] + public class ReadingRegistriesFromXmlTester + { + [SetUp] + public void SetUp() + { + } + + public void TheXmlFileRegistryWasLoadedInto(IContainer container) + { + container.GetInstance<ColorRule>().Color.ShouldEqual("Cornflower"); + } + + [Test] + public void graphbuilder_can_add_a_registry_directly() + { + var graph = new PluginGraph(); + var builder = new GraphBuilder(new Registry[0], graph); + builder.AddRegistry(typeof(XmlFileRegistry).AssemblyQualifiedName); + + var container = new Container(graph); + TheXmlFileRegistryWasLoadedInto(container); + } + + [Test] + public void handles_failures_gracefully_if_the_registry_cannot_be_loaded() + { + //290 + var graph = new PluginGraph(); + var builder = new GraphBuilder(new Registry[0], graph); + builder.AddRegistry("an invalid type name"); + + graph.Log.ErrorCount.ShouldEqual(1); + graph.Log.AssertHasError(290); + + } + + [Test] + public void read_registry_from_xml() + { + var document = new XmlDocument(); + document.LoadXml("<StructureMap><Registry></Registry></StructureMap>"); + document.DocumentElement.FirstChild.ShouldBeOfType<XmlElement>().SetAttribute("Type", + typeof (XmlFileRegistry). + AssemblyQualifiedName); + + Debug.WriteLine(document.OuterXml); + + var container = new Container(x => + { + x.AddConfigurationFromNode(document.DocumentElement); + }); + + TheXmlFileRegistryWasLoadedInto(container); + + } + + } + + public class XmlFileRegistry : Registry + { + public XmlFileRegistry() + { + ForConcreteType<ColorRule>().Configure.WithCtorArg("color").EqualTo("Cornflower"); + } + } +} \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj =================================================================== --- trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-02-01 18:34:03 UTC (rev 230) +++ trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-02-01 20:02:05 UTC (rev 231) @@ -367,6 +367,7 @@ <DesignTimeSharedInput>True</DesignTimeSharedInput> <DependentUpon>Settings.settings</DependentUpon> </Compile> + <Compile Include="ReadingRegistriesFromXmlTester.cs" /> <Compile Include="SpecificationExtensions.cs" /> <Compile Include="StructureMapConfigCreator.cs" /> <Compile Include="StructureMapConfigurationDefensiveChecksTester.cs" /> @@ -444,6 +445,7 @@ <EmbeddedResource Include="TestData\PluggedTypeTest.xml" /> </ItemGroup> <ItemGroup> + <Content Include="Examples\AddRegistryInXml.xml" /> <Content Include="Sample.xml" /> <Content Include="TestData\ProfileSample.xml" /> <EmbeddedResource Include="TestData\ShortInstance.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2009-02-01 18:35:45
|
Revision: 230 http://structuremap.svn.sourceforge.net/structuremap/?rev=230&view=rev Author: jeremydmiller Date: 2009-02-01 18:34:03 +0000 (Sun, 01 Feb 2009) Log Message: ----------- applying patches, and fixing HttpSession outside of HttpContext Modified Paths: -------------- trunk/Source/StructureMap/Attributes/InstanceScope.cs trunk/Source/StructureMap/BuildSession.cs trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs trunk/Source/StructureMap/Graph/PluginFamily.cs trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs trunk/Source/StructureMap/StructureMap.csproj trunk/Source/StructureMap/Util/Cache.cs trunk/Source/StructureMap.Testing/Graph/PluginFamilyTester.cs trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj Added Paths: ----------- trunk/Source/StructureMap/Pipeline/HttpSessionBuildPolicy.cs trunk/Source/StructureMap/Pipeline/SessionWrapper.cs trunk/Source/StructureMap/Pipeline/UniquePerRequestInterceptor.cs trunk/Source/StructureMap.Testing/Bugs/HttpSessionNullRefBug.cs trunk/Source/StructureMap.Testing/PerRequestInterceptorTester.cs Property Changed: ---------------- trunk/Source/StructureMap/ Property changes on: trunk/Source/StructureMap ___________________________________________________________________ Modified: svn:ignore - bin obj *.suo *.csproj.user StructureMap.xml + bin obj *.suo *.csproj.user StructureMap.xml [Bb]in [Dd]ebug [Rr]elease *.user *.aps *.eto Modified: trunk/Source/StructureMap/Attributes/InstanceScope.cs =================================================================== --- trunk/Source/StructureMap/Attributes/InstanceScope.cs 2009-02-01 17:47:12 UTC (rev 229) +++ trunk/Source/StructureMap/Attributes/InstanceScope.cs 2009-02-01 18:34:03 UTC (rev 230) @@ -7,6 +7,7 @@ ThreadLocal, HttpContext, Hybrid, - HttpSession + HttpSession, + HybridHttpSession } } \ No newline at end of file Modified: trunk/Source/StructureMap/BuildSession.cs =================================================================== --- trunk/Source/StructureMap/BuildSession.cs 2009-02-01 17:47:12 UTC (rev 229) +++ trunk/Source/StructureMap/BuildSession.cs 2009-02-01 18:34:03 UTC (rev 230) @@ -73,7 +73,7 @@ { private readonly BuildStack _buildStack = new BuildStack(); private readonly InstanceCache _cache = new InstanceCache(); - private readonly Cache<Type, object> _defaults; + private readonly Cache<Type, Func<object>> _defaults; private readonly InterceptorLibrary _interceptorLibrary; private readonly PipelineGraph _pipelineGraph; @@ -82,7 +82,7 @@ _pipelineGraph = pipelineGraph; _interceptorLibrary = interceptorLibrary; - _defaults = new Cache<Type, object>(t => + _defaults = new Cache<Type, Func<object>>(t => { Instance instance = _pipelineGraph.GetDefault(t); @@ -91,7 +91,9 @@ throw new StructureMapException(202, t); } - return CreateInstance(t, instance); + object createdInstance = CreateInstance(t, instance); + + return () => createdInstance; }); } @@ -197,7 +199,7 @@ public virtual object CreateInstance(Type pluginType) { - return _defaults[pluginType]; + return _defaults[pluginType](); } public virtual object ApplyInterception(Type pluginType, object actualValue) @@ -208,14 +210,19 @@ public virtual void RegisterDefault(Type pluginType, object defaultObject) { - _defaults[pluginType] = defaultObject; + RegisterDefault(pluginType, () => defaultObject); } + public virtual void RegisterDefault(Type pluginType, Func<object> creator) + { + _defaults[pluginType] = creator; + } + public T TryGetInstance<T>() where T : class { if (_defaults.Has(typeof(T))) { - return (T) _defaults[typeof (T)]; + return (T) _defaults[typeof (T)](); } return _pipelineGraph.HasDefaultForPluginType(typeof (T)) @@ -234,4 +241,4 @@ return _pipelineGraph.ForType(pluginType); } } -} \ No newline at end of file +} Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2009-02-01 17:47:12 UTC (rev 229) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2009-02-01 18:34:03 UTC (rev 230) @@ -301,5 +301,10 @@ family.DefaultInstanceKey = instance.Name; }); } + + public CreatePluginFamilyExpression<PLUGINTYPE> AlwaysUnique() + { + return InterceptConstructionWith(new UniquePerRequestInterceptor()); + } } } \ No newline at end of file Modified: trunk/Source/StructureMap/Graph/PluginFamily.cs =================================================================== --- trunk/Source/StructureMap/Graph/PluginFamily.cs 2009-02-01 17:47:12 UTC (rev 229) +++ trunk/Source/StructureMap/Graph/PluginFamily.cs 2009-02-01 18:34:03 UTC (rev 230) @@ -79,8 +79,12 @@ break; case InstanceScope.HttpSession: - AddInterceptor(new HttpSessionBuildPolicy()); + AddInterceptor(new HybridSessionBuildPolicy()); break; + + case InstanceScope.HybridHttpSession: + AddInterceptor(new HybridSessionBuildPolicy()); + break; } } Modified: trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs 2009-02-01 17:47:12 UTC (rev 229) +++ trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs 2009-02-01 18:34:03 UTC (rev 230) @@ -1,7 +1,5 @@ -using System; using System.Collections; using System.Web; -using System.Web.SessionState; using StructureMap.Attributes; namespace StructureMap.Pipeline @@ -10,6 +8,7 @@ { public static readonly string ITEM_NAME = "STRUCTUREMAP-INSTANCES"; + public static bool HasContext() { return HttpContext.Current != null; @@ -56,107 +55,4 @@ return InstanceScope.HttpContext.ToString(); } } - - public class HttpSessionBuildPolicy : HttpContextBuildPolicy - { - protected override IDictionary findHttpDictionary() - { - return new SessionWrapper(HttpContext.Current.Session); - } - - public override string ToString() - { - return InstanceScope.HttpSession.ToString(); - } - } - - public class SessionWrapper : IDictionary - { - private readonly HttpSessionState _session; - - public SessionWrapper(HttpSessionState session) - { - _session = session; - } - - #region IDictionary Members - - IEnumerator IEnumerable.GetEnumerator() - { - return GetEnumerator(); - } - - public void CopyTo(Array array, int index) - { - _session.CopyTo(array, index); - } - - public int Count - { - get { return _session.Count; } - } - - public object SyncRoot - { - get { return _session.SyncRoot; } - } - - public bool IsSynchronized - { - get { return _session.IsSynchronized; } - } - - public bool Contains(object key) - { - return _session[key.ToString()] != null; - } - - public void Add(object key, object value) - { - _session.Add(key.ToString(), value); - } - - public void Clear() - { - _session.Clear(); - } - - public IDictionaryEnumerator GetEnumerator() - { - throw new NotImplementedException(); - } - - public void Remove(object key) - { - _session.Remove(key.ToString()); - } - - public object this[object key] - { - get { return _session[key.ToString()]; } - set { _session[key.ToString()] = value; } - } - - public ICollection Keys - { - get { return _session.Keys; } - } - - public ICollection Values - { - get { throw new NotImplementedException(); } - } - - public bool IsReadOnly - { - get { return _session.IsReadOnly; } - } - - public bool IsFixedSize - { - get { return false; } - } - - #endregion - } } Added: trunk/Source/StructureMap/Pipeline/HttpSessionBuildPolicy.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/HttpSessionBuildPolicy.cs (rev 0) +++ trunk/Source/StructureMap/Pipeline/HttpSessionBuildPolicy.cs 2009-02-01 18:34:03 UTC (rev 230) @@ -0,0 +1,32 @@ +using System.Collections; +using System.Web; +using StructureMap.Attributes; + +namespace StructureMap.Pipeline +{ + public class HttpSessionBuildPolicy : HttpContextBuildPolicy + { + protected override IDictionary findHttpDictionary() + { + return new SessionWrapper(HttpContext.Current.Session); + } + + public override string ToString() + { + return InstanceScope.HttpSession.ToString(); + } + } + + public class HybridSessionBuildPolicy : HttpBuildPolicyBase<HttpSessionBuildPolicy, ThreadLocalStoragePolicy> + { + public override IBuildPolicy Clone() + { + return new HybridSessionBuildPolicy() { InnerPolicy = InnerPolicy.Clone() }; + } + + public override string ToString() + { + return InstanceScope.HybridHttpSession.ToString(); + } + } +} \ No newline at end of file Added: trunk/Source/StructureMap/Pipeline/SessionWrapper.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/SessionWrapper.cs (rev 0) +++ trunk/Source/StructureMap/Pipeline/SessionWrapper.cs 2009-02-01 18:34:03 UTC (rev 230) @@ -0,0 +1,96 @@ +using System; +using System.Collections; +using System.Web.SessionState; + +namespace StructureMap.Pipeline +{ + public class SessionWrapper : IDictionary + { + private readonly HttpSessionState _session; + + public SessionWrapper(HttpSessionState session) + { + _session = session; + } + + #region IDictionary Members + + IEnumerator IEnumerable.GetEnumerator() + { + return GetEnumerator(); + } + + public void CopyTo(Array array, int index) + { + _session.CopyTo(array, index); + } + + public int Count + { + get { return _session.Count; } + } + + public object SyncRoot + { + get { return _session.SyncRoot; } + } + + public bool IsSynchronized + { + get { return _session.IsSynchronized; } + } + + public bool Contains(object key) + { + return _session[key.ToString()] != null; + } + + public void Add(object key, object value) + { + _session.Add(key.ToString(), value); + } + + public void Clear() + { + _session.Clear(); + } + + public IDictionaryEnumerator GetEnumerator() + { + throw new NotImplementedException(); + } + + public void Remove(object key) + { + _session.Remove(key.ToString()); + } + + public object this[object key] + { + get { return _session[key.ToString()]; } + set { _session[key.ToString()] = value; } + } + + public ICollection Keys + { + get { return _session.Keys; } + } + + public ICollection Values + { + get { throw new NotImplementedException(); } + } + + public bool IsReadOnly + { + get { return _session.IsReadOnly; } + } + + public bool IsFixedSize + { + get { return false; } + } + + #endregion + } +} \ No newline at end of file Added: trunk/Source/StructureMap/Pipeline/UniquePerRequestInterceptor.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/UniquePerRequestInterceptor.cs (rev 0) +++ trunk/Source/StructureMap/Pipeline/UniquePerRequestInterceptor.cs 2009-02-01 18:34:03 UTC (rev 230) @@ -0,0 +1,46 @@ +using System; + +namespace StructureMap.Pipeline +{ + /// <summary> + /// Makes sure that every request for this object returns a unique object + /// </summary> + public class UniquePerRequestInterceptor : IBuildInterceptor + { + + #region IBuildInterceptor Members + + private IBuildPolicy _innerPolicy = new BuildPolicy(); + + public IBuildPolicy InnerPolicy + { + get { return _innerPolicy; } + set { _innerPolicy = value; } + } + + #endregion + + #region IBuildPolicy Members + + public object Build(BuildSession buildSession, Type pluginType, Instance instance) + { + //insert a default object creator + buildSession.RegisterDefault(pluginType, () => InnerPolicy.Build(buildSession, pluginType, instance)); + + //build this object for the first time + return buildSession.CreateInstance(pluginType); + } + + public IBuildPolicy Clone() + { + return new UniquePerRequestInterceptor(); + } + + public void EjectAll() + { + InnerPolicy.EjectAll(); + } + + #endregion + } +} Modified: trunk/Source/StructureMap/StructureMap.csproj =================================================================== --- trunk/Source/StructureMap/StructureMap.csproj 2009-02-01 17:47:12 UTC (rev 229) +++ trunk/Source/StructureMap/StructureMap.csproj 2009-02-01 18:34:03 UTC (rev 230) @@ -405,6 +405,9 @@ <Compile Include="Graph\PluggableAttributeScanner.cs" /> <Compile Include="Graph\PluginCache.cs" /> <Compile Include="Pipeline\ConditionalInstance.cs" /> + <Compile Include="Pipeline\HttpSessionBuildPolicy.cs" /> + <Compile Include="Pipeline\SessionWrapper.cs" /> + <Compile Include="Pipeline\UniquePerRequestInterceptor.cs" /> <Compile Include="TypeExtensions.cs" /> <Compile Include="IBootstrapper.cs" /> <Compile Include="InitializationExpression.cs" /> Modified: trunk/Source/StructureMap/Util/Cache.cs =================================================================== --- trunk/Source/StructureMap/Util/Cache.cs 2009-02-01 17:47:12 UTC (rev 229) +++ trunk/Source/StructureMap/Util/Cache.cs 2009-02-01 18:34:03 UTC (rev 230) @@ -79,7 +79,9 @@ if (!_values.ContainsKey(key)) { VALUE value = _onMissing(key); - _values.Add(key, value); + //Check to make sure that the onMissing didn't cache this already + if(!_values.ContainsKey(key)) + _values.Add(key, value); } } } @@ -203,4 +205,4 @@ _values.Clear(); } } -} \ No newline at end of file +} Added: trunk/Source/StructureMap.Testing/Bugs/HttpSessionNullRefBug.cs =================================================================== --- trunk/Source/StructureMap.Testing/Bugs/HttpSessionNullRefBug.cs (rev 0) +++ trunk/Source/StructureMap.Testing/Bugs/HttpSessionNullRefBug.cs 2009-02-01 18:34:03 UTC (rev 230) @@ -0,0 +1,25 @@ +using NUnit.Framework; +using StructureMap.Attributes; +using StructureMap.Testing.Widget3; + +namespace StructureMap.Testing.Bugs +{ + [TestFixture] + public class HttpSessionNullRefBug + { + [Test] + public void SetUp() + { + var container = new Container(x => + { + x.ForRequestedType<IGateway>() + .CacheBy(InstanceScope.HybridHttpSession) + .TheDefaultIsConcreteType<DefaultGateway>(); + }); + + container.GetInstance<IGateway>().ShouldNotBeNull(); + } + + + } +} \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/Graph/PluginFamilyTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Graph/PluginFamilyTester.cs 2009-02-01 17:47:12 UTC (rev 229) +++ trunk/Source/StructureMap.Testing/Graph/PluginFamilyTester.cs 2009-02-01 18:34:03 UTC (rev 230) @@ -265,10 +265,19 @@ var family = new PluginFamily(typeof(IServiceProvider)); family.SetScopeTo(InstanceScope.HttpSession); - family.Policy.ShouldBeOfType<HttpSessionBuildPolicy>(); + family.Policy.ShouldBeOfType<HybridSessionBuildPolicy>(); } [Test] + public void set_the_scope_to_session_hybrid() + { + var family = new PluginFamily(typeof(IServiceProvider)); + family.SetScopeTo(InstanceScope.HybridHttpSession); + + family.Policy.ShouldBeOfType<HybridSessionBuildPolicy>(); + } + + [Test] public void SetScopeToSingleton() { var family = new PluginFamily(typeof (IServiceProvider)); Added: trunk/Source/StructureMap.Testing/PerRequestInterceptorTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/PerRequestInterceptorTester.cs (rev 0) +++ trunk/Source/StructureMap.Testing/PerRequestInterceptorTester.cs 2009-02-01 18:34:03 UTC (rev 230) @@ -0,0 +1,70 @@ +using NUnit.Framework; +using StructureMap.Pipeline; + +namespace StructureMap.Testing +{ + [TestFixture] + public class PerRequestInterceptorTester + { + //Think of this as a data session + public class Session + { + } + + public class Model1 + { + public Model1(Session session) + { + Session = session; + } + + public Session Session { get; set; } + } + + public class Model2 + { + public Model2(Session session) + { + Session = session; + } + + public Session Session { get; set; } + } + + //this is my shell, it needs some models + public class Shell + { + public Shell(Model1 model1, Model2 model2) + { + Model1 = model1; + Model2 = model2; + } + + public Model1 Model1 { get; set; } + public Model2 Model2 { get; set; } + } + + [Test] + public void TestObjectReturnedAreUnique() + { + ObjectFactory.Initialize( + x => + { + x.BuildInstancesOf<Session>() + .AlwaysUnique() + .TheDefaultIsConcreteType<Session>(); + x.BuildInstancesOf<Model1>() + .TheDefaultIsConcreteType<Model1>(); + x.BuildInstancesOf<Model2>() + .TheDefaultIsConcreteType<Model2>(); + x.BuildInstancesOf<Shell>() + .TheDefaultIsConcreteType<Shell>(); + }); + + var shell = ObjectFactory.GetInstance<Shell>(); + + shell.Model1.Session.ShouldNotBeTheSameAs(shell.Model2.Session); + + } + } +} \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj =================================================================== --- trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-02-01 17:47:12 UTC (rev 229) +++ trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-02-01 18:34:03 UTC (rev 230) @@ -178,6 +178,7 @@ <Compile Include="AutoMocking\RhinoMockRepositoryProxyTester.cs" /> <Compile Include="AutoWiringExamples.cs" /> <Compile Include="Bugs\BuildUpBug.cs" /> + <Compile Include="Bugs\HttpSessionNullRefBug.cs" /> <Compile Include="Bugs\IDictionaryAndXmlBugTester.cs" /> <Compile Include="Bugs\ScanIndexerBugTester.cs" /> <Compile Include="Bugs\SingletonShouldBeLazy.cs" /> @@ -373,6 +374,7 @@ <Compile Include="TestData\DataMother.cs"> <SubType>Code</SubType> </Compile> + <Compile Include="PerRequestInterceptorTester.cs" /> <Compile Include="TestUtility.cs" /> <Compile Include="Diagnostics\ValidationBuildSessionTester.cs" /> <Compile Include="TypeExtensionsTester.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2009-02-01 17:47:19
|
Revision: 229 http://structuremap.svn.sourceforge.net/structuremap/?rev=229&view=rev Author: jeremydmiller Date: 2009-02-01 17:47:12 +0000 (Sun, 01 Feb 2009) Log Message: ----------- touch of work on HttpContextBuildPolicy Modified Paths: -------------- trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs Modified: trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs 2009-01-31 20:03:15 UTC (rev 228) +++ trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs 2009-02-01 17:47:12 UTC (rev 229) @@ -154,7 +154,7 @@ public bool IsFixedSize { - get { throw new NotImplementedException(); } + get { return false; } } #endregion This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2009-01-31 20:03:26
|
Revision: 228 http://structuremap.svn.sourceforge.net/structuremap/?rev=228&view=rev Author: jeremydmiller Date: 2009-01-31 20:03:15 +0000 (Sat, 31 Jan 2009) Log Message: ----------- beginning of the Prism bootstrapper, some work for diagnostics "pretty-ifying" Modified Paths: -------------- trunk/Source/StructureMap/Configuration/DSL/Registry.cs trunk/Source/StructureMap/Diagnostics/WhatDoIHaveWriter.cs trunk/Source/StructureMap/Graph/Constructor.cs trunk/Source/StructureMap/Pipeline/BuildPolicy.cs trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs trunk/Source/StructureMap/Pipeline/HybridBuildPolicy.cs trunk/Source/StructureMap/Pipeline/SingletonPolicy.cs trunk/Source/StructureMap/Pipeline/ThreadLocalStoragePolicy.cs trunk/Source/StructureMap/TypeExtensions.cs trunk/Source/StructureMap.sln Added Paths: ----------- trunk/Source/StructureMap.Prism/ trunk/Source/StructureMap.Prism/DefaultRegistry.cs trunk/Source/StructureMap.Prism/PrismBootstrapper.cs trunk/Source/StructureMap.Prism/StructureMapContainerFacade.cs trunk/Source/StructureMap.Prism/structuremap.snk trunk/Source/StructureMap.Testing.Prism/ trunk/Source/StructureMap.Testing.Prism/DefaultRegistryTester.cs trunk/Source/StructureMap.Testing.Prism/StructureMapContainerFacadeTester.cs Modified: trunk/Source/StructureMap/Configuration/DSL/Registry.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2009-01-22 22:33:20 UTC (rev 227) +++ trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2009-01-31 20:03:15 UTC (rev 228) @@ -47,6 +47,7 @@ void SelectConstructor<T>(Expression<Func<T>> expression); } + /// <summary> /// A Registry class provides methods and grammars for configuring a Container or ObjectFactory. /// Using a Registry subclass is the recommended way of configuring a StructureMap Container. @@ -74,6 +75,7 @@ /// You can overide this method as a place to put the Registry DSL /// declarations. This is not mandatory. /// </summary> + [Obsolete("configure() is unnecessary. All declarations can be made in the constructor of a Registry or any other method")] protected virtual void configure() { // no-op; @@ -152,6 +154,16 @@ } /// <summary> + /// Convenience method. Equivalent of ForRequestedType[PluginType]().AsSingletons() + /// </summary> + /// <typeparam name="PLUGINTYPE"></typeparam> + /// <returns></returns> + public CreatePluginFamilyExpression<PLUGINTYPE> ForSingletonOf<PLUGINTYPE>() + { + return ForRequestedType<PLUGINTYPE>().AsSingletons(); + } + + /// <summary> /// Uses the configuration expressions of this Registry to create a PluginGraph /// object that could be used to initialize a Container. This method is /// mostly for internal usage, but might be helpful for diagnostics @@ -357,5 +369,7 @@ { PluginCache.GetPlugin(typeof(T)).UseConstructor(expression); } + + } } \ No newline at end of file Modified: trunk/Source/StructureMap/Diagnostics/WhatDoIHaveWriter.cs =================================================================== --- trunk/Source/StructureMap/Diagnostics/WhatDoIHaveWriter.cs 2009-01-22 22:33:20 UTC (rev 227) +++ trunk/Source/StructureMap/Diagnostics/WhatDoIHaveWriter.cs 2009-01-31 20:03:15 UTC (rev 228) @@ -79,7 +79,7 @@ _writer.AddText(contents); - _writer.AddContent("Built by: " + pluginType.Policy); + _writer.AddContent("Scoped as: " + pluginType.Policy); foreach (IInstance instance in pluginType.Instances) { Modified: trunk/Source/StructureMap/Graph/Constructor.cs =================================================================== --- trunk/Source/StructureMap/Graph/Constructor.cs 2009-01-22 22:33:20 UTC (rev 227) +++ trunk/Source/StructureMap/Graph/Constructor.cs 2009-01-31 20:03:15 UTC (rev 228) @@ -94,12 +94,33 @@ public void Visit(IArgumentVisitor visitor) { - foreach (ParameterInfo info in _ctor.GetParameters()) + try { - Type parameterType = info.ParameterType; - - visitParameter(info, parameterType, visitor); + foreach (ParameterInfo info in _ctor.GetParameters()) + { + try + { + Type parameterType = info.ParameterType; + visitParameter(info, parameterType, visitor); + } + catch (Exception e) + { + string message = + "Trying to visit parameter {0} of type {1} in the constructor for {2}".ToFormat(info.Name, + info. + ParameterType, + _pluggedType. + AssemblyQualifiedName); + throw new ApplicationException(message, e); + } + } } + catch (Exception e) + { + string message = "Failed while trying to visit the constructor for " + + _pluggedType.AssemblyQualifiedName; + throw new ApplicationException(message, e); + } } private void visitParameter(ParameterInfo info, Type parameterType, IArgumentVisitor visitor) Modified: trunk/Source/StructureMap/Pipeline/BuildPolicy.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/BuildPolicy.cs 2009-01-22 22:33:20 UTC (rev 227) +++ trunk/Source/StructureMap/Pipeline/BuildPolicy.cs 2009-01-31 20:03:15 UTC (rev 228) @@ -1,4 +1,5 @@ using System; +using StructureMap.Attributes; namespace StructureMap.Pipeline { @@ -54,5 +55,10 @@ { return 0; } + + public override string ToString() + { + return InstanceScope.PerRequest.ToString(); + } } } \ No newline at end of file Modified: trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs 2009-01-22 22:33:20 UTC (rev 227) +++ trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs 2009-01-31 20:03:15 UTC (rev 228) @@ -2,6 +2,7 @@ using System.Collections; using System.Web; using System.Web.SessionState; +using StructureMap.Attributes; namespace StructureMap.Pipeline { @@ -49,6 +50,11 @@ { return this; } + + public override string ToString() + { + return InstanceScope.HttpContext.ToString(); + } } public class HttpSessionBuildPolicy : HttpContextBuildPolicy @@ -57,6 +63,11 @@ { return new SessionWrapper(HttpContext.Current.Session); } + + public override string ToString() + { + return InstanceScope.HttpSession.ToString(); + } } public class SessionWrapper : IDictionary Modified: trunk/Source/StructureMap/Pipeline/HybridBuildPolicy.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/HybridBuildPolicy.cs 2009-01-22 22:33:20 UTC (rev 227) +++ trunk/Source/StructureMap/Pipeline/HybridBuildPolicy.cs 2009-01-31 20:03:15 UTC (rev 228) @@ -1,4 +1,5 @@ using System; +using StructureMap.Attributes; namespace StructureMap.Pipeline { @@ -60,6 +61,11 @@ { return new HybridBuildPolicy(){InnerPolicy = InnerPolicy.Clone()}; } + + public override string ToString() + { + return InstanceScope.Hybrid.ToString(); + } } } \ No newline at end of file Modified: trunk/Source/StructureMap/Pipeline/SingletonPolicy.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/SingletonPolicy.cs 2009-01-22 22:33:20 UTC (rev 227) +++ trunk/Source/StructureMap/Pipeline/SingletonPolicy.cs 2009-01-31 20:03:15 UTC (rev 228) @@ -1,4 +1,5 @@ using System; +using StructureMap.Attributes; namespace StructureMap.Pipeline { @@ -43,5 +44,10 @@ { return new SingletonPolicy(); } + + public override string ToString() + { + return InstanceScope.Singleton.ToString(); + } } } \ No newline at end of file Modified: trunk/Source/StructureMap/Pipeline/ThreadLocalStoragePolicy.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/ThreadLocalStoragePolicy.cs 2009-01-22 22:33:20 UTC (rev 227) +++ trunk/Source/StructureMap/Pipeline/ThreadLocalStoragePolicy.cs 2009-01-31 20:03:15 UTC (rev 228) @@ -1,4 +1,5 @@ using System; +using StructureMap.Attributes; namespace StructureMap.Pipeline { @@ -36,5 +37,10 @@ { return this; } + + public override string ToString() + { + return InstanceScope.Hybrid.ToString(); + } } } \ No newline at end of file Modified: trunk/Source/StructureMap/TypeExtensions.cs =================================================================== --- trunk/Source/StructureMap/TypeExtensions.cs 2009-01-22 22:33:20 UTC (rev 227) +++ trunk/Source/StructureMap/TypeExtensions.cs 2009-01-31 20:03:15 UTC (rev 228) @@ -17,6 +17,11 @@ return new ReferencedInstance(key); } + public static bool IsSimple(this Type type) + { + return new TypeRules().IsSimple(type); + } + public static bool IsConcrete(this Type type) { return new TypeRules().IsConcrete(type); Added: trunk/Source/StructureMap.Prism/DefaultRegistry.cs =================================================================== --- trunk/Source/StructureMap.Prism/DefaultRegistry.cs (rev 0) +++ trunk/Source/StructureMap.Prism/DefaultRegistry.cs 2009-01-31 20:03:15 UTC (rev 228) @@ -0,0 +1,17 @@ +using Microsoft.Practices.Composite; +using Microsoft.Practices.Composite.Events; +using Microsoft.Practices.Composite.Wpf.Regions; +using StructureMap.Configuration.DSL; + +namespace StructureMap.Prism +{ + public class DefaultRegistry : Registry + { + public DefaultRegistry() + { + ForSingletonOf<IContainerFacade>().TheDefaultIsConcreteType<StructureMapContainerFacade>(); + ForSingletonOf<IEventAggregator>().TheDefaultIsConcreteType<EventAggregator>(); + ForSingletonOf<RegionAdapterMappings>().TheDefaultIsConcreteType<RegionAdapterMappings>(); + } + } +} \ No newline at end of file Added: trunk/Source/StructureMap.Prism/PrismBootstrapper.cs =================================================================== --- trunk/Source/StructureMap.Prism/PrismBootstrapper.cs (rev 0) +++ trunk/Source/StructureMap.Prism/PrismBootstrapper.cs 2009-01-31 20:03:15 UTC (rev 228) @@ -0,0 +1,62 @@ +using System.Collections.Generic; +using System.Linq; +using System.Text; +using StructureMap.Configuration.DSL; + +namespace StructureMap.Prism +{ + public abstract class PrismBootstrapper<THIS> : IBootstrapper where THIS : IBootstrapper, new() + { + private static bool _hasStarted = false; + + public static void Restart() + { + + } + + public void Bootstrap(string profile) + { + Bootstrap(); + } + + public void Bootstrap() + { + + } + + public PrismBootstrapper(string defaultProfofile) + { + } + + public PrismBootstrapper() : this(string.Empty) + { + } + + + public void BootstrapStructureMap() + { + throw new System.NotImplementedException(); + } + + // TODO + // 1.) Calls all Startables at end + // 2.) applies Profile + // 3.) adds the basic types + // 4.) create the shell + // 5.) tie into debuggers + } + + // test this + + public interface IStartable + { + void Execute(IContainer container); + } + + public class PrismRegistry : Registry + { + // TODO + // 1.) OnStartUp method + // 2.) + } +} Added: trunk/Source/StructureMap.Prism/StructureMapContainerFacade.cs =================================================================== --- trunk/Source/StructureMap.Prism/StructureMapContainerFacade.cs (rev 0) +++ trunk/Source/StructureMap.Prism/StructureMapContainerFacade.cs 2009-01-31 20:03:15 UTC (rev 228) @@ -0,0 +1,30 @@ +using System; +using Microsoft.Practices.Composite; + +namespace StructureMap.Prism +{ + public class StructureMapContainerFacade : IContainerFacade + { + private readonly IContainer _container; + + public StructureMapContainerFacade(IContainer container) + { + _container = container; + } + + public object Resolve(Type type) + { + return _container.GetInstance(type); + } + + public object TryResolve(Type type) + { + return _container.TryGetInstance(type); + } + + public IContainer Container + { + get { return _container; } + } + } +} \ No newline at end of file Added: trunk/Source/StructureMap.Prism/structuremap.snk =================================================================== (Binary files differ) Property changes on: trunk/Source/StructureMap.Prism/structuremap.snk ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/Source/StructureMap.Testing.Prism/DefaultRegistryTester.cs =================================================================== --- trunk/Source/StructureMap.Testing.Prism/DefaultRegistryTester.cs (rev 0) +++ trunk/Source/StructureMap.Testing.Prism/DefaultRegistryTester.cs 2009-01-31 20:03:15 UTC (rev 228) @@ -0,0 +1,54 @@ +using Microsoft.Practices.Composite; +using Microsoft.Practices.Composite.Events; +using Microsoft.Practices.Composite.Wpf.Regions; +using NUnit.Framework; +using StructureMap.Prism; + +namespace StructureMap.Testing.Prism +{ + [TestFixture] + public class DefaultRegistryTester + { + #region Setup/Teardown + + [SetUp] + public void SetUp() + { + container = new Container(new DefaultRegistry()); + } + + #endregion + + private Container container; + + [Test] + public void sets_up_the_default_event_aggregator_as_a_singleton() + { + container.GetInstance<IEventAggregator>().ShouldBeOfType<EventAggregator>(); + container.GetInstance<IEventAggregator>().ShouldBeTheSameAs(container.GetInstance<IEventAggregator>()); + } + + [Test] + public void sets_up_the_default_region_adapter_as_a_singleton() + { + container.GetInstance<RegionAdapterMappings>().ShouldBeOfType<RegionAdapterMappings>(); + container.GetInstance<RegionAdapterMappings>().ShouldBeTheSameAs( + container.GetInstance<RegionAdapterMappings>()); + } + + [Test] + public void sets_up_the_icontainerfacade_to_wrap_itself() + { + var theView = new TheView(); + container.Inject(theView); + + container.GetInstance<IContainerFacade>() + .ShouldBeOfType<StructureMapContainerFacade>() + .Container.ShouldBeTheSameAs(container); + } + } + + public class TheView + { + } +} \ No newline at end of file Added: trunk/Source/StructureMap.Testing.Prism/StructureMapContainerFacadeTester.cs =================================================================== --- trunk/Source/StructureMap.Testing.Prism/StructureMapContainerFacadeTester.cs (rev 0) +++ trunk/Source/StructureMap.Testing.Prism/StructureMapContainerFacadeTester.cs 2009-01-31 20:03:15 UTC (rev 228) @@ -0,0 +1,42 @@ +using NUnit.Framework; +using StructureMap.Prism; + +namespace StructureMap.Testing.Prism +{ + [TestFixture] + public class StructureMapContainerFacadeTester + { + [Test] + public void can_use_inner_container_to_resolve_a_type() + { + var container = new Container(x => { x.ForRequestedType<IView>().TheDefaultIsConcreteType<View>(); }); + + var facade = new StructureMapContainerFacade(container); + facade.Resolve(typeof (IView)).ShouldBeOfType<View>(); + } + + [Test] + public void can_use_inner_container_to_try_resolve_successfully() + { + var container = new Container(x => { x.ForRequestedType<IView>().TheDefaultIsConcreteType<View>(); }); + + var facade = new StructureMapContainerFacade(container); + facade.TryResolve(typeof (IView)).ShouldBeOfType<View>(); + } + + [Test] + public void can_use_inner_container_to_try_resolve_when_type_is_not_there() + { + var facade = new StructureMapContainerFacade(new Container()); + facade.TryResolve(typeof (IView)).ShouldBeNull(); + } + } + + public interface IView + { + } + + public class View : IView + { + } +} \ No newline at end of file Modified: trunk/Source/StructureMap.sln =================================================================== --- trunk/Source/StructureMap.sln 2009-01-22 22:33:20 UTC (rev 227) +++ trunk/Source/StructureMap.sln 2009-01-31 20:03:15 UTC (rev 228) @@ -57,6 +57,10 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TableOfContentsBuilder", "TableOfContentsBuilder\TableOfContentsBuilder.csproj", "{8A9EAE91-F3F5-4919-86FC-6D98D00FC77F}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureMap.Prism", "StructureMap.Prism\StructureMap.Prism.csproj", "{150CACB1-7F59-4C68-8830-F277E0E98A3F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StructureMap.Testing.Prism", "StructureMap.Testing.Prism\StructureMap.Testing.Prism.csproj", "{7F72EFA9-B575-462A-855F-132F8DBC6E9D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Build|.NET = Build|.NET @@ -292,6 +296,36 @@ {8A9EAE91-F3F5-4919-86FC-6D98D00FC77F}.Release|Any CPU.Build.0 = Release|Any CPU {8A9EAE91-F3F5-4919-86FC-6D98D00FC77F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU {8A9EAE91-F3F5-4919-86FC-6D98D00FC77F}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Build|.NET.ActiveCfg = Release|Any CPU + {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Build|Any CPU.ActiveCfg = Release|Any CPU + {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Build|Any CPU.Build.0 = Release|Any CPU + {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Build|Mixed Platforms.ActiveCfg = Release|Any CPU + {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Build|Mixed Platforms.Build.0 = Release|Any CPU + {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Debug|.NET.ActiveCfg = Debug|Any CPU + {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Release|.NET.ActiveCfg = Release|Any CPU + {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Release|Any CPU.Build.0 = Release|Any CPU + {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {150CACB1-7F59-4C68-8830-F277E0E98A3F}.Release|Mixed Platforms.Build.0 = Release|Any CPU + {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Build|.NET.ActiveCfg = Release|Any CPU + {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Build|Any CPU.ActiveCfg = Release|Any CPU + {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Build|Any CPU.Build.0 = Release|Any CPU + {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Build|Mixed Platforms.ActiveCfg = Release|Any CPU + {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Build|Mixed Platforms.Build.0 = Release|Any CPU + {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Debug|.NET.ActiveCfg = Debug|Any CPU + {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU + {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU + {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Release|.NET.ActiveCfg = Release|Any CPU + {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Release|Any CPU.Build.0 = Release|Any CPU + {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU + {7F72EFA9-B575-462A-855F-132F8DBC6E9D}.Release|Mixed Platforms.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fli...@us...> - 2009-01-22 22:33:26
|
Revision: 227 http://structuremap.svn.sourceforge.net/structuremap/?rev=227&view=rev Author: flimflan Date: 2009-01-22 22:33:20 +0000 (Thu, 22 Jan 2009) Log Message: ----------- Applied patch from Weston Binford to suppress noisy documentation warnings. Cleaned up "real" warnings. Modified Paths: -------------- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs trunk/Source/StructureMap/Configuration/DSL/Expressions/InstanceExpression.cs trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs trunk/Source/StructureMap/Configuration/DSL/Registry.cs trunk/Source/StructureMap/Configuration/GraphBuilder.cs trunk/Source/StructureMap/Container.cs trunk/Source/StructureMap/Diagnostics/ValidationBuildSession.cs trunk/Source/StructureMap/Graph/AssemblyScanner.cs trunk/Source/StructureMap/IContainer.cs trunk/Source/StructureMap/InitializationExpression.cs trunk/Source/StructureMap/InstanceBuilder.cs trunk/Source/StructureMap/Model.cs trunk/Source/StructureMap/ObjectFactory.cs trunk/Source/StructureMap/Pipeline/ConditionalInstance.cs trunk/Source/StructureMap/Pipeline/ConfiguredInstanceBase.cs trunk/Source/StructureMap/Pipeline/DefaultInstance.cs trunk/Source/StructureMap/Pipeline/Instance.cs trunk/Source/StructureMap/Pipeline/SmartInstance.cs trunk/Source/StructureMap/StructureMap.csproj trunk/Source/StructureMap.AutoMocking/AutoMocker.cs trunk/Source/StructureMap.AutoMocking/StructureMap.AutoMocking.csproj trunk/Source/StructureMap.Testing/AutoMocking/RhinoAutoMockerTester.cs trunk/Source/StructureMap.Testing/Pipeline/ConditionalInstanceTester.cs trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2009-01-22 22:33:20 UTC (rev 227) @@ -100,8 +100,6 @@ family.AddInstance(instance); family.DefaultInstanceKey = instance.Name; }); - - return this; } /// <summary> @@ -193,7 +191,7 @@ /// <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">OnCreation()</see>, + /// 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> @@ -215,7 +213,7 @@ /// <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">OnCreation()</see>, + /// 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> Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/InstanceExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/InstanceExpression.cs 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/InstanceExpression.cs 2009-01-22 22:33:20 UTC (rev 227) @@ -15,13 +15,14 @@ IInstanceExpression<T> Is { get; } /// <summary> - /// Shortcut to specify a prebuilt Instance + /// Register a previously built Instance. This provides a "catch all" + /// method to attach custom Instance objects. Synonym for Instance() /// </summary> /// <param name="instance"></param> void IsThis(Instance instance); /// <summary> - /// Shortcut to directly inject an object + /// Inject this object directly. Synonym to Object() /// </summary> /// <param name="obj"></param> /// <returns></returns> @@ -90,20 +91,6 @@ void Instance(Instance instance); /// <summary> - /// Register a previously built Instance. This provides a "catch all" - /// method to attach custom Instance objects. Synonym for Instance() - /// </summary> - /// <param name="instance"></param> - void IsThis(Instance instance); - - /// <summary> - /// Inject this object directly. Synonym to Object() - /// </summary> - /// <param name="obj"></param> - /// <returns></returns> - LiteralInstance IsThis(T obj); - - /// <summary> /// Inject this object directly. Synonym to IsThis() /// </summary> /// <param name="theObject"></param> @@ -190,7 +177,7 @@ /// <param name="configuration"></param> /// <returns></returns> // Conditional object construction - ConditionalInstance<T> Conditional(Action<ConditionalInstance<T>.ConditionalInstanceExpression<T>> configuration); + ConditionalInstance<T> Conditional(Action<ConditionalInstance<T>.ConditionalInstanceExpression> configuration); } public class InstanceExpression<T> : IInstanceExpression<T>, ThenItExpression<T> @@ -226,7 +213,7 @@ _action(instance); } - private T returnInstance<T>(T instance) where T : Instance + private INSTANCE returnInstance<INSTANCE>(INSTANCE instance) where INSTANCE : Instance { Instance(instance); return instance; @@ -282,7 +269,7 @@ return returnInstance(new UserControlInstance(url)); } - public ConditionalInstance<T> Conditional(Action<ConditionalInstance<T>.ConditionalInstanceExpression<T>> configuration) + public ConditionalInstance<T> Conditional(Action<ConditionalInstance<T>.ConditionalInstanceExpression> configuration) { return returnInstance(new ConditionalInstance<T>(configuration)); } Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs 2009-01-22 22:33:20 UTC (rev 227) @@ -151,7 +151,7 @@ /// <summary> /// Define the default instance of the PluginType for the containing Profile /// </summary> - /// <param name="mementoBuilder"></param> + /// <param name="instance"></param> /// <returns></returns> public ProfileExpression Use(Instance instance) { Modified: trunk/Source/StructureMap/Configuration/DSL/Registry.cs =================================================================== --- trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2009-01-22 22:33:20 UTC (rev 227) @@ -43,7 +43,7 @@ /// class. Applies globally to all Containers in a single AppDomain. /// </summary> /// <typeparam name="T"></typeparam> - /// <param name="func"></param> + /// <param name="expression"></param> void SelectConstructor<T>(Expression<Func<T>> expression); } @@ -352,7 +352,7 @@ /// class. Applies globally to all Containers in a single AppDomain. /// </summary> /// <typeparam name="T"></typeparam> - /// <param name="func"></param> + /// <param name="expression"></param> public void SelectConstructor<T>(Expression<Func<T>> expression) { PluginCache.GetPlugin(typeof(T)).UseConstructor(expression); Modified: trunk/Source/StructureMap/Configuration/GraphBuilder.cs =================================================================== --- trunk/Source/StructureMap/Configuration/GraphBuilder.cs 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap/Configuration/GraphBuilder.cs 2009-01-22 22:33:20 UTC (rev 227) @@ -1,5 +1,4 @@ using System; -using System.Diagnostics; using System.Reflection; using StructureMap.Configuration.DSL; using StructureMap.Graph; @@ -11,8 +10,7 @@ { private readonly AssemblyScanner _assemblyScanner; private readonly PluginGraph _pluginGraph; - private Profile _profile; - private Container _systemContainer; + private readonly Container _systemContainer; private readonly PluginGraph _systemGraph; Modified: trunk/Source/StructureMap/Container.cs =================================================================== --- trunk/Source/StructureMap/Container.cs 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap/Container.cs 2009-01-22 22:33:20 UTC (rev 227) @@ -506,8 +506,8 @@ /// <param name="templateType"></param> /// <returns></returns> /// <example> - /// IFlattener flattener1 = container.ForGenericType(typeof (IFlattener<>)) - /// .WithParameters(typeof (Address)).GetInstanceAs<IFlattener>(); + /// IFlattener flattener1 = container.ForGenericType(typeof (IFlattener<>)) + /// .WithParameters(typeof (Address)).GetInstanceAs<IFlattener>(); /// </example> public OpenGenericTypeExpression ForGenericType(Type templateType) { Modified: trunk/Source/StructureMap/Diagnostics/ValidationBuildSession.cs =================================================================== --- trunk/Source/StructureMap/Diagnostics/ValidationBuildSession.cs 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap/Diagnostics/ValidationBuildSession.cs 2009-01-22 22:33:20 UTC (rev 227) @@ -48,7 +48,6 @@ try { return base.CreateInstance(pluginType, instance); - _dependencyStack.Pop(); } catch (StructureMapException ex) { @@ -81,9 +80,7 @@ object builtInstance = CreateInstance(pluginType, instance); validate(pluginType, instance, builtInstance); } -#pragma warning disable EmptyGeneralCatchClause catch (Exception) -#pragma warning restore EmptyGeneralCatchClause { // All exceptions are being dealt with in another place } Modified: trunk/Source/StructureMap/Graph/AssemblyScanner.cs =================================================================== --- trunk/Source/StructureMap/Graph/AssemblyScanner.cs 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap/Graph/AssemblyScanner.cs 2009-01-22 22:33:20 UTC (rev 227) @@ -188,10 +188,9 @@ private void scanTypesInAssembly(Assembly assembly, PluginGraph graph) { - Type[] exportedTypes; try { - foreach (Type type in assembly.GetExportedTypes()) + foreach (var type in assembly.GetExportedTypes()) { if (!isInTheIncludes(type)) continue; if (isInTheExcludes(type)) continue; Modified: trunk/Source/StructureMap/IContainer.cs =================================================================== --- trunk/Source/StructureMap/IContainer.cs 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap/IContainer.cs 2009-01-22 22:33:20 UTC (rev 227) @@ -233,8 +233,8 @@ /// <param name="templateType"></param> /// <returns></returns> /// <example> - /// IFlattener flattener1 = container.ForGenericType(typeof (IFlattener<>)) - /// .WithParameters(typeof (Address)).GetInstanceAs<IFlattener>(); + /// IFlattener flattener1 = container.ForGenericType(typeof (IFlattener<>)) + /// .WithParameters(typeof (Address)).GetInstanceAs<IFlattener>(); /// </example> Container.OpenGenericTypeExpression ForGenericType(Type templateType); Modified: trunk/Source/StructureMap/InitializationExpression.cs =================================================================== --- trunk/Source/StructureMap/InitializationExpression.cs 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap/InitializationExpression.cs 2009-01-22 22:33:20 UTC (rev 227) @@ -85,7 +85,6 @@ /// Scoping, the Default Instance, and interception. This method is specifically /// meant for registering open generic types /// </summary> - /// <typeparam name="PLUGINTYPE"></typeparam> /// <returns></returns> GenericFamilyExpression ForRequestedType(Type pluginType); Modified: trunk/Source/StructureMap/InstanceBuilder.cs =================================================================== --- trunk/Source/StructureMap/InstanceBuilder.cs 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap/InstanceBuilder.cs 2009-01-22 22:33:20 UTC (rev 227) @@ -3,6 +3,7 @@ namespace StructureMap { +#pragma warning disable 169 /// <summary> /// Base class for creating an object instance from an InstanceMemento. SubClasses are /// emitted for each concrete Plugin with constructor parameters. @@ -20,4 +21,5 @@ public virtual void BuildUp(IConfiguredInstance instance, BuildSession session, object target) { } } +#pragma warning restore 169 } \ No newline at end of file Modified: trunk/Source/StructureMap/Model.cs =================================================================== --- trunk/Source/StructureMap/Model.cs 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap/Model.cs 2009-01-22 22:33:20 UTC (rev 227) @@ -13,7 +13,7 @@ public interface IModel { /// <summary> - /// Access to all the <seealso cref="PluginType">PluginType</seealso> registrations + /// Access to all the <seealso cref="PluginTypeConfiguration">Plugin Type</seealso> registrations /// </summary> IEnumerable<PluginTypeConfiguration> PluginTypes { get; } @@ -27,7 +27,7 @@ bool HasDefaultImplementationFor(Type pluginType); /// <summary> - /// Can StructureMap fulfill a request to ObjectFactory.GetInstance<T>() from the + /// Can StructureMap fulfill a request to ObjectFactory.GetInstance<T>() from the /// current configuration. This does not include concrete classes that could be auto-configured /// upon demand /// </summary> @@ -45,7 +45,6 @@ /// <summary> /// Queryable access to all of the <see cref="IInstance">IInstance</see> for a given PluginType /// </summary> - /// <param name="pluginType"></param> /// <returns></returns> IEnumerable<IInstance> InstancesOf<T>(); Modified: trunk/Source/StructureMap/ObjectFactory.cs =================================================================== --- trunk/Source/StructureMap/ObjectFactory.cs 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap/ObjectFactory.cs 2009-01-22 22:33:20 UTC (rev 227) @@ -88,7 +88,7 @@ /// to introduce mocks or stubs during automated testing scenarios /// </summary> /// <param name="pluginType"></param> - /// <param name="stub"></param> + /// <param name="instance"></param> public static void Inject(Type pluginType, object instance) { container.Inject(pluginType, instance); @@ -117,7 +117,7 @@ /// pluginType. Mostly used for temporarily setting up return values of the Container /// to introduce mocks or stubs during automated testing scenarios /// </summary> - /// <typeparam name="T"></typeparam> + /// <typeparam name="PLUGINTYPE"></typeparam> /// <param name="name"></param> /// <param name="instance"></param> public static void Inject<PLUGINTYPE>(string name, PLUGINTYPE instance) @@ -162,7 +162,7 @@ /// <summary> /// Creates or finds the default instance of type T /// </summary> - /// <typeparam name="T"></typeparam> + /// <typeparam name="PLUGINTYPE"></typeparam> /// <returns></returns> public static PLUGINTYPE GetInstance<PLUGINTYPE>() { @@ -172,18 +172,17 @@ /// <summary> /// Creates a new instance of the requested type using the supplied Instance. Mostly used internally /// </summary> - /// <param name="pluginType"></param> + /// <param name="targetType"></param> /// <param name="instance"></param> /// <returns></returns> - public static object GetInstance(Type TargetType, Instance instance) + public static object GetInstance(Type targetType, Instance instance) { - return container.GetInstance(TargetType, instance); + return container.GetInstance(targetType, instance); } /// <summary> /// Creates a new instance of the requested type T using the supplied Instance. Mostly used internally /// </summary> - /// <param name="pluginType"></param> /// <param name="instance"></param> /// <returns></returns> public static T GetInstance<T>(Instance instance) @@ -195,7 +194,7 @@ /// Creates or finds the named instance of the pluginType /// </summary> /// <param name="pluginType"></param> - /// <param name="instanceKey"></param> + /// <param name="name"></param> /// <returns></returns> public static object GetNamedInstance(Type pluginType, string name) { @@ -205,8 +204,8 @@ /// <summary> /// Creates or finds the named instance of T /// </summary> - /// <typeparam name="T"></typeparam> - /// <param name="instanceKey"></param> + /// <typeparam name="PLUGINTYPE"></typeparam> + /// <param name="name"></param> /// <returns></returns> public static PLUGINTYPE GetNamedInstance<PLUGINTYPE>(string name) { @@ -227,7 +226,7 @@ /// <summary> /// Creates or resolves all registered instances of type T /// </summary> - /// <typeparam name="T"></typeparam> + /// <typeparam name="PLUGINTYPE"></typeparam> /// <returns></returns> public static IList<PLUGINTYPE> GetAllInstances<PLUGINTYPE>() { @@ -290,7 +289,6 @@ /// <summary> /// Sets the default instance for all PluginType's to the designated Profile. /// </summary> - /// <param name="profile"></param> public static string Profile { set @@ -377,7 +375,6 @@ /// </summary> /// <param name="pluginType"></param> /// <param name="instanceKey"></param> - /// <param name="instance"></param> /// <returns></returns> public static object TryGetInstance(Type pluginType, string instanceKey) { @@ -388,7 +385,6 @@ /// Creates or finds the default instance of the pluginType. Returns null if the pluginType is not known to the container. /// </summary> /// <param name="pluginType"></param> - /// <param name="instance"></param> /// <returns></returns> public static object TryGetInstance(Type pluginType) { @@ -399,7 +395,6 @@ /// Creates or finds the default instance of type T. Returns the default value of T if it is not known to the container. /// </summary> /// <typeparam name="T"></typeparam> - /// <param name="instance"></param> /// <returns></returns> public static T TryGetInstance<T>() { @@ -410,7 +405,7 @@ /// Creates or finds the named instance of type T. Returns the default value of T if the named instance is not known to the container. /// </summary> /// <typeparam name="T"></typeparam> - /// <param name="instance"></param> + /// <param name="instanceKey"></param> /// <returns></returns> public static T TryGetInstance<T>(string instanceKey) { @@ -435,8 +430,8 @@ /// <param name="templateType"></param> /// <returns></returns> /// <example> - /// IFlattener flattener1 = container.ForGenericType(typeof (IFlattener<>)) - /// .WithParameters(typeof (Address)).GetInstanceAs<IFlattener>(); + /// IFlattener flattener1 = container.ForGenericType(typeof (IFlattener<>)) + /// .WithParameters(typeof (Address)).GetInstanceAs<IFlattener>(); /// </example> public static Container.OpenGenericTypeExpression ForGenericType(Type templateType) { Modified: trunk/Source/StructureMap/Pipeline/ConditionalInstance.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/ConditionalInstance.cs 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap/Pipeline/ConditionalInstance.cs 2009-01-22 22:33:20 UTC (rev 227) @@ -17,9 +17,9 @@ public Instance _default = new DefaultInstance(); - public ConditionalInstance(Action<ConditionalInstanceExpression<T>> action) + public ConditionalInstance(Action<ConditionalInstanceExpression> action) { - action(new ConditionalInstanceExpression<T>(this)); + action(new ConditionalInstanceExpression(this)); } protected override string getDescription() @@ -40,7 +40,7 @@ return instance.Build(pluginType, session); } - public class ConditionalInstanceExpression<T> + public class ConditionalInstanceExpression { private readonly ConditionalInstance<T> _parent; Modified: trunk/Source/StructureMap/Pipeline/ConfiguredInstanceBase.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/ConfiguredInstanceBase.cs 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap/Pipeline/ConfiguredInstanceBase.cs 2009-01-22 22:33:20 UTC (rev 227) @@ -214,14 +214,14 @@ return _pluggedType; } - protected string findPropertyName<T>() + protected string findPropertyName<PLUGINTYPE>() { var plugin = new Plugin(_pluggedType); string propertyName = plugin.FindArgumentNameForType<T>(); if (string.IsNullOrEmpty(propertyName)) { - throw new StructureMapException(305, typeof (T)); + throw new StructureMapException(305, typeof(PLUGINTYPE)); } return propertyName; Modified: trunk/Source/StructureMap/Pipeline/DefaultInstance.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/DefaultInstance.cs 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap/Pipeline/DefaultInstance.cs 2009-01-22 22:33:20 UTC (rev 227) @@ -4,11 +4,6 @@ { public class DefaultInstance : Instance { - public DefaultInstance() - { - int x = 1; - } - protected override bool doesRecordOnTheStack { get { return false; } Modified: trunk/Source/StructureMap/Pipeline/Instance.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/Instance.cs 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap/Pipeline/Instance.cs 2009-01-22 22:33:20 UTC (rev 227) @@ -133,7 +133,7 @@ { return build(pluginType, session); } - catch (StructureMapException ex) + catch (StructureMapException) { throw; } Modified: trunk/Source/StructureMap/Pipeline/SmartInstance.cs =================================================================== --- trunk/Source/StructureMap/Pipeline/SmartInstance.cs 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap/Pipeline/SmartInstance.cs 2009-01-22 22:33:20 UTC (rev 227) @@ -34,7 +34,6 @@ /// Register an Action to perform on the object created by this Instance /// before it is returned to the caller /// </summary> - /// <typeparam name="T"></typeparam> /// <param name="handler"></param> /// <returns></returns> public SmartInstance<T> OnCreation(Action<T> handler) @@ -49,7 +48,6 @@ /// Register an Action to perform on the object created by this Instance /// before it is returned to the caller /// </summary> - /// <typeparam name="T"></typeparam> /// <param name="handler"></param> /// <returns></returns> public SmartInstance<T> OnCreation(Action<IContext, T> handler) @@ -192,7 +190,7 @@ /// </summary> /// <typeparam name="CTORTYPE"></typeparam> /// <returns></returns> - public DependencyExpression<T, CTORTYPE> CtorDependency<CTORTYPE>() + public DependencyExpression<CTORTYPE> CtorDependency<CTORTYPE>() { string constructorArg = getArgumentNameForType<CTORTYPE>(); return CtorDependency<CTORTYPE>(constructorArg); @@ -211,9 +209,9 @@ /// <typeparam name="CTORTYPE"></typeparam> /// <param name="constructorArg"></param> /// <returns></returns> - public DependencyExpression<T, CTORTYPE> CtorDependency<CTORTYPE>(string constructorArg) + public DependencyExpression<CTORTYPE> CtorDependency<CTORTYPE>(string constructorArg) { - return new DependencyExpression<T, CTORTYPE>(this, constructorArg); + return new DependencyExpression<CTORTYPE>(this, constructorArg); } /// <summary> @@ -222,11 +220,11 @@ /// <typeparam name="SETTERTYPE"></typeparam> /// <param name="expression"></param> /// <returns></returns> - public DependencyExpression<T, SETTERTYPE> SetterDependency<SETTERTYPE>( + public DependencyExpression<SETTERTYPE> SetterDependency<SETTERTYPE>( Expression<Func<T, SETTERTYPE>> expression) { string propertyName = ReflectionHelper.GetProperty(expression).Name; - return new DependencyExpression<T, SETTERTYPE>(this, propertyName); + return new DependencyExpression<SETTERTYPE>(this, propertyName); } /// <summary> @@ -235,7 +233,7 @@ /// </summary> /// <typeparam name="SETTERTYPE"></typeparam> /// <returns></returns> - public DependencyExpression<T, SETTERTYPE> SetterDependency<SETTERTYPE>() + public DependencyExpression<SETTERTYPE> SetterDependency<SETTERTYPE>() { return CtorDependency<SETTERTYPE>(); } @@ -246,7 +244,7 @@ /// </summary> /// <typeparam name="CHILD"></typeparam> /// <returns></returns> - public ArrayDefinitionExpression<T, CHILD> TheArrayOf<CHILD>() + public ArrayDefinitionExpression<CHILD> TheArrayOf<CHILD>() { if (typeof (CHILD).IsArray) { @@ -266,9 +264,9 @@ /// <typeparam name="CHILD"></typeparam> /// <param name="ctorOrPropertyName"></param> /// <returns></returns> - public ArrayDefinitionExpression<T, CHILD> TheArrayOf<CHILD>(string ctorOrPropertyName) + public ArrayDefinitionExpression<CHILD> TheArrayOf<CHILD>(string ctorOrPropertyName) { - return new ArrayDefinitionExpression<T, CHILD>(this, ctorOrPropertyName); + return new ArrayDefinitionExpression<CHILD>(this, ctorOrPropertyName); } #region Nested type: ArrayDefinitionExpression @@ -276,9 +274,8 @@ /// <summary> /// Expression Builder to help define multiple Instances for an Array dependency /// </summary> - /// <typeparam name="T"></typeparam> /// <typeparam name="ARRAY"></typeparam> - public class ArrayDefinitionExpression<T, ARRAY> + public class ArrayDefinitionExpression<ARRAY> { private readonly SmartInstance<T> _instance; private readonly string _propertyName; @@ -298,7 +295,7 @@ { var list = new List<Instance>(); - var child = new InstanceExpression<ARRAY>(i => list.Add(i)); + var child = new InstanceExpression<ARRAY>(list.Add); action(child); _instance.setChildArray(_propertyName, list.ToArray()); @@ -326,9 +323,8 @@ /// <summary> /// Expression Builder that helps to define child dependencies inline /// </summary> - /// <typeparam name="T"></typeparam> /// <typeparam name="CHILD"></typeparam> - public class DependencyExpression<T, CHILD> + public class DependencyExpression<CHILD> { private readonly SmartInstance<T> _instance; private readonly string _propertyName; Modified: trunk/Source/StructureMap/StructureMap.csproj =================================================================== --- trunk/Source/StructureMap/StructureMap.csproj 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap/StructureMap.csproj 2009-01-22 22:33:20 UTC (rev 227) @@ -56,13 +56,12 @@ <DebugSymbols>true</DebugSymbols> <FileAlignment>4096</FileAlignment> <NoStdLib>false</NoStdLib> - <NoWarn> - </NoWarn> + <NoWarn>618,1591</NoWarn> <Optimize>false</Optimize> <RegisterForComInterop>false</RegisterForComInterop> <RemoveIntegerChecks>false</RemoveIntegerChecks> <TreatWarningsAsErrors>false</TreatWarningsAsErrors> - <WarningLevel>0</WarningLevel> + <WarningLevel>4</WarningLevel> <DebugType>full</DebugType> <ErrorReport>prompt</ErrorReport> </PropertyGroup> @@ -78,12 +77,11 @@ <DebugSymbols>true</DebugSymbols> <FileAlignment>4096</FileAlignment> <NoStdLib>false</NoStdLib> - <NoWarn> - </NoWarn> + <NoWarn>618,1591</NoWarn> <Optimize>true</Optimize> <RegisterForComInterop>false</RegisterForComInterop> <RemoveIntegerChecks>false</RemoveIntegerChecks> - <TreatWarningsAsErrors>false</TreatWarningsAsErrors> + <TreatWarningsAsErrors>true</TreatWarningsAsErrors> <WarningLevel>4</WarningLevel> <DebugType>pdbonly</DebugType> <ErrorReport>prompt</ErrorReport> @@ -100,8 +98,7 @@ <DebugSymbols>true</DebugSymbols> <FileAlignment>4096</FileAlignment> <NoStdLib>false</NoStdLib> - <NoWarn> - </NoWarn> + <NoWarn>618, 1591</NoWarn> <Optimize>false</Optimize> <RegisterForComInterop>false</RegisterForComInterop> <RemoveIntegerChecks>false</RemoveIntegerChecks> Modified: trunk/Source/StructureMap.AutoMocking/AutoMocker.cs =================================================================== --- trunk/Source/StructureMap.AutoMocking/AutoMocker.cs 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap.AutoMocking/AutoMocker.cs 2009-01-22 22:33:20 UTC (rev 227) @@ -10,8 +10,7 @@ public interface IAutoMocker<TARGETCLASS> where TARGETCLASS : class { /// <summary> - ///Gets an instance of the ClassUnderTest with mock objects (or stubs) pushed in -// for all of its dependencies + ///Gets an instance of the ClassUnderTest with mock objects (or stubs) pushed in for all of its dependencies /// </summary> TARGETCLASS ClassUnderTest { get; } @@ -101,8 +100,7 @@ protected ServiceLocator _serviceLocator; /// <summary> - ///Gets an instance of the ClassUnderTest with mock objects (or stubs) pushed in - // for all of its dependencies + ///Gets an instance of the ClassUnderTest with mock objects (or stubs) pushed in for all of its dependencies /// </summary> public TARGETCLASS ClassUnderTest { Modified: trunk/Source/StructureMap.AutoMocking/StructureMap.AutoMocking.csproj =================================================================== --- trunk/Source/StructureMap.AutoMocking/StructureMap.AutoMocking.csproj 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap.AutoMocking/StructureMap.AutoMocking.csproj 2009-01-22 22:33:20 UTC (rev 227) @@ -42,6 +42,7 @@ <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <DocumentationFile>bin\Debug\StructureMap.AutoMocking.XML</DocumentationFile> + <NoWarn>1591</NoWarn> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <DebugType>pdbonly</DebugType> @@ -51,6 +52,8 @@ <ErrorReport>prompt</ErrorReport> <WarningLevel>4</WarningLevel> <DocumentationFile>bin\Release\StructureMap.AutoMocking.XML</DocumentationFile> + <NoWarn>1591</NoWarn> + <TreatWarningsAsErrors>true</TreatWarningsAsErrors> </PropertyGroup> <ItemGroup> <Reference Include="System" /> Modified: trunk/Source/StructureMap.Testing/AutoMocking/RhinoAutoMockerTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/AutoMocking/RhinoAutoMockerTester.cs 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap.Testing/AutoMocking/RhinoAutoMockerTester.cs 2009-01-22 22:33:20 UTC (rev 227) @@ -95,10 +95,5 @@ autoMocker.Get<IMockedService>().AssertWasCalled(s => s.Go()); } - public interface IAnotherService - { - - } - } } \ No newline at end of file Modified: trunk/Source/StructureMap.Testing/Pipeline/ConditionalInstanceTester.cs =================================================================== --- trunk/Source/StructureMap.Testing/Pipeline/ConditionalInstanceTester.cs 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap.Testing/Pipeline/ConditionalInstanceTester.cs 2009-01-22 22:33:20 UTC (rev 227) @@ -14,7 +14,6 @@ private Rule Blue = new ColorRule("blue"); private Rule Default = new ColorRule("black"); - private Rule _rule; private BuildSession _session; private void TheRequestedNameIs(string name) @@ -40,7 +39,6 @@ _session = new BuildSession(); - _rule = null; } [Test] @@ -90,7 +88,7 @@ var container = new Container(x => { x.ForRequestedType<Rule>().TheDefault.IsThis(DEFAULT); - x.InstanceOf<Rule>().Is.Conditional(o => + x.InstanceOf<Rule>().Is.Conditional(o => { o.If(c => false).ThenIt.Is.OfConcreteType<ARule>(); }).WithName("conditional"); Modified: trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj =================================================================== --- trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-01-21 00:53:11 UTC (rev 226) +++ trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-01-22 22:33:20 UTC (rev 227) @@ -57,8 +57,7 @@ <DebugSymbols>true</DebugSymbols> <FileAlignment>4096</FileAlignment> <NoStdLib>false</NoStdLib> - <NoWarn> - </NoWarn> + <NoWarn>618</NoWarn> <Optimize>false</Optimize> <RegisterForComInterop>false</RegisterForComInterop> <RemoveIntegerChecks>false</RemoveIntegerChecks> @@ -80,8 +79,7 @@ <DebugSymbols>false</DebugSymbols> <FileAlignment>4096</FileAlignment> <NoStdLib>false</NoStdLib> - <NoWarn> - </NoWarn> + <NoWarn>618</NoWarn> <Optimize>true</Optimize> <RegisterForComInterop>false</RegisterForComInterop> <RemoveIntegerChecks>false</RemoveIntegerChecks> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jer...@us...> - 2009-01-21 00:53:15
|
Revision: 226 http://structuremap.svn.sourceforge.net/structuremap/?rev=226&view=rev Author: jeremydmiller Date: 2009-01-21 00:53:11 +0000 (Wed, 21 Jan 2009) Log Message: ----------- marked some methods on PluginGraph virtual for testability concerns Modified Paths: -------------- trunk/Source/StructureMap/Graph/PluginGraph.cs trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj Added Paths: ----------- trunk/Source/StructureMap.Testing/Bugs/BuildUpBug.cs Modified: trunk/Source/StructureMap/Graph/PluginGraph.cs =================================================================== --- trunk/Source/StructureMap/Graph/PluginGraph.cs 2009-01-19 18:57:33 UTC (rev 225) +++ trunk/Source/StructureMap/Graph/PluginGraph.cs 2009-01-21 00:53:11 UTC (rev 226) @@ -178,7 +178,7 @@ /// </summary> /// <param name="pluginType"></param> /// <param name="concreteType"></param> - public void AddType(Type pluginType, Type concreteType) + public virtual void AddType(Type pluginType, Type concreteType) { FindFamily(pluginType).AddType(concreteType); } @@ -189,7 +189,7 @@ /// <param name="pluginType"></param> /// <param name="concreteType"></param> /// <param name="name"></param> - public void AddType(Type pluginType, Type concreteType, string name) + public virtual void AddType(Type pluginType, Type concreteType, string name) { FindFamily(pluginType).AddType(concreteType, name); } @@ -199,7 +199,7 @@ /// could be assigned to the pluginType /// </summary> /// <param name="pluggedType"></param> - public void AddType(Type pluggedType) + public virtual void AddType(Type pluggedType) { _pluggedTypes.Add(pluggedType); } Added: trunk/Source/StructureMap.Testing/Bugs/BuildUpBug.cs =================================================================== --- trunk/Source/StructureMap.Testing/Bugs/BuildUpBug.cs (rev 0) +++ trunk/Source/StructureMap.Testing/Bugs/BuildUpBug.cs 2009-01-21 00:53:11 UTC (rev 226) @@ -0,0 +1,57 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using NUnit.Framework; + +namespace StructureMap.Testing.Bugs +{ + [TestFixture] + public class StructureMapTests + { + [Test] + public void Test() + { + ObjectFactory.Initialize(x => + { + x.UseDefaultStructureMapConfigFile = false; + + x.ForConcreteType<SomeDbRepository>().Configure. + WithCtorArg("connectionString").EqualTo("some connection string"); + + //x.ForConcreteType<SomeWebPage>().Configure. + // SetterDependency<SomeDbRepository>().Is<SomeDbRepository>(); + + x.SetAllProperties(o => o.OfType<SomeDbRepository>()); + }); + + SomeDbRepository dbRepository = + ObjectFactory.GetInstance<SomeDbRepository>(); + + SomeWebPage webPage = new SomeWebPage(); + + ObjectFactory.BuildUp(webPage); + + webPage.DbRepository.ConnectionString.ShouldEqual("some connection string"); + } + } + + public class SomeDbRepository + { + public SomeDbRepository(string connectionString) + { + this.ConnectionString = connectionString; + } + + public string ConnectionString { get; set; } + + // ... + } + + public class SomeWebPage + { + public SomeDbRepository DbRepository { get; set; } + + // ... + } +} Modified: trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj =================================================================== --- trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-01-19 18:57:33 UTC (rev 225) +++ trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj 2009-01-21 00:53:11 UTC (rev 226) @@ -179,6 +179,7 @@ <Compile Include="AutoMocking\RhinoAutoMockerTester.cs" /> <Compile Include="AutoMocking\RhinoMockRepositoryProxyTester.cs" /> <Compile Include="AutoWiringExamples.cs" /> + <Compile Include="Bugs\BuildUpBug.cs" /> <Compile Include="Bugs\IDictionaryAndXmlBugTester.cs" /> <Compile Include="Bugs\ScanIndexerBugTester.cs" /> <Compile Include="Bugs\SingletonShouldBeLazy.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |