|
From: <jer...@us...> - 2009-12-29 04:51:24
|
Revision: 316
http://structuremap.svn.sourceforge.net/structuremap/?rev=316&view=rev
Author: jeremydmiller
Date: 2009-12-29 04:51:11 +0000 (Tue, 29 Dec 2009)
Log Message:
-----------
fix to the explicit args functionality introduced in the recent changes
Modified Paths:
--------------
trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs
trunk/Source/StructureMap/Graph/Plugin.cs
trunk/Source/StructureMap/Pipeline/ConstructorInstance.cs
trunk/Source/StructureMap/Pipeline/ExplicitArguments.cs
trunk/Source/StructureMap/Pipeline/IConfiguredInstance.cs
trunk/Source/StructureMap.Testing/Configuration/DSL/GenericFamilyExpressionTester.cs
trunk/Source/StructureMap.Testing/Examples/Interception.cs
trunk/Source/StructureMap.Testing/GenericsIntegrationTester.cs
Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2009-12-29 03:50:13 UTC (rev 315)
+++ trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2009-12-29 04:51:11 UTC (rev 316)
@@ -120,6 +120,11 @@
return TheDefault.Is.ConstructedBy(func);
}
+ public void Use(Instance instance)
+ {
+ TheDefault.IsThis(instance);
+ }
+
/// <summary>
/// Shorthand to say TheDefault.IsThis(@object)
/// </summary>
Modified: trunk/Source/StructureMap/Graph/Plugin.cs
===================================================================
--- trunk/Source/StructureMap/Graph/Plugin.cs 2009-12-29 03:50:13 UTC (rev 315)
+++ trunk/Source/StructureMap/Graph/Plugin.cs 2009-12-29 04:51:11 UTC (rev 316)
@@ -74,7 +74,7 @@
public string FindArgumentNameForType<T>()
{
- return FindArgumentNameForType(typeof (T));
+ return FindArgumentNameForType(typeof (T), CannotFindProperty.ThrowException);
}
public string FindArgumentNameForEnumerableOf(Type type)
@@ -87,13 +87,13 @@
}).FirstOrDefault(x => x != null);
}
- public string FindArgumentNameForType(Type type)
+ public string FindArgumentNameForType(Type type, CannotFindProperty cannotFind)
{
string returnValue =
_constructor.FindFirstConstructorArgumentOfType(type) ??
_setters.FindFirstWriteablePropertyOfType(type);
- if (returnValue == null)
+ if (returnValue == null && cannotFind == CannotFindProperty.ThrowException)
{
throw new StructureMapException(302, type.FullName, _pluggedType.FullName);
}
Modified: trunk/Source/StructureMap/Pipeline/ConstructorInstance.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/ConstructorInstance.cs 2009-12-29 03:50:13 UTC (rev 315)
+++ trunk/Source/StructureMap/Pipeline/ConstructorInstance.cs 2009-12-29 04:51:11 UTC (rev 316)
@@ -47,10 +47,10 @@
SetChild(name, instance);
}
- public void SetValue(Type type, object value)
+ public void SetValue(Type type, object value, CannotFindProperty cannotFind)
{
- string name = _plugin.FindArgumentNameForType(type);
- SetValue(name, value);
+ string name = _plugin.FindArgumentNameForType(type, cannotFind);
+ if (name != null) SetValue(name, value);
}
void IConfiguredInstance.SetValue(string name, object value)
@@ -175,7 +175,7 @@
protected string findPropertyName(Type dependencyType)
{
- string propertyName = _plugin.FindArgumentNameForType(dependencyType);
+ string propertyName = _plugin.FindArgumentNameForType(dependencyType, CannotFindProperty.ThrowException);
if (string.IsNullOrEmpty(propertyName))
{
Modified: trunk/Source/StructureMap/Pipeline/ExplicitArguments.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/ExplicitArguments.cs 2009-12-29 03:50:13 UTC (rev 315)
+++ trunk/Source/StructureMap/Pipeline/ExplicitArguments.cs 2009-12-29 04:51:11 UTC (rev 316)
@@ -52,7 +52,11 @@
{
_args.Each(pair => { instance.SetValue(pair.Key, pair.Value); });
- _children.Each(pair => { instance.SetValue(pair.Key, pair.Value); });
+ _children.Each(pair =>
+ {
+ instance.SetValue(pair.Key, pair.Value, CannotFindProperty.Ignore);
+
+ });
}
public bool Has(Type type)
Modified: trunk/Source/StructureMap/Pipeline/IConfiguredInstance.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/IConfiguredInstance.cs 2009-12-29 03:50:13 UTC (rev 315)
+++ trunk/Source/StructureMap/Pipeline/IConfiguredInstance.cs 2009-12-29 04:51:11 UTC (rev 316)
@@ -3,6 +3,12 @@
namespace StructureMap.Pipeline
{
+ public enum CannotFindProperty
+ {
+ ThrowException,
+ Ignore
+ }
+
public interface IConfiguredInstance
{
string Name { get; }
@@ -15,7 +21,7 @@
bool HasProperty(string propertyName, BuildSession session);
void SetChild(string name, Instance instance);
- void SetValue(Type type, object value);
+ void SetValue(Type type, object value, CannotFindProperty cannotFind);
void SetValue(string name, object value);
void SetCollection(string name, IEnumerable<Instance> children);
Modified: trunk/Source/StructureMap.Testing/Configuration/DSL/GenericFamilyExpressionTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Configuration/DSL/GenericFamilyExpressionTester.cs 2009-12-29 03:50:13 UTC (rev 315)
+++ trunk/Source/StructureMap.Testing/Configuration/DSL/GenericFamilyExpressionTester.cs 2009-12-29 04:51:11 UTC (rev 316)
@@ -117,21 +117,7 @@
container.GetInstance<ITarget>().ShouldBeOfType<Target2>();
}
- [Test, Explicit]
- public void Add_default_instance2()
- {
- var container =
- new Container(
- r => { r.ForRequestedType(typeof (IRepository<>)).TheDefaultIsConcreteType(typeof (OnlineRepository<>)); });
- Assert.IsInstanceOfType(typeof (Target2), container.GetInstance<ITarget>());
-
-
- var repository =
- ObjectFactory.GetInstance<IRepository<Invoice>>();
- }
-
-
[Test]
public void Add_instance_directly()
{
Modified: trunk/Source/StructureMap.Testing/Examples/Interception.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Examples/Interception.cs 2009-12-29 03:50:13 UTC (rev 315)
+++ trunk/Source/StructureMap.Testing/Examples/Interception.cs 2009-12-29 04:51:11 UTC (rev 316)
@@ -16,7 +16,6 @@
{
public void StartConnection()
{
- throw new NotImplementedException();
}
public void Start()
@@ -96,19 +95,6 @@
}
}
- [TestFixture, Explicit]
- public class InterceptionRegistryInAction
- {
- [Test]
- public void see_the_enrichment_with_a_decorator_in_action()
- {
- var container = new Container(new InterceptionRegistry());
- container.GetInstance<IConnectionListener>()
- .ShouldBeOfType<LoggingDecorator>()
- .Inner.ShouldBeOfType<ClassThatNeedsSomeBootstrapping>();
- }
- }
-
public class CustomInterceptor : InstanceInterceptor
{
public object Process(object target, IContext context)
Modified: trunk/Source/StructureMap.Testing/GenericsIntegrationTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/GenericsIntegrationTester.cs 2009-12-29 03:50:13 UTC (rev 315)
+++ trunk/Source/StructureMap.Testing/GenericsIntegrationTester.cs 2009-12-29 04:51:11 UTC (rev 316)
@@ -6,7 +6,7 @@
namespace StructureMap.Testing
{
- [TestFixture, Ignore("Putting right back on")]
+ [TestFixture]
public class GenericsIntegrationTester
{
#region Setup/Teardown
@@ -49,7 +49,7 @@
private Container manager;
- [Test]
+ [Test, Ignore("not sure I want this behavior anyway")]
public void AllTypesWithSpecificImplementation()
{
IList objectConcepts = manager.GetAllInstances(typeof (IConcept<object>));
@@ -136,7 +136,7 @@
Assert.AreNotSame(object1, object4);
}
- [Test]
+ [Test, Ignore("not sure we want this behavior anyway")]
public void SpecificImplementation()
{
var concept = (IConcept<object>) manager.GetInstance(typeof (IConcept<object>), "Specific");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|