|
From: <jer...@us...> - 2008-08-19 01:24:42
|
Revision: 140
http://structuremap.svn.sourceforge.net/structuremap/?rev=140&view=rev
Author: jeremydmiller
Date: 2008-08-19 01:24:37 +0000 (Tue, 19 Aug 2008)
Log Message:
-----------
refactored ConfiguredInstance
Modified Paths:
--------------
trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs
trunk/Source/StructureMap/Configuration/DSL/Registry.cs
trunk/Source/StructureMap/Pipeline/ConfiguredInstance.Expressions.cs
trunk/Source/StructureMap/Pipeline/ConfiguredInstance.cs
trunk/Source/StructureMap/Pipeline/ExplicitArguments.cs
trunk/Source/StructureMap/Pipeline/IConfiguredInstance.cs
trunk/Source/StructureMap/Pipeline/InstanceMementoPropertyReader.cs
trunk/Source/StructureMap/StructureMap.csproj
trunk/Source/StructureMap.Testing/Graph/ContainerTester.cs
trunk/Source/StructureMap.Testing/Pipeline/ConfiguredInstanceTester.cs
trunk/Source/StructureMap.Testing/Pipeline/OptionalSetterInjectionTester.cs
trunk/Source/StructureMap.Testing.Widget/Rule.cs
Added Paths:
-----------
trunk/Source/StructureMap/Pipeline/ConfiguredInstanceBase.cs
Removed Paths:
-------------
trunk/Source/StructureMap/Pipeline/ConfiguredInstance.Building.cs
Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2008-08-16 16:44:23 UTC (rev 139)
+++ trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2008-08-19 01:24:37 UTC (rev 140)
@@ -146,11 +146,13 @@
return this;
}
+ [Obsolete("Kill!")]
public CreatePluginFamilyExpression<PLUGINTYPE> AddConcreteType<CONCRETETYPE>()
{
return AddConcreteType<CONCRETETYPE>(Guid.NewGuid().ToString());
}
+ [Obsolete("Kill!")]
public CreatePluginFamilyExpression<PLUGINTYPE> AddConcreteType<CONCRETETYPE>(string instanceName)
{
ExpressionValidator.ValidatePluggabilityOf(typeof (CONCRETETYPE)).IntoPluginType(typeof (PLUGINTYPE));
@@ -179,23 +181,27 @@
return this;
}
+ [Obsolete("Kill!")]
public CreatePluginFamilyExpression<PLUGINTYPE> TheDefaultIs(PLUGINTYPE @object)
{
return TheDefaultIs(new LiteralInstance(@object));
}
+ [Obsolete("Kill!")]
public CreatePluginFamilyExpression<PLUGINTYPE> TheDefaultIs(Func<PLUGINTYPE> func)
{
ConstructorInstance instance = new ConstructorInstance(() => func());
return TheDefaultIs(instance);
}
+ [Obsolete("Kill!")]
public CreatePluginFamilyExpression<PLUGINTYPE> AddInstance(PLUGINTYPE @object)
{
LiteralInstance instance = new LiteralInstance(@object);
return AddInstance(instance);
}
+ [Obsolete("Kill!")]
public CreatePluginFamilyExpression<PLUGINTYPE> AddInstance(Func<PLUGINTYPE> func)
{
ConstructorInstance instance = new ConstructorInstance(() => func());
Modified: trunk/Source/StructureMap/Configuration/DSL/Registry.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2008-08-16 16:44:23 UTC (rev 139)
+++ trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2008-08-19 01:24:37 UTC (rev 140)
@@ -88,11 +88,13 @@
/// </summary>
/// <typeparam name="PLUGINTYPE"></typeparam>
/// <returns></returns>
+ [Obsolete("Like to go away")]
public ConfiguredInstanceExpression<PLUGINTYPE> AddInstanceOf<PLUGINTYPE>()
{
return new ConfiguredInstanceExpression<PLUGINTYPE>(this);
}
+ [Obsolete("Like to get rid of this")]
public class ConfiguredInstanceExpression<PLUGINTYPE>
{
private readonly Registry _registry;
@@ -102,15 +104,7 @@
_registry = registry;
}
- /*
- ConfiguredInstance instance = new ConfiguredInstance();
- addExpression(
- pluginGraph => pluginGraph.FindFamily(typeof (PLUGINTYPE)).AddInstance(instance));
-
- return instance;
- */
-
public ConfiguredInstance UsingConcreteType<T>()
{
ConfiguredInstance instance = new ConfiguredInstance(typeof(T));
@@ -127,6 +121,7 @@
/// <typeparam name="PLUGINTYPE"></typeparam>
/// <param name="target"></param>
/// <returns></returns>
+ [Obsolete("Like to get rid of this")]
public LiteralInstance AddInstanceOf<PLUGINTYPE>(PLUGINTYPE target)
{
LiteralInstance literal = new LiteralInstance(target);
@@ -141,6 +136,7 @@
/// <typeparam name="PLUGINTYPE"></typeparam>
/// <param name="prototype"></param>
/// <returns></returns>
+ [Obsolete("Like to get rid of this")]
public PrototypeInstance AddPrototypeInstanceOf<PLUGINTYPE>(PLUGINTYPE prototype)
{
PrototypeInstance instance = new PrototypeInstance((ICloneable) prototype);
@@ -154,6 +150,7 @@
/// </summary>
/// <param name="url"></param>
/// <returns></returns>
+ [Obsolete("Like to get rid of this")]
public static UserControlInstance LoadUserControlFrom(string url)
{
return new UserControlInstance(url);
@@ -209,12 +206,13 @@
return new ScanAssembliesExpression(this);
}
-
+ [Obsolete("Like to get rid of this")]
public void AddInstanceOf(Type pluginType, Instance instance)
{
_actions.Add(graph => graph.FindFamily(pluginType).AddInstance(instance));
}
+ [Obsolete("Like to get rid of this")]
public void AddInstanceOf<PLUGINTYPE>(Instance instance)
{
_actions.Add(graph => graph.FindFamily(typeof (PLUGINTYPE)).AddInstance(instance));
Deleted: trunk/Source/StructureMap/Pipeline/ConfiguredInstance.Building.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/ConfiguredInstance.Building.cs 2008-08-16 16:44:23 UTC (rev 139)
+++ trunk/Source/StructureMap/Pipeline/ConfiguredInstance.Building.cs 2008-08-19 01:24:37 UTC (rev 140)
@@ -1,73 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Text;
-
-namespace StructureMap.Pipeline
-{
- public partial class ConfiguredInstance
- {
- Type IConfiguredInstance.PluggedType
- {
- get { return _pluggedType; }
- }
-
- Instance[] IConfiguredInstance.GetChildrenArray(string propertyName)
- {
- return _arrays.ContainsKey(propertyName) ? _arrays[propertyName] : null;
- }
-
- string IConfiguredInstance.GetProperty(string propertyName)
- {
- if (!_properties.ContainsKey(propertyName))
- {
- throw new StructureMapException(205, propertyName, Name);
- }
-
- return _properties[propertyName];
- }
-
- object IConfiguredInstance.GetChild(string propertyName, Type pluginType, BuildSession buildSession)
- {
- return getChild(propertyName, pluginType, buildSession);
- }
-
-
- // Only open for testing
- object IConfiguredInstance.Build(Type pluginType, BuildSession session, InstanceBuilder builder)
- {
- if (builder == null)
- {
- throw new StructureMapException(
- 201, _pluggedType.FullName, Name, pluginType);
- }
-
-
- try
- {
- return builder.BuildInstance(this, session);
- }
- catch (StructureMapException)
- {
- throw;
- }
- catch (InvalidCastException ex)
- {
- throw new StructureMapException(206, ex, Name);
- }
- catch (Exception ex)
- {
- throw new StructureMapException(207, ex, Name, pluginType.FullName);
- }
- }
-
- bool IConfiguredInstance.HasProperty(string propertyName)
- {
- return _properties.ContainsKey(propertyName) || _children.ContainsKey(propertyName) || _arrays.ContainsKey(propertyName);
- }
-
- protected override Type getConcreteType()
- {
- return _pluggedType;
- }
- }
-}
Modified: trunk/Source/StructureMap/Pipeline/ConfiguredInstance.Expressions.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/ConfiguredInstance.Expressions.cs 2008-08-16 16:44:23 UTC (rev 139)
+++ trunk/Source/StructureMap/Pipeline/ConfiguredInstance.Expressions.cs 2008-08-19 01:24:37 UTC (rev 140)
@@ -77,28 +77,6 @@
return new PropertyExpression(this, propertyName);
}
-
- private string findPropertyName<T>()
- {
- Plugin plugin = new Plugin(_pluggedType);
- string propertyName = plugin.FindArgumentNameForType<T>();
-
- if (string.IsNullOrEmpty(propertyName))
- {
- throw new StructureMapException(305, typeof (T));
- }
-
- return propertyName;
- }
-
- private static void validateTypeIsArray<PLUGINTYPE>()
- {
- if (!typeof (PLUGINTYPE).IsArray)
- {
- throw new StructureMapException(307);
- }
- }
-
#region Nested type: ChildArrayExpression
public class ChildArrayExpression
@@ -236,7 +214,7 @@
/// <returns></returns>
public ConfiguredInstance EqualTo(object propertyValue)
{
- _instance.SetProperty(_propertyName, propertyValue.ToString());
+ _instance.setProperty(_propertyName, propertyValue.ToString());
return _instance;
}
@@ -249,7 +227,7 @@
public ConfiguredInstance EqualToAppSetting(string appSettingKey)
{
string propertyValue = ConfigurationManager.AppSettings[appSettingKey];
- _instance.SetProperty(_propertyName, propertyValue);
+ _instance.setProperty(_propertyName, propertyValue);
return _instance;
}
}
Modified: trunk/Source/StructureMap/Pipeline/ConfiguredInstance.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/ConfiguredInstance.cs 2008-08-16 16:44:23 UTC (rev 139)
+++ trunk/Source/StructureMap/Pipeline/ConfiguredInstance.cs 2008-08-19 01:24:37 UTC (rev 140)
@@ -4,31 +4,19 @@
namespace StructureMap.Pipeline
{
- public partial class ConfiguredInstance : ExpressedInstance<ConfiguredInstance>, IConfiguredInstance,
- IStructuredInstance
+ public partial class ConfiguredInstance : ConfiguredInstanceBase<ConfiguredInstance>
{
- private Dictionary<string, Instance> _children = new Dictionary<string, Instance>();
- private Dictionary<string, string> _properties = new Dictionary<string, string>();
- private Dictionary<string, Instance[]> _arrays = new Dictionary<string, Instance[]>();
-
- private Type _pluggedType;
-
-
- public ConfiguredInstance(InstanceMemento memento, PluginGraph graph, Type pluginType)
+ public ConfiguredInstance(InstanceMemento memento, PluginGraph graph, Type pluginType) : base(memento, graph, pluginType)
{
- read(memento, graph, pluginType);
}
- public ConfiguredInstance(Type pluggedType, string name)
+ public ConfiguredInstance(Type pluggedType, string name) : base(pluggedType, name)
{
- _pluggedType = pluggedType;
- Name = name;
}
- public ConfiguredInstance(Type pluggedType)
+ public ConfiguredInstance(Type pluggedType) : base(pluggedType)
{
- _pluggedType = pluggedType;
}
@@ -39,21 +27,6 @@
#region IStructuredInstance Members
- Instance IStructuredInstance.GetChild(string name)
- {
- return _children[name];
- }
-
- Instance[] IStructuredInstance.GetChildArray(string name)
- {
- return _arrays[name];
- }
-
- void IStructuredInstance.RemoveKey(string name)
- {
- _properties.Remove(name);
- }
-
#endregion
protected void setPluggedType(Type pluggedType)
@@ -85,64 +58,7 @@
_arrays = instance._arrays;
}
- protected override object build(Type pluginType, BuildSession session)
- {
- InstanceBuilder builder = PluginCache.FindBuilder(_pluggedType);
- return ((IConfiguredInstance) this).Build(pluginType, session, builder);
- }
- protected virtual object getChild(string propertyName, Type pluginType, BuildSession buildSession)
- {
- Instance childInstance = _children.ContainsKey(propertyName)
- ? _children[propertyName]
- : new DefaultInstance();
-
-
- return childInstance.Build(pluginType, buildSession);
- }
-
-
- protected override bool canBePartOfPluginFamily(PluginFamily family)
- {
- return TypeRules.CanBeCast(family.PluginType, _pluggedType);
- }
-
- internal override bool Matches(Plugin plugin)
- {
- return plugin.PluggedType == _pluggedType;
- }
-
- public ConfiguredInstance SetProperty(string propertyName, string propertyValue)
- {
- _properties[propertyName] = propertyValue;
- return this;
- }
-
- private void read(InstanceMemento memento, PluginGraph graph, Type pluginType)
- {
- PluginFamily family = graph.FindFamily(pluginType);
- Plugin plugin = memento.FindPlugin(family);
-
- _pluggedType = plugin.PluggedType;
-
- InstanceMementoPropertyReader reader = new InstanceMementoPropertyReader(this, memento, graph, pluginType);
- plugin.VisitArguments(reader);
- }
-
-
- private void setChild(string name, Instance instance)
- {
- if (instance == null) return;
-
- _children.Add(name, instance);
- }
-
- private void setChildArray(string name, Instance[] array)
- {
- _arrays.Add(name, array);
- }
-
-
protected override void preprocess(PluginFamily family)
{
Added: trunk/Source/StructureMap/Pipeline/ConfiguredInstanceBase.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/ConfiguredInstanceBase.cs (rev 0)
+++ trunk/Source/StructureMap/Pipeline/ConfiguredInstanceBase.cs 2008-08-19 01:24:37 UTC (rev 140)
@@ -0,0 +1,198 @@
+using System;
+using System.Collections.Generic;
+using StructureMap.Graph;
+
+namespace StructureMap.Pipeline
+{
+ public abstract class ConfiguredInstanceBase<T> : ExpressedInstance<T>, IConfiguredInstance, IStructuredInstance
+ {
+ protected Dictionary<string, Instance> _children = new Dictionary<string, Instance>();
+ protected Dictionary<string, string> _properties = new Dictionary<string, string>();
+ protected Dictionary<string, Instance[]> _arrays = new Dictionary<string, Instance[]>();
+ protected Type _pluggedType;
+
+ protected ConfiguredInstanceBase(InstanceMemento memento, PluginGraph graph, Type pluginType)
+ {
+ read(memento, graph, pluginType);
+ }
+
+ protected ConfiguredInstanceBase(Type pluggedType, string name)
+ {
+ _pluggedType = pluggedType;
+ Name = name;
+ }
+
+ protected ConfiguredInstanceBase(Type pluggedType)
+ {
+ _pluggedType = pluggedType;
+ }
+
+
+ Type IConfiguredInstance.PluggedType
+ {
+ get { return _pluggedType; }
+ }
+
+ Instance IStructuredInstance.GetChild(string name)
+ {
+ return _children[name];
+ }
+
+ Instance[] IStructuredInstance.GetChildArray(string name)
+ {
+ return _arrays[name];
+ }
+
+ void IStructuredInstance.RemoveKey(string name)
+ {
+ _properties.Remove(name);
+ }
+
+ protected override object build(Type pluginType, BuildSession session)
+ {
+ InstanceBuilder builder = PluginCache.FindBuilder(_pluggedType);
+ return ((IConfiguredInstance) this).Build(pluginType, session, builder);
+ }
+
+ protected virtual object getChild(string propertyName, Type pluginType, BuildSession buildSession)
+ {
+ Instance childInstance = _children.ContainsKey(propertyName)
+ ? _children[propertyName]
+ : new DefaultInstance();
+
+
+ return childInstance.Build(pluginType, buildSession);
+ }
+
+ protected override bool canBePartOfPluginFamily(PluginFamily family)
+ {
+ return TypeRules.CanBeCast(family.PluginType, _pluggedType);
+ }
+
+ internal override bool Matches(Plugin plugin)
+ {
+ return plugin.PluggedType == _pluggedType;
+ }
+
+ private void read(InstanceMemento memento, PluginGraph graph, Type pluginType)
+ {
+ PluginFamily family = graph.FindFamily(pluginType);
+ Plugin plugin = memento.FindPlugin(family);
+
+ _pluggedType = plugin.PluggedType;
+
+ InstanceMementoPropertyReader reader = new InstanceMementoPropertyReader(this, memento, graph, pluginType);
+ plugin.VisitArguments(reader);
+ }
+
+ protected void setChild(string name, Instance instance)
+ {
+ if (instance == null) return;
+
+ _children.Add(name, instance);
+ }
+
+ protected void setChildArray(string name, Instance[] array)
+ {
+ _arrays.Add(name, array);
+ }
+
+ Instance[] IConfiguredInstance.GetChildrenArray(string propertyName)
+ {
+ return _arrays.ContainsKey(propertyName) ? _arrays[propertyName] : null;
+ }
+
+ string IConfiguredInstance.GetProperty(string propertyName)
+ {
+ if (!_properties.ContainsKey(propertyName))
+ {
+ throw new StructureMapException(205, propertyName, Name);
+ }
+
+ return _properties[propertyName];
+ }
+
+ object IConfiguredInstance.GetChild(string propertyName, Type pluginType, BuildSession buildSession)
+ {
+ return getChild(propertyName, pluginType, buildSession);
+ }
+
+ object IConfiguredInstance.Build(Type pluginType, BuildSession session, InstanceBuilder builder)
+ {
+ if (builder == null)
+ {
+ throw new StructureMapException(
+ 201, _pluggedType.FullName, Name, pluginType);
+ }
+
+
+ try
+ {
+ return builder.BuildInstance(this, session);
+ }
+ catch (StructureMapException)
+ {
+ throw;
+ }
+ catch (InvalidCastException ex)
+ {
+ throw new StructureMapException(206, ex, Name);
+ }
+ catch (Exception ex)
+ {
+ throw new StructureMapException(207, ex, Name, pluginType.FullName);
+ }
+ }
+
+ bool IConfiguredInstance.HasProperty(string propertyName)
+ {
+ return _properties.ContainsKey(propertyName) || _children.ContainsKey(propertyName) || _arrays.ContainsKey(propertyName);
+ }
+
+ protected override Type getConcreteType()
+ {
+ return _pluggedType;
+ }
+
+ protected string findPropertyName<T>()
+ {
+ Plugin plugin = new Plugin(_pluggedType);
+ string propertyName = plugin.FindArgumentNameForType<T>();
+
+ if (string.IsNullOrEmpty(propertyName))
+ {
+ throw new StructureMapException(305, typeof (T));
+ }
+
+ return propertyName;
+ }
+
+ protected static void validateTypeIsArray<PLUGINTYPE>()
+ {
+ if (!typeof (PLUGINTYPE).IsArray)
+ {
+ throw new StructureMapException(307);
+ }
+ }
+
+ void IConfiguredInstance.SetProperty(string propertyName, string propertyValue)
+ {
+ setProperty(propertyName, propertyValue);
+ }
+
+ protected void setProperty(string propertyName, string propertyValue)
+ {
+ _properties[propertyName] = propertyValue;
+ }
+
+ void IConfiguredInstance.SetChild(string name, Instance instance)
+ {
+ setChild(name, instance);
+ }
+
+ void IConfiguredInstance.SetChildArray(string name, Type type, Instance[] children)
+ {
+ setChildArray(name, children);
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Pipeline/ExplicitArguments.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/ExplicitArguments.cs 2008-08-16 16:44:23 UTC (rev 139)
+++ trunk/Source/StructureMap/Pipeline/ExplicitArguments.cs 2008-08-19 01:24:37 UTC (rev 140)
@@ -42,14 +42,14 @@
return _args.ContainsKey(key) ? _args[key] : null;
}
- public void Configure(ConfiguredInstance instance)
+ public void Configure(IConfiguredInstance instance)
{
foreach (KeyValuePair<string, object> arg in _args)
{
if (arg.Value == null) continue;
instance.SetProperty(arg.Key, arg.Value.ToString());
- instance.Child(arg.Key).Is(arg.Value);
+ instance.SetChild(arg.Key, new LiteralInstance(arg.Value));
}
}
Modified: trunk/Source/StructureMap/Pipeline/IConfiguredInstance.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/IConfiguredInstance.cs 2008-08-16 16:44:23 UTC (rev 139)
+++ trunk/Source/StructureMap/Pipeline/IConfiguredInstance.cs 2008-08-19 01:24:37 UTC (rev 140)
@@ -11,5 +11,10 @@
object GetChild(string propertyName, Type pluginType, BuildSession buildSession);
object Build(Type pluginType, BuildSession session, InstanceBuilder builder);
bool HasProperty(string propertyName);
+ void SetProperty(string name, string value);
+ void SetChild(string name, Instance instance);
+ void SetChildArray(string name, Type type, Instance[] children);
}
+
+
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Pipeline/InstanceMementoPropertyReader.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/InstanceMementoPropertyReader.cs 2008-08-16 16:44:23 UTC (rev 139)
+++ trunk/Source/StructureMap/Pipeline/InstanceMementoPropertyReader.cs 2008-08-19 01:24:37 UTC (rev 140)
@@ -6,12 +6,12 @@
{
public class InstanceMementoPropertyReader : IArgumentVisitor
{
- private readonly ConfiguredInstance _instance;
+ private readonly IConfiguredInstance _instance;
private readonly InstanceMemento _memento;
private readonly PluginGraph _pluginGraph;
private readonly Type _pluginType;
- public InstanceMementoPropertyReader(ConfiguredInstance instance, InstanceMemento memento,
+ public InstanceMementoPropertyReader(IConfiguredInstance instance, InstanceMemento memento,
PluginGraph pluginGraph, Type pluginType)
{
_instance = instance;
@@ -89,8 +89,8 @@
private void copyChild(string name, Type childType, bool isMandatory)
{
Instance childInstance = _memento.ReadChildInstance(name, _pluginGraph, childType);
-
- _instance.Child(name).Is(childInstance);
+
+ _instance.SetChild(name, childInstance);
}
private void copyChildArray(string name, Type childType)
@@ -104,7 +104,7 @@
children[i] = memento.ReadInstance(_pluginGraph, childType);
}
- _instance.ChildArray(name, childType).Contains(children);
+ _instance.SetChildArray(name, childType, children);
}
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/StructureMap.csproj
===================================================================
--- trunk/Source/StructureMap/StructureMap.csproj 2008-08-16 16:44:23 UTC (rev 139)
+++ trunk/Source/StructureMap/StructureMap.csproj 2008-08-19 01:24:37 UTC (rev 140)
@@ -406,7 +406,7 @@
<Compile Include="IBootstrapper.cs" />
<Compile Include="Pipeline\BuildFrame.cs" />
<Compile Include="Pipeline\BuildStack.cs" />
- <Compile Include="Pipeline\ConfiguredInstance.Building.cs" />
+ <Compile Include="Pipeline\ConfiguredInstanceBase.cs" />
<Compile Include="Pipeline\IStructuredInstance.cs" />
<Compile Include="Pipeline\SerializedInstance.cs" />
<Compile Include="ReflectionHelper.cs" />
Modified: trunk/Source/StructureMap.Testing/Graph/ContainerTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Graph/ContainerTester.cs 2008-08-16 16:44:23 UTC (rev 139)
+++ trunk/Source/StructureMap.Testing/Graph/ContainerTester.cs 2008-08-19 01:24:37 UTC (rev 140)
@@ -35,11 +35,9 @@
{
_manager.Configure(registry =>
{
- registry.AddInstanceOf<Rule>().UsingConcreteType<ColorRule>().SetProperty("color", Color).WithName(Color);
- registry.AddInstanceOf<IWidget>().UsingConcreteType<ColorWidget>().SetProperty("color", Color).WithName(
- Color);
- registry.AddInstanceOf<WidgetMaker>().UsingConcreteType<ColorWidgetMaker>().SetProperty("color", Color).
- WithName(Color);
+ registry.AddInstanceOf<Rule>().UsingConcreteType<ColorRule>().WithProperty("color").EqualTo(Color).WithName(Color);
+ registry.AddInstanceOf<IWidget>().UsingConcreteType<ColorWidget>().WithProperty("color").EqualTo(Color).WithName(Color);
+ registry.AddInstanceOf<WidgetMaker>().UsingConcreteType<ColorWidgetMaker>().WithProperty("color").EqualTo(Color).WithName(Color);
});
}
Modified: trunk/Source/StructureMap.Testing/Pipeline/ConfiguredInstanceTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Pipeline/ConfiguredInstanceTester.cs 2008-08-16 16:44:23 UTC (rev 139)
+++ trunk/Source/StructureMap.Testing/Pipeline/ConfiguredInstanceTester.cs 2008-08-19 01:24:37 UTC (rev 140)
@@ -96,7 +96,7 @@
{
ConfiguredInstance instance = (ConfiguredInstance) ComplexRule.GetInstance();
- instance.SetProperty("Int", "abc");
+ instance.WithProperty("Int").EqualTo("abc");
ComplexRule rule = (ComplexRule) instance.Build(typeof (Rule), _session);
}
@@ -149,15 +149,14 @@
public void GetProperty_happy_path()
{
ConfiguredInstance instance = new ConfiguredInstance(typeof(ColorRule))
- .SetProperty("Color", "Red")
- .SetProperty("Age", "34");
+ .WithProperty("Color").EqualTo("Red").WithProperty("Age").EqualTo("34");
IConfiguredInstance configuredInstance = instance;
Assert.AreEqual("Red", configuredInstance.GetProperty("Color"));
Assert.AreEqual("34", configuredInstance.GetProperty("Age"));
- instance.SetProperty("Color", "Blue");
+ instance.WithProperty("Color").EqualTo("Blue");
Assert.AreEqual("Blue", configuredInstance.GetProperty("Color"));
}
Modified: trunk/Source/StructureMap.Testing/Pipeline/OptionalSetterInjectionTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Pipeline/OptionalSetterInjectionTester.cs 2008-08-16 16:44:23 UTC (rev 139)
+++ trunk/Source/StructureMap.Testing/Pipeline/OptionalSetterInjectionTester.cs 2008-08-19 01:24:37 UTC (rev 140)
@@ -44,7 +44,7 @@
r =>
{
r.ForRequestedType<OptionalSetterTarget>().TheDefaultIs(
- Instance<OptionalSetterTarget>().SetProperty("Name", "Jeremy"));
+ (Instance<OptionalSetterTarget>()).WithProperty("Name").EqualTo("Jeremy"));
r.AddInstanceOf<OptionalSetterTarget>(Instance<OptionalSetterTarget>().WithName("NoName"));
});
Modified: trunk/Source/StructureMap.Testing.Widget/Rule.cs
===================================================================
--- trunk/Source/StructureMap.Testing.Widget/Rule.cs 2008-08-16 16:44:23 UTC (rev 139)
+++ trunk/Source/StructureMap.Testing.Widget/Rule.cs 2008-08-19 01:24:37 UTC (rev 140)
@@ -96,14 +96,16 @@
ConfiguredInstance memento = new ConfiguredInstance(typeof(ComplexRule));
memento.Name = "Sample";
- memento.SetProperty("String", "Red");
- memento.SetProperty("String2", "Green");
- memento.SetProperty("Int", "1");
- memento.SetProperty("Long", "2");
- memento.SetProperty("Byte", "3");
- memento.SetProperty("Double", "4");
- memento.SetProperty("Bool", "true");
+ IConfiguredInstance instance = memento;
+ instance.SetProperty("String", "Red");
+ instance.SetProperty("String2", "Green");
+ instance.SetProperty("Int", "1");
+ instance.SetProperty("Long", "2");
+ instance.SetProperty("Byte", "3");
+ instance.SetProperty("Double", "4");
+ instance.SetProperty("Bool", "true");
+
return memento;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|