|
From: <jer...@us...> - 2008-05-09 15:47:42
|
Revision: 95
http://structuremap.svn.sourceforge.net/structuremap/?rev=95&view=rev
Author: jeremydmiller
Date: 2008-05-09 08:47:15 -0700 (Fri, 09 May 2008)
Log Message:
-----------
centralized the Generics stuff to GenericsPluginGraph, cleaned out some other cruft, Plugin/Emitting code cleanup
Modified Paths:
--------------
trunk/Source/StructureMap/Attributes/PluginFamilyAttribute.cs
trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs
trunk/Source/StructureMap/Configuration/FamilyParser.cs
trunk/Source/StructureMap/Emitting/ClassBuilder.cs
trunk/Source/StructureMap/Emitting/InstanceBuilderAssembly.cs
trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs
trunk/Source/StructureMap/Graph/IPluginFamily.cs
trunk/Source/StructureMap/Graph/Plugin.cs
trunk/Source/StructureMap/Graph/PluginCollection.cs
trunk/Source/StructureMap/Graph/PluginFamily.cs
trunk/Source/StructureMap/Graph/PluginFamilyCollection.cs
trunk/Source/StructureMap/Graph/PluginGraph.cs
trunk/Source/StructureMap/IInstanceManager.cs
trunk/Source/StructureMap/InstanceBuilder.cs
trunk/Source/StructureMap/InstanceBuilderList.cs
trunk/Source/StructureMap/InstanceFactory.cs
trunk/Source/StructureMap/InstanceManager.cs
trunk/Source/StructureMap/InstanceMemento.cs
trunk/Source/StructureMap/MementoSource.cs
trunk/Source/StructureMap/ObjectFactory.cs
trunk/Source/StructureMap/Pipeline/BuildStrategies.cs
trunk/Source/StructureMap/PluginGraphBuilder.cs
trunk/Source/StructureMap/StructureMap.csproj
trunk/Source/StructureMap.AutoMocking/AutoMockedInstanceManager.cs
trunk/Source/StructureMap.Testing/Configuration/DSL/CreatePluginFamilyTester.cs
trunk/Source/StructureMap.Testing/Configuration/DSL/RegistryTester.cs
trunk/Source/StructureMap.Testing/Configuration/InlineInstanceDefinitionInProfileAndMachineNodesTester.cs
trunk/Source/StructureMap.Testing/Configuration/NormalGraphBuilderTester.cs
trunk/Source/StructureMap.Testing/Container/DynamicInjectionTester.cs
trunk/Source/StructureMap.Testing/Container/EmittingTester.cs
trunk/Source/StructureMap.Testing/Container/EnumerationTester.cs
trunk/Source/StructureMap.Testing/Container/ExplicitArgumentTester.cs
trunk/Source/StructureMap.Testing/Container/InstanceManagerTester.cs
trunk/Source/StructureMap.Testing/Container/PluginGraphBuilderTester.cs
trunk/Source/StructureMap.Testing/Container/Source/XmlTemplaterTester.cs
trunk/Source/StructureMap.Testing/GenericsAcceptanceTester.cs
trunk/Source/StructureMap.Testing/Graph/GenericsPluginGraphTester.cs
trunk/Source/StructureMap.Testing/Graph/PluginGraphTester.cs
trunk/Source/StructureMap.Testing/Graph/PluginTester.cs
trunk/Source/StructureMap.Testing/ImplicitPluginFromPluggedTypeAttributeTester.cs
trunk/Source/StructureMap.Testing/InstanceMementoInstanceCreationTester.cs
trunk/Source/StructureMap.Testing/ObjectMother.cs
trunk/Source/StructureMap.Testing.Widget/ArrayConstruction.cs
trunk/Source/StructureMap.Testing.Widget/Decision.cs
trunk/Source/StructureMap.Testing.Widget/Hierarchy.cs
trunk/Source/StructureMap.Testing.Widget/Rule.cs
trunk/Source/StructureMap.Testing.Widget2/EnumerationCheck.cs
trunk/Source/StructureMap.Testing.Widget5/BasicGridColumnInstanceBuilder.cs
Removed Paths:
-------------
trunk/Source/StructureMap/Configuration/Mementos/
trunk/Source/StructureMap/IPluginGraphSource.cs
Modified: trunk/Source/StructureMap/Attributes/PluginFamilyAttribute.cs
===================================================================
--- trunk/Source/StructureMap/Attributes/PluginFamilyAttribute.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/Attributes/PluginFamilyAttribute.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -94,7 +94,7 @@
}
catch (Exception ex)
{
- throw new StructureMapException(122, ex, SourceType.FullName, family.PluginTypeName);
+ throw new StructureMapException(122, ex, SourceType.FullName, family.PluginType.AssemblyQualifiedName);
}
}
Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -8,14 +8,13 @@
namespace StructureMap.Configuration.DSL.Expressions
{
- public delegate void AlterPluginFamilyDelegate(PluginFamily family);
/// <summary>
/// Represents the parameters for creating instances of a given Type
/// </summary>
public class CreatePluginFamilyExpression<PLUGINTYPE> : IExpression
{
- private readonly List<AlterPluginFamilyDelegate> _alterations = new List<AlterPluginFamilyDelegate>();
+ private readonly List<Action<PluginFamily>> _alterations = new List<Action<PluginFamily>>();
private readonly List<IExpression> _children = new List<IExpression>();
private readonly Type _pluginType;
private readonly InstanceScope _scope = InstanceScope.PerRequest;
@@ -37,7 +36,7 @@
child.Configure(graph);
}
- foreach (AlterPluginFamilyDelegate alteration in _alterations)
+ foreach (Action<PluginFamily> alteration in _alterations)
{
alteration(family);
}
@@ -45,6 +44,8 @@
#endregion
+ // TODO: Try alterAndContinue(f => {});
+
/// <summary>
/// Sets the default instance of a Type to the definition represented by builder
/// </summary>
@@ -159,7 +160,7 @@
return this;
}
- public CreatePluginFamilyExpression<PLUGINTYPE> InterceptConstructionWith(IInstanceInterceptor interceptor)
+ public CreatePluginFamilyExpression<PLUGINTYPE> InterceptConstructionWith(IBuildInterceptor interceptor)
{
_alterations.Add(delegate(PluginFamily family)
{
Modified: trunk/Source/StructureMap/Configuration/FamilyParser.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/FamilyParser.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/Configuration/FamilyParser.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -116,7 +116,7 @@
TypePath pluginPath = TypePath.CreateFromXmlNode(pluginElement);
string concreteKey = pluginElement.GetAttribute(XmlConstants.CONCRETE_KEY_ATTRIBUTE);
- string context = "creating a Plugin for " + family.PluginTypeName;
+ string context = "creating a Plugin for " + family.PluginType.AssemblyQualifiedName;
_builder.WithType(pluginPath, context, delegate(Type pluggedType)
{
Plugin plugin = new Plugin(pluggedType, concreteKey);
@@ -148,7 +148,7 @@
XmlAttributeInstanceMemento interceptorMemento = new XmlAttributeInstanceMemento(interceptorNode);
- _builder.WithSystemObject<IInstanceInterceptor>(interceptorMemento, context, delegate(IInstanceInterceptor interceptor)
+ _builder.WithSystemObject<IBuildInterceptor>(interceptorMemento, context, delegate(IBuildInterceptor interceptor)
{
family.AddInterceptor(interceptor);
});
Modified: trunk/Source/StructureMap/Emitting/ClassBuilder.cs
===================================================================
--- trunk/Source/StructureMap/Emitting/ClassBuilder.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/Emitting/ClassBuilder.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -84,28 +84,58 @@
}
- public void AddReadonlyStringProperty(string PropertyName, string Value, bool Override)
+ public void AddReadonlyStringProperty(string propertyName, string propertyValue, bool @override)
{
PropertyBuilder prop =
- _newTypeBuilder.DefineProperty(PropertyName, PropertyAttributes.HasDefault, typeof (string), null);
+ _newTypeBuilder.DefineProperty(propertyName, PropertyAttributes.HasDefault, typeof (string), null);
MethodAttributes atts = MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig |
MethodAttributes.Final | MethodAttributes.SpecialName;
- string _GetMethodName = "get_" + PropertyName;
+ string getterMethodName = "get_" + propertyName;
MethodBuilder methodGet =
- _newTypeBuilder.DefineMethod(_GetMethodName, atts, CallingConventions.Standard, typeof (string), null);
+ _newTypeBuilder.DefineMethod(getterMethodName, atts, CallingConventions.Standard, typeof (string), null);
ILGenerator gen = methodGet.GetILGenerator();
LocalBuilder ilReturn = gen.DeclareLocal(typeof (string));
- gen.Emit(OpCodes.Ldstr, Value);
+ gen.Emit(OpCodes.Ldstr, propertyValue);
gen.Emit(OpCodes.Stloc_0);
gen.Emit(OpCodes.Ldloc_0);
gen.Emit(OpCodes.Ret);
prop.SetGetMethod(methodGet);
}
+
+ public void AddPluggedTypeGetter(Type pluggedType)
+ {
+ PropertyBuilder prop =
+ _newTypeBuilder.DefineProperty("PluggedType", PropertyAttributes.HasDefault, typeof(Type), null);
+
+ MethodAttributes atts = MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig |
+ MethodAttributes.Final | MethodAttributes.SpecialName;
+
+ string getterMethodName = "get_PluggedType";
+
+ MethodBuilder methodGet =
+ _newTypeBuilder.DefineMethod(getterMethodName, atts, CallingConventions.Standard, typeof(Type), null);
+ ILGenerator gen = methodGet.GetILGenerator();
+
+ LocalBuilder ilReturn = gen.DeclareLocal(typeof(Type));
+
+ gen.Emit(OpCodes.Nop);
+ gen.Emit(OpCodes.Ldtoken, pluggedType);
+
+ MethodInfo method = typeof(Type).GetMethod("GetTypeFromHandle");
+ gen.Emit(OpCodes.Call, method);
+
+ gen.Emit(OpCodes.Stloc_0);
+
+ gen.Emit(OpCodes.Ldloc_0);
+ gen.Emit(OpCodes.Ret);
+
+ prop.SetGetMethod(methodGet);
+ }
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Emitting/InstanceBuilderAssembly.cs
===================================================================
--- trunk/Source/StructureMap/Emitting/InstanceBuilderAssembly.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/Emitting/InstanceBuilderAssembly.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Reflection;
using StructureMap.Graph;
@@ -9,23 +10,66 @@
/// </summary>
public class InstanceBuilderAssembly
{
- private DynamicAssembly _dynamicAssembly;
- private Type _pluginType;
+ private readonly DynamicAssembly _dynamicAssembly;
+ private readonly Type _pluginType;
+ private readonly List<string> _classNames = new List<string>();
- public InstanceBuilderAssembly(string assemblyName, Type pluginType)
+ public InstanceBuilderAssembly(Type pluginType, IEnumerable<Plugin> plugins)
{
+ string assemblyName = Guid.NewGuid().ToString().Replace(".", "") + "InstanceBuilderAssembly";
_dynamicAssembly = new DynamicAssembly(assemblyName);
_pluginType = pluginType;
+
+ foreach (Plugin plugin in plugins)
+ {
+ processPlugin(plugin);
+ }
}
- public void AddPlugin(Plugin plugin)
+ /// <summary>
+ /// Gets a class name for the InstanceBuilder that will be emitted for this Plugin
+ /// </summary>
+ /// <returns></returns>
+ public static string getInstanceBuilderClassName(Type pluggedType)
{
+ string className = "";
+
+ if (pluggedType.IsGenericType)
+ {
+ className += escapeClassName(pluggedType);
+
+ Type[] args = pluggedType.GetGenericArguments();
+ foreach (Type arg in args)
+ {
+ className += escapeClassName(arg);
+ }
+ }
+ else
+ {
+ className = escapeClassName(pluggedType);
+ }
+
+ return className + "InstanceBuilder";
+ }
+
+ private static string escapeClassName(Type type)
+ {
+ string typeName = type.Namespace + type.Name;
+ string returnValue = typeName.Replace(".", string.Empty);
+ return returnValue.Replace("`", string.Empty);
+ }
+
+ private void processPlugin(Plugin plugin)
+ {
if (Plugin.CanBeCast(_pluginType, plugin.PluggedType))
{
+ string className = getInstanceBuilderClassName(plugin.PluggedType);
ClassBuilder builderClass =
- _dynamicAssembly.AddClass(plugin.GetInstanceBuilderClassName(), typeof (InstanceBuilder));
+ _dynamicAssembly.AddClass(className, typeof (InstanceBuilder));
configureClassBuilder(builderClass, plugin);
+
+ _classNames.Add(className);
}
else
{
@@ -33,15 +77,21 @@
}
}
- public Assembly Compile()
+ public List<InstanceBuilder> Compile()
{
- return _dynamicAssembly.Compile();
+ Assembly assembly = _dynamicAssembly.Compile();
+
+ return _classNames.ConvertAll<InstanceBuilder>(delegate(string typeName)
+ {
+ return (InstanceBuilder) assembly.CreateInstance(typeName);
+ });
}
private void configureClassBuilder(ClassBuilder builderClass, Plugin plugin)
{
builderClass.AddReadonlyStringProperty("ConcreteTypeKey", plugin.ConcreteKey, true);
+ builderClass.AddPluggedTypeGetter(plugin.PluggedType);
BuildInstanceMethod method = new BuildInstanceMethod(plugin);
builderClass.AddMethod(method);
Modified: trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs
===================================================================
--- trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -79,12 +79,68 @@
profileManager.CopyDefaults(basicType, templatedType);
- return basicFamily.CreateTemplatedClone(templatedParameterTypes);
+ return CreateTemplatedClone(basicFamily, templatedParameterTypes);
}
else
{
return null;
}
}
+
+ // TODO: This code sucks. What's going on here?
+ public static PluginFamily CreateTemplatedClone(PluginFamily baseFamily, params Type[] templateTypes)
+ {
+ Type templatedType = baseFamily.PluginType.MakeGenericType(templateTypes);
+ PluginFamily templatedFamily = new PluginFamily(templatedType);
+ templatedFamily.DefaultInstanceKey = baseFamily.DefaultInstanceKey;
+ templatedFamily.Parent = baseFamily.Parent;
+ templatedFamily.Policy = baseFamily.Policy.Clone();
+
+ // Add Plugins
+ foreach (Plugin plugin in baseFamily.Plugins)
+ {
+ if (plugin.CanBePluggedIntoGenericType(baseFamily.PluginType, templateTypes))
+ {
+ Plugin templatedPlugin = CreateTemplatedClone(plugin, templateTypes);
+ templatedFamily.Plugins.Add(templatedPlugin);
+ }
+ }
+
+ // TODO -- Got a big problem here. Intances need to be copied over
+ foreach (IDiagnosticInstance instance in baseFamily.GetAllInstances())
+ {
+ if (instance.CanBePartOfPluginFamily(templatedFamily))
+ {
+ templatedFamily.AddInstance((Instance)instance);
+ }
+ }
+
+ // Need to attach the new PluginFamily to the old PluginGraph
+ baseFamily.Parent.PluginFamilies.Add(templatedFamily);
+
+ return templatedFamily;
+ }
+
+
+
+ public static Plugin CreateTemplatedClone(Plugin plugin, params Type[] types)
+ {
+ Type templatedType;
+ if (plugin.PluggedType.IsGenericType)
+ {
+ templatedType = plugin.PluggedType.MakeGenericType(types);
+ }
+ else
+ {
+ templatedType = plugin.PluggedType;
+ }
+ Plugin templatedPlugin = new Plugin(templatedType, plugin.ConcreteKey);
+ foreach (SetterProperty setter in plugin.Setters)
+ {
+ templatedPlugin.Setters.Add(setter.Name);
+ }
+
+ return templatedPlugin;
+ }
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Graph/IPluginFamily.cs
===================================================================
--- trunk/Source/StructureMap/Graph/IPluginFamily.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/Graph/IPluginFamily.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -21,12 +21,7 @@
get;
}
- string PluginTypeName
- {
- get;
- }
-
void SetScopeTo(InstanceScope scope);
- void AddInterceptor(IInstanceInterceptor interceptor);
+ void AddInterceptor(IBuildInterceptor interceptor);
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Graph/Plugin.cs
===================================================================
--- trunk/Source/StructureMap/Graph/Plugin.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/Graph/Plugin.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -1,6 +1,5 @@
using System;
using System.Reflection;
-using StructureMap.Configuration.Mementos;
namespace StructureMap.Graph
{
@@ -127,25 +126,6 @@
}
- /// <summary>
- /// Troubleshooting constructor used by PluginGraphBuilder to find possible problems
- /// with the configured Plugin
- /// </summary>
- /// <param name="path"></param>
- /// <param name="concreteKey"></param>
- [Obsolete("Get rid of this. All of this should go through NormalGraphBuilder")] public Plugin(TypePath path, string concreteKey) : base()
- {
- if (concreteKey == string.Empty)
- {
- throw new StructureMapException(112, path.ClassName);
- }
-
- setPluggedType(path, concreteKey);
- _setters = new SetterPropertyCollection(this);
-
- _concreteKey = concreteKey;
- }
-
#endregion
@@ -218,37 +198,7 @@
}
}
- private void setPluggedType(TypePath path, string concreteKey)
- {
- try
- {
- _pluggedType = path.FindType();
- }
- catch (Exception ex)
- {
- throw new StructureMapException(111, ex, path.ClassName, concreteKey);
- }
- }
-
- public Plugin CreateTemplatedClone(params Type[] types)
- {
- Type templatedType;
- if (_pluggedType.IsGenericType)
- {
- templatedType = _pluggedType.MakeGenericType(types);
- }
- else
- {
- templatedType = _pluggedType;
- }
- Plugin templatedPlugin = new Plugin(templatedType, _concreteKey);
- templatedPlugin._setters = _setters;
-
- return templatedPlugin;
- }
-
-
/// <summary>
/// Returns the System.Reflection.ConstructorInfo for the PluggedType. Uses either
/// the "greediest" constructor with the most arguments or the constructor function
@@ -273,40 +223,7 @@
return returnValue;
}
- /// <summary>
- /// Gets a class name for the InstanceBuilder that will be emitted for this Plugin
- /// </summary>
- /// <returns></returns>
- public string GetInstanceBuilderClassName()
- {
- string className = "";
- if (_pluggedType.IsGenericType)
- {
- className += escapeClassName(_pluggedType);
-
- Type[] args = _pluggedType.GetGenericArguments();
- foreach (Type arg in args)
- {
- className += escapeClassName(arg);
- }
- }
- else
- {
- className = escapeClassName(_pluggedType);
- }
-
- return className + "InstanceBuilder";
- }
-
- private string escapeClassName(Type type)
- {
- string typeName = type.Namespace + type.Name;
- string returnValue = typeName.Replace(".", string.Empty);
- return returnValue.Replace("`", string.Empty);
- }
-
-
/// <summary>
/// Boolean flag denoting the presence of any constructor arguments
/// </summary>
@@ -435,6 +352,8 @@
}
}
+ // TODO: Move to Generics. This code is insanely stupid. Just make the templated type and do
+ // IsAssignableFrom. Duh!
public bool CanBePluggedIntoGenericType(Type pluginType, params Type[] templateTypes)
{
bool isValid = true;
Modified: trunk/Source/StructureMap/Graph/PluginCollection.cs
===================================================================
--- trunk/Source/StructureMap/Graph/PluginCollection.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/Graph/PluginCollection.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -75,13 +75,6 @@
}
}
- [Obsolete("Get rid of this")]
- public void Add(TypePath path, string concreteKey)
- {
- Plugin plugin = new Plugin(path, concreteKey);
- Add(plugin);
- }
-
/// <summary>
/// Adds a new Plugin by the PluggedType
/// </summary>
@@ -109,14 +102,14 @@
}
else
{
- throw new StructureMapException(113, plugin.ConcreteKey, _family.PluginTypeName);
+ throw new StructureMapException(113, plugin.ConcreteKey, _family.PluginType.AssemblyQualifiedName);
}
}
// Reject if the PluggedType cannot be upcast to the PluginType
if (!Plugin.CanBeCast(_family.PluginType, plugin.PluggedType))
{
- throw new StructureMapException(114, plugin.PluggedType.FullName, _family.PluginTypeName);
+ throw new StructureMapException(114, plugin.PluggedType.FullName, _family.PluginType.AssemblyQualifiedName);
}
_plugins.Add(plugin.ConcreteKey, plugin);
Modified: trunk/Source/StructureMap/Graph/PluginFamily.cs
===================================================================
--- trunk/Source/StructureMap/Graph/PluginFamily.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/Graph/PluginFamily.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -15,20 +15,19 @@
/// </summary>
public class PluginFamily : IPluginFamily
{
- public const string CONCRETE_KEY = "CONCRETE";
private readonly List<InstanceMemento> _mementoList = new List<InstanceMemento>();
private readonly PluginCollection _plugins;
private string _defaultKey = string.Empty;
private InstanceInterceptor _instanceInterceptor = new NulloInterceptor();
private PluginGraph _parent;
- private readonly Type _pluginType;
- private readonly string _pluginTypeName;
private readonly List<Instance> _instances = new List<Instance>();
private IBuildPolicy _buildPolicy = new BuildPolicy();
+ private readonly Type _pluginType;
private readonly Predicate<Type> _explicitlyMarkedPluginFilter;
private readonly Predicate<Type> _implicitPluginFilter;
private Predicate<Type> _pluginFilter;
+ private IBuildPolicy _policy;
// TODO: Need to unit test the scope from the attribute
@@ -39,7 +38,6 @@
public PluginFamily(Type pluginType)
{
_pluginType = pluginType;
- _pluginTypeName = TypePath.GetAssemblyQualifiedName(_pluginType);
_plugins = new PluginCollection(this);
PluginFamilyAttribute.ConfigureFamily(this);
@@ -62,42 +60,8 @@
set { _instanceInterceptor = value; }
}
- // TODO: This code sucks. What's going on here?
- public PluginFamily CreateTemplatedClone(params Type[] templateTypes)
- {
- Type templatedType = _pluginType.MakeGenericType(templateTypes);
- PluginFamily templatedFamily = new PluginFamily(templatedType);
- templatedFamily._defaultKey = _defaultKey;
- templatedFamily.Parent = Parent;
- templatedFamily._buildPolicy = _buildPolicy.Clone();
- // Add Plugins
- foreach (Plugin plugin in _plugins)
- {
- if (plugin.CanBePluggedIntoGenericType(_pluginType, templateTypes))
- {
- Plugin templatedPlugin = plugin.CreateTemplatedClone(templateTypes);
- templatedFamily.Plugins.Add(templatedPlugin);
- }
- }
- // TODO -- Got a big problem here. Intances need to be copied over
- foreach (IDiagnosticInstance instance in GetAllInstances())
- {
- if (instance.CanBePartOfPluginFamily(templatedFamily))
- {
- templatedFamily.AddInstance((Instance)instance);
- }
- }
-
- // Need to attach the new PluginFamily to the old PluginGraph
- Parent.PluginFamilies.Add(templatedFamily);
-
- return templatedFamily;
- }
-
-
-
public void AddInstance(InstanceMemento memento)
{
_mementoList.Add(memento);
@@ -145,11 +109,6 @@
get { return _plugins; }
}
- public string PluginTypeName
- {
- get { return _pluginTypeName; }
- }
-
public bool IsGenericTemplate
{
get { return _pluginType.IsGenericTypeDefinition; }
@@ -175,6 +134,7 @@
public IBuildPolicy Policy
{
get { return _buildPolicy; }
+ set { _policy = value; }
}
public int PluginCount
@@ -242,7 +202,7 @@
}
}
- public void AddInterceptor(IInstanceInterceptor interceptor)
+ public void AddInterceptor(IBuildInterceptor interceptor)
{
interceptor.InnerPolicy = _buildPolicy;
_buildPolicy = interceptor;
Modified: trunk/Source/StructureMap/Graph/PluginFamilyCollection.cs
===================================================================
--- trunk/Source/StructureMap/Graph/PluginFamilyCollection.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/Graph/PluginFamilyCollection.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -31,41 +31,6 @@
}
}
-
- public PluginFamily this[int index]
- {
- get
- {
- PluginFamily[] families = new PluginFamily[_pluginFamilies.Count];
- return families[index];
- }
- }
-
- public PluginFamily this[string pluginTypeName]
- {
- get
- {
- Type pluginType = Type.GetType(pluginTypeName);
-
- if (pluginType == null)
- {
- foreach (KeyValuePair<Type, PluginFamily> pair in _pluginFamilies)
- {
- if (pair.Value.PluginType.FullName == pluginTypeName)
- {
- return pair.Value;
- }
- }
-
- throw new ApplicationException("Could not find PluginFamily " + pluginTypeName);
- }
- else
- {
- return this[pluginType];
- }
- }
- }
-
public int Count
{
get { return _pluginFamilies.Count; }
Modified: trunk/Source/StructureMap/Graph/PluginGraph.cs
===================================================================
--- trunk/Source/StructureMap/Graph/PluginGraph.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/Graph/PluginGraph.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -1,7 +1,5 @@
using System;
-using System.Collections.Generic;
using System.Reflection;
-using StructureMap.Configuration.DSL;
using StructureMap.Diagnostics;
using StructureMap.Interceptors;
using StructureMap.Pipeline;
@@ -106,8 +104,6 @@
_sealed = true;
}
-
-
#endregion
public static PluginGraph BuildGraphFromAssembly(Assembly assembly)
Modified: trunk/Source/StructureMap/IInstanceManager.cs
===================================================================
--- trunk/Source/StructureMap/IInstanceManager.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/IInstanceManager.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -1,7 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
-using StructureMap.Configuration.Mementos;
using StructureMap.Graph;
using StructureMap.Pipeline;
Deleted: trunk/Source/StructureMap/IPluginGraphSource.cs
===================================================================
--- trunk/Source/StructureMap/IPluginGraphSource.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/IPluginGraphSource.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -1,15 +0,0 @@
-using System;
-using StructureMap.Graph;
-
-namespace StructureMap
-{
- [Obsolete] public interface IPluginGraphSource
- {
- /// <summary>
- /// Reads the configuration information and returns the PluginGraph definition of
- /// plugin families and plugin's
- /// </summary>
- /// <returns></returns>
- PluginGraph Build();
- }
-}
\ No newline at end of file
Modified: trunk/Source/StructureMap/InstanceBuilder.cs
===================================================================
--- trunk/Source/StructureMap/InstanceBuilder.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/InstanceBuilder.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -17,6 +17,8 @@
public abstract string ConcreteTypeKey { get; }
+ public abstract Type PluggedType { get; }
+
public abstract object BuildInstance(IConfiguredInstance instance, StructureMap.Pipeline.IInstanceCreator creator);
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/InstanceBuilderList.cs
===================================================================
--- trunk/Source/StructureMap/InstanceBuilderList.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/InstanceBuilderList.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -58,33 +58,17 @@
private void processPlugins(IEnumerable<Plugin> plugins)
{
- Assembly assembly = createInstanceBuilderAssembly(plugins);
- foreach (Plugin plugin in plugins)
+ List<InstanceBuilder> list = createInstanceBuilders(plugins);
+ foreach (InstanceBuilder builder in list)
{
- addPlugin(assembly, plugin);
+ _builders.Add(builder.PluggedType, builder);
}
}
- private Assembly createInstanceBuilderAssembly(IEnumerable<Plugin> plugins)
+ private List<InstanceBuilder> createInstanceBuilders(IEnumerable<Plugin> plugins)
{
- string assemblyName = Guid.NewGuid().ToString().Replace(".", "") + "InstanceBuilderAssembly";
- InstanceBuilderAssembly builderAssembly = new InstanceBuilderAssembly(assemblyName, _pluginType);
-
- foreach (Plugin plugin in plugins)
- {
- builderAssembly.AddPlugin(plugin);
- }
-
+ InstanceBuilderAssembly builderAssembly = new InstanceBuilderAssembly(_pluginType, plugins);
return builderAssembly.Compile();
}
-
-
- private void addPlugin(Assembly assembly, Plugin plugin)
- {
- string instanceBuilderClassName = plugin.GetInstanceBuilderClassName();
- InstanceBuilder builder = (InstanceBuilder)assembly.CreateInstance(instanceBuilderClassName);
-
- _builders.Add(plugin.PluggedType, builder);
- }
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/InstanceFactory.cs
===================================================================
--- trunk/Source/StructureMap/InstanceFactory.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/InstanceFactory.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -27,7 +27,7 @@
/// </summary>
/// <param name="family"></param>
/// <param name="failOnException">Toggles error trapping. Set to "true" for diagnostics</param>
- public InstanceFactory(PluginFamily family, bool failOnException)
+ public InstanceFactory(PluginFamily family)
{
if (family == null)
{
@@ -53,7 +53,7 @@
}
catch (Exception e)
{
- throw new StructureMapException(115, e, family.PluginTypeName);
+ throw new StructureMapException(115, e, family.PluginType.AssemblyQualifiedName);
}
}
@@ -68,7 +68,7 @@
return;
}
- Plugin plugin = new Plugin(new TypePath(concreteType), Guid.NewGuid().ToString());
+ Plugin plugin = new Plugin(concreteType, Guid.NewGuid().ToString());
if (plugin.CanBeAutoFilled)
{
_instanceBuilders = new InstanceBuilderList(_pluginType, new Plugin[] {plugin});
@@ -83,7 +83,7 @@
}
}
- public static InstanceFactory CreateInstanceFactoryForType(Type concreteType, ProfileManager profileManager)
+ public static InstanceFactory CreateFactoryForConcreteType(Type concreteType, ProfileManager profileManager)
{
return new InstanceFactory(concreteType, profileManager);
}
Modified: trunk/Source/StructureMap/InstanceManager.cs
===================================================================
--- trunk/Source/StructureMap/InstanceManager.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/InstanceManager.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -2,7 +2,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Text;
-using StructureMap.Configuration.Mementos;
using StructureMap.Exceptions;
using StructureMap.Graph;
using StructureMap.Interceptors;
@@ -353,7 +352,7 @@
private IInstanceFactory registerPluginFamily(PluginFamily family)
{
- InstanceFactory factory = new InstanceFactory(family, _failOnException);
+ InstanceFactory factory = new InstanceFactory(family);
RegisterType(factory);
return factory;
@@ -420,10 +419,10 @@
if (pluggedType.IsGenericType)
{
PluginFamily family = _genericsGraph.CreateTemplatedFamily(pluggedType, _profileManager);
- if (family != null) return new InstanceFactory(family, true);
+ if (family != null) return new InstanceFactory(family);
}
- return InstanceFactory.CreateInstanceFactoryForType(pluggedType, _profileManager);
+ return InstanceFactory.CreateFactoryForConcreteType(pluggedType, _profileManager);
}
#region Nested type: CreateFactoryDelegate
Modified: trunk/Source/StructureMap/InstanceMemento.cs
===================================================================
--- trunk/Source/StructureMap/InstanceMemento.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/InstanceMemento.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -44,7 +44,7 @@
return family.Plugins[innerConcreteKey];
}
- throw new StructureMapException(201, innerConcreteKey, InstanceKey, family.PluginTypeName);
+ throw new StructureMapException(201, innerConcreteKey, InstanceKey, family.PluginType.AssemblyQualifiedName);
}
Modified: trunk/Source/StructureMap/MementoSource.cs
===================================================================
--- trunk/Source/StructureMap/MementoSource.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/MementoSource.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -98,7 +98,7 @@
{
if (_defaultMemento == null)
{
- string pluginTypeName = Family == null ? "UNKNOWN" : Family.PluginTypeName;
+ string pluginTypeName = Family == null ? "UNKNOWN" : Family.PluginType.AssemblyQualifiedName;
throw new StructureMapException(202, pluginTypeName);
}
@@ -110,7 +110,7 @@
if (returnValue == null)
{
- throw new StructureMapException(200, memento.ReferenceKey, Family.PluginTypeName);
+ throw new StructureMapException(200, memento.ReferenceKey, Family.PluginType.AssemblyQualifiedName);
}
}
Modified: trunk/Source/StructureMap/ObjectFactory.cs
===================================================================
--- trunk/Source/StructureMap/ObjectFactory.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/ObjectFactory.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -2,7 +2,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Security.Permissions;
-using StructureMap.Configuration.Mementos;
using StructureMap.Graph;
using StructureMap.Pipeline;
Modified: trunk/Source/StructureMap/Pipeline/BuildStrategies.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/BuildStrategies.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/Pipeline/BuildStrategies.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -27,12 +27,12 @@
}
[PluginFamily]
- public interface IInstanceInterceptor : IBuildPolicy
+ public interface IBuildInterceptor : IBuildPolicy
{
IBuildPolicy InnerPolicy { get; set; }
}
- public abstract class CacheInterceptor : IInstanceInterceptor
+ public abstract class CacheInterceptor : IBuildInterceptor
{
private readonly object _locker = new object();
private IBuildPolicy _innerPolicy = new BuildPolicy();
@@ -80,15 +80,15 @@
protected abstract object retrieveFromCache(string instanceKey, Type pluginType);
}
- public class HybridBuildPolicy : IInstanceInterceptor
+ public class HybridBuildPolicy : IBuildInterceptor
{
- private readonly IInstanceInterceptor _innerInterceptor;
+ private readonly IBuildInterceptor _innerInterceptor;
public HybridBuildPolicy()
{
_innerInterceptor = HttpContextBuildPolicy.HasContext()
- ? (IInstanceInterceptor) new HttpContextBuildPolicy()
+ ? (IBuildInterceptor) new HttpContextBuildPolicy()
: new ThreadLocalStoragePolicy();
}
Modified: trunk/Source/StructureMap/PluginGraphBuilder.cs
===================================================================
--- trunk/Source/StructureMap/PluginGraphBuilder.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/PluginGraphBuilder.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -10,7 +10,7 @@
/// Reads configuration XML documents and builds the structures necessary to initialize
/// the InstanceManager/IInstanceFactory/InstanceBuilder/ObjectInstanceActivator objects
/// </summary>
- public class PluginGraphBuilder : IPluginGraphSource
+ public class PluginGraphBuilder
{
#region statics
@@ -34,7 +34,7 @@
private readonly ConfigurationParser[] _parsers;
private readonly Registry[] _registries = new Registry[0];
- private PluginGraph _graph;
+ private readonly PluginGraph _graph;
#region constructors
@@ -52,8 +52,6 @@
#endregion
- #region IPluginGraphSource Members
-
/// <summary>
/// Reads the configuration information and returns the PluginGraph definition of
/// plugin families and plugin's
@@ -69,8 +67,6 @@
return _graph;
}
- #endregion
-
private void forAllParsers(Action<ConfigurationParser> action)
{
foreach (ConfigurationParser parser in _parsers)
Modified: trunk/Source/StructureMap/StructureMap.csproj
===================================================================
--- trunk/Source/StructureMap/StructureMap.csproj 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap/StructureMap.csproj 2008-05-09 15:47:15 UTC (rev 95)
@@ -171,10 +171,8 @@
<Compile Include="Configuration\DSL\ExpressionValidator.cs" />
<Compile Include="Configuration\DSL\IExpression.cs" />
<Compile Include="Configuration\DSL\Expressions\InstanceDefaultExpression.cs" />
- <Compile Include="Configuration\Mementos\ExplicitArguments.cs" />
- <Compile Include="Configuration\Mementos\LiteralMemento.cs" />
+ <Compile Include="Pipeline\ExplicitArguments.cs" />
<Compile Include="Configuration\DSL\Expressions\ProfileExpression.cs" />
- <Compile Include="Configuration\Mementos\PrototypeMemento.cs" />
<Compile Include="Configuration\DSL\Registry.cs" />
<Compile Include="Configuration\DSL\Expressions\ScanAssembliesExpression.cs" />
<Compile Include="Configuration\FamilyParser.cs">
@@ -188,7 +186,6 @@
</Compile>
<Compile Include="Configuration\ProfileAndMachineParser.cs" />
<Compile Include="Configuration\StructureMapConfigurationSection.cs" />
- <Compile Include="Configuration\Mementos\UserControlMemento.cs" />
<Compile Include="Configuration\XmlConstants.cs">
<SubType>Code</SubType>
</Compile>
@@ -283,11 +280,10 @@
<Compile Include="Interceptors\NulloInterceptor.cs" />
<Compile Include="Interceptors\StartupInterceptor.cs" />
<Compile Include="Interceptors\FilteredInstanceInterceptor.cs" />
- <Compile Include="IPluginGraphSource.cs" />
<Compile Include="MementoSource.cs">
<SubType>Code</SubType>
</Compile>
- <Compile Include="Configuration\Mementos\MemoryInstanceMemento.cs">
+ <Compile Include="MemoryInstanceMemento.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="ObjectFactory.cs">
Modified: trunk/Source/StructureMap.AutoMocking/AutoMockedInstanceManager.cs
===================================================================
--- trunk/Source/StructureMap.AutoMocking/AutoMockedInstanceManager.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap.AutoMocking/AutoMockedInstanceManager.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -22,7 +22,7 @@
}
object service = _locator.Service(pluginType);
- InstanceFactory factory = new InstanceFactory(new PluginFamily(pluginType), true);
+ InstanceFactory factory = new InstanceFactory(new PluginFamily(pluginType));
LiteralInstance instance = new LiteralInstance(service);
SetDefault(pluginType, instance);
Modified: trunk/Source/StructureMap.Testing/Configuration/DSL/CreatePluginFamilyTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Configuration/DSL/CreatePluginFamilyTester.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap.Testing/Configuration/DSL/CreatePluginFamilyTester.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -215,7 +215,7 @@
}
}
- public class StubbedInstanceFactoryInterceptor : IInstanceInterceptor
+ public class StubbedInstanceFactoryInterceptor : IBuildInterceptor
{
public IBuildPolicy InnerPolicy
{
Modified: trunk/Source/StructureMap.Testing/Configuration/DSL/RegistryTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Configuration/DSL/RegistryTester.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap.Testing/Configuration/DSL/RegistryTester.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -2,7 +2,6 @@
using NUnit.Framework;
using Rhino.Mocks;
using StructureMap.Configuration.DSL;
-using StructureMap.Configuration.Mementos;
using StructureMap.Graph;
using StructureMap.Pipeline;
using StructureMap.Testing.Widget3;
Modified: trunk/Source/StructureMap.Testing/Configuration/InlineInstanceDefinitionInProfileAndMachineNodesTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Configuration/InlineInstanceDefinitionInProfileAndMachineNodesTester.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap.Testing/Configuration/InlineInstanceDefinitionInProfileAndMachineNodesTester.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -1,6 +1,5 @@
using System.Diagnostics;
using NUnit.Framework;
-using StructureMap.Configuration.Mementos;
using StructureMap.Graph;
using StructureMap.Testing.TestData;
using StructureMap.Testing.Widget;
Modified: trunk/Source/StructureMap.Testing/Configuration/NormalGraphBuilderTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Configuration/NormalGraphBuilderTester.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap.Testing/Configuration/NormalGraphBuilderTester.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -3,7 +3,6 @@
using Rhino.Mocks;
using StructureMap.Configuration;
using StructureMap.Configuration.DSL;
-using StructureMap.Configuration.Mementos;
using StructureMap.Graph;
using StructureMap.Pipeline;
using StructureMap.Source;
@@ -90,7 +89,7 @@
NormalGraphBuilder builder = new NormalGraphBuilder(new Registry[0]);
builder.PrepareSystemObjects();
- builder.WithSystemObject<IInstanceInterceptor>(memento, "singleton", delegate(IInstanceInterceptor policy)
+ builder.WithSystemObject<IBuildInterceptor>(memento, "singleton", delegate(IBuildInterceptor policy)
{
Assert.IsInstanceOfType(typeof(SingletonPolicy), policy);
iWasCalled = true;
Modified: trunk/Source/StructureMap.Testing/Container/DynamicInjectionTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Container/DynamicInjectionTester.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap.Testing/Container/DynamicInjectionTester.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -2,7 +2,6 @@
using System.Collections;
using System.Collections.Generic;
using NUnit.Framework;
-using StructureMap.Configuration.Mementos;
using StructureMap.Graph;
using StructureMap.Interceptors;
using StructureMap.Pipeline;
@@ -205,7 +204,7 @@
}
}
- public class FakeInstanceFactoryInterceptor : IInstanceInterceptor
+ public class FakeInstanceFactoryInterceptor : IBuildInterceptor
{
public IBuildPolicy InnerPolicy
{
Modified: trunk/Source/StructureMap.Testing/Container/EmittingTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Container/EmittingTester.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap.Testing/Container/EmittingTester.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -1,4 +1,5 @@
using System;
+using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using NUnit.Framework;
@@ -24,18 +25,11 @@
Plugin plugin = new Plugin(typeof (ComplexRule));
InstanceBuilderAssembly _InstanceBuilderAssembly =
- new InstanceBuilderAssembly("StructureMap.EmittingTesterAssembly", typeof (Rule));
+ new InstanceBuilderAssembly(typeof (Rule), new Plugin[]{plugin});
- _InstanceBuilderAssembly.AddPlugin(plugin);
- assem = _InstanceBuilderAssembly.Compile();
+ List<InstanceBuilder> list = _InstanceBuilderAssembly.Compile();
+ builder = list[0];
- if (assem != null)
- {
- string builderName = plugin.GetInstanceBuilderClassName();
-
- builder = assem.CreateInstance(builderName) as InstanceBuilder;
- }
-
if (builder != null)
{
rule = (ComplexRule) builder.BuildInstance(instance, new InstanceManager());
@@ -66,14 +60,7 @@
Assert.AreEqual(true, rule.Bool);
}
-
[Test]
- public void BuiltTheAssembly()
- {
- Assert.IsNotNull(assem);
- }
-
- [Test]
public void BuiltTheInstanceBuilder()
{
Assert.IsNotNull(builder);
Modified: trunk/Source/StructureMap.Testing/Container/EnumerationTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Container/EnumerationTester.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap.Testing/Container/EnumerationTester.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -1,5 +1,4 @@
using NUnit.Framework;
-using StructureMap.Configuration.Mementos;
using StructureMap.Graph;
using StructureMap.Source;
using StructureMap.Testing.Widget2;
@@ -24,7 +23,7 @@
family.Plugins.Add(typeof (Cow), "Default");
- InstanceFactory cowFactory = new InstanceFactory(family, true);
+ InstanceFactory cowFactory = new InstanceFactory(family);
cowFactory.SetInstanceManager(new InstanceManager());
MemoryInstanceMemento memento = new MemoryInstanceMemento("Default", "Angus");
Modified: trunk/Source/StructureMap.Testing/Container/ExplicitArgumentTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Container/ExplicitArgumentTester.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap.Testing/Container/ExplicitArgumentTester.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -1,6 +1,5 @@
using NUnit.Framework;
using StructureMap.Configuration.DSL;
-using StructureMap.Configuration.Mementos;
using StructureMap.Graph;
using StructureMap.Pipeline;
Modified: trunk/Source/StructureMap.Testing/Container/InstanceManagerTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Container/InstanceManagerTester.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap.Testing/Container/InstanceManagerTester.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -1,7 +1,6 @@
using System;
using NUnit.Framework;
using StructureMap.Configuration.DSL;
-using StructureMap.Configuration.Mementos;
using StructureMap.Graph;
using StructureMap.Interceptors;
using StructureMap.Pipeline;
Modified: trunk/Source/StructureMap.Testing/Container/PluginGraphBuilderTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Container/PluginGraphBuilderTester.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap.Testing/Container/PluginGraphBuilderTester.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -163,7 +163,7 @@
Assert.AreEqual("NotPluggable", plugin.ConcreteKey);
// Just for fun, test with InstanceFactory too.
- InstanceFactory factory = new InstanceFactory(family, true);
+ InstanceFactory factory = new InstanceFactory(family);
factory.SetInstanceManager(new InstanceManager());
ConfiguredInstance instance = new ConfiguredInstance();
Modified: trunk/Source/StructureMap.Testing/Container/Source/XmlTemplaterTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Container/Source/XmlTemplaterTester.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap.Testing/Container/Source/XmlTemplaterTester.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -1,7 +1,6 @@
using System.Collections;
using System.Xml;
using NUnit.Framework;
-using StructureMap.Configuration.Mementos;
using StructureMap.Source;
using StructureMap.Testing.TestData;
using StructureMap.Testing.XmlWriting;
Modified: trunk/Source/StructureMap.Testing/GenericsAcceptanceTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/GenericsAcceptanceTester.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap.Testing/GenericsAcceptanceTester.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -77,7 +77,7 @@
PluginFamily family = new PluginFamily(typeof (ITarget2<int, string, bool>));
family.Plugins.Add(typeof (SpecificTarget2<int, string, bool>), "specific");
- InstanceFactory factory = new InstanceFactory(family, true);
+ InstanceFactory factory = new InstanceFactory(family);
}
[Test]
@@ -86,7 +86,7 @@
PluginFamily family = new PluginFamily(typeof (ITarget<int, string>));
family.Plugins.Add(typeof (SpecificTarget<int, string>), "specific");
- InstanceFactory factory = new InstanceFactory(family, true);
+ InstanceFactory factory = new InstanceFactory(family);
}
[Test]
Modified: trunk/Source/StructureMap.Testing/Graph/GenericsPluginGraphTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Graph/GenericsPluginGraphTester.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap.Testing/Graph/GenericsPluginGraphTester.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -57,7 +57,7 @@
family.Plugins.Add(typeof (SecondGenericService<>), "Second");
family.Plugins.Add(typeof (ThirdGenericService<>), "Third");
- PluginFamily templatedFamily = family.CreateTemplatedClone(typeof (int));
+ PluginFamily templatedFamily = GenericsPluginGraph.CreateTemplatedClone(family, typeof(int));
Assert.IsNotNull(templatedFamily);
Assert.AreEqual(typeof (IGenericService<int>), templatedFamily.PluginType);
@@ -77,12 +77,13 @@
family.Plugins.Add(typeof (SecondGenericService3<,,>), "Second");
family.Plugins.Add(typeof (ThirdGenericService3<,,>), "Third");
- PluginFamily templatedFamily = family.CreateTemplatedClone(typeof (int), typeof (bool), typeof (string));
+ PluginFamily templatedFamily = GenericsPluginGraph.CreateTemplatedClone(family, typeof (int), typeof (bool), typeof (string));
Assert.IsNotNull(templatedFamily);
Assert.AreEqual(typeof (IGenericService3<int, bool, string>), templatedFamily.PluginType);
Assert.AreEqual(3, templatedFamily.Plugins.Count);
+
Assert.AreEqual(typeof (GenericService3<int, bool, string>), templatedFamily.Plugins["Default"].PluggedType);
Assert.AreEqual(typeof (SecondGenericService3<int, bool, string>),
templatedFamily.Plugins["Second"].PluggedType);
Modified: trunk/Source/StructureMap.Testing/Graph/PluginGraphTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Graph/PluginGraphTester.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap.Testing/Graph/PluginGraphTester.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -64,13 +64,11 @@
graph.Assemblies.Add("StructureMap.Testing.Widget");
graph.FindFamily(typeof (IWidget)).DefaultInstanceKey = "Blue";
- TypePath path =
- new TypePath("StructureMap.Testing.Widget", "StructureMap.Testing.Widget.NotPluggableWidget");
+
-
PluginFamily family = graph.FindFamily(typeof (IWidget));
- family.Plugins.Add(path, "NotPluggable");
+ family.Plugins.Add(typeof(NotPluggableWidget), "NotPluggable");
graph.Seal();
Modified: trunk/Source/StructureMap.Testing/Graph/PluginTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/Graph/PluginTester.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap.Testing/Graph/PluginTester.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -33,19 +33,7 @@
private Type _colorwidget;
private Type _moneywidgetmaker;
- [
- Test,
- ExpectedException(typeof (StructureMapException),
- ExpectedMessage = "StructureMap Exception Code: 112\nMissing a mandatory \"ConcreteKey\" attribute in a <Plugin> node for Type \"StructureMap.Testing.Widget.NotPluggableWidget\""
- )]
- public void AddAPluggedTypeWithoutAConcreteKey()
- {
- TypePath path = new TypePath("StructureMap.Testing.Widget",
- "StructureMap.Testing.Widget.NotPluggableWidget");
- Plugin plugin = new Plugin(path, "");
- }
-
[Test]
public void BadPluginToAbstractClass()
{
@@ -126,28 +114,6 @@
}
- [Test, ExpectedException(typeof (StructureMapException))]
- public void CreateAPluginWithANonExistentAssembly()
- {
- TypePath path = new TypePath("IDontExist.Assembly",
- "IDontExist.Assembly.NotPluggableWidget");
-
- Plugin plugin = new Plugin(path, "default");
- }
-
-
- [
- Test,
- ExpectedException(typeof (StructureMapException))]
- public void CreateAPluginWithANonExistentClass()
- {
- TypePath path = new TypePath("StructureMap.Testing.Widget",
- "StructureMap.Testing.Widget.NonExistentClass");
-
- Plugin plugin = new Plugin(path, "default");
- }
-
-
[Test]
public void CreateImplicitMementoWithNoConstructorArguments()
{
Modified: trunk/Source/StructureMap.Testing/ImplicitPluginFromPluggedTypeAttributeTester.cs
===================================================================
--- trunk/Source/StructureMap.Testing/ImplicitPluginFromPluggedTypeAttributeTester.cs 2008-05-06 21:48:18 UTC (rev 94)
+++ trunk/Source/StructureMap.Testing/ImplicitPluginFromPluggedTypeAttributeTester.cs 2008-05-09 15:47:15 UTC (rev 95)
@@ -4,7 +4,6 @@
using StructureMap.Attributes;
using StructureMap.Configuration;
...
[truncated message content] |