|
From: <jer...@us...> - 2008-05-15 18:15:52
|
Revision: 97
http://structuremap.svn.sourceforge.net/structuremap/?rev=97&view=rev
Author: jeremydmiller
Date: 2008-05-15 11:15:44 -0700 (Thu, 15 May 2008)
Log Message:
-----------
Reformatting
Modified Paths:
--------------
trunk/Source/CommonAssemblyInfo.cs
trunk/Source/StructureMap/Attributes/PluginFamilyAttribute.cs
trunk/Source/StructureMap/BuildSession.cs
trunk/Source/StructureMap/Configuration/ConfigurationParser.cs
trunk/Source/StructureMap/Configuration/ConfigurationParserCollection.cs
trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs
trunk/Source/StructureMap/Configuration/DSL/Expressions/InstanceDefaultExpression.cs
trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs
trunk/Source/StructureMap/Configuration/DSL/Expressions/ScanAssembliesExpression.cs
trunk/Source/StructureMap/Configuration/DSL/Registry.cs
trunk/Source/StructureMap/Configuration/FamilyParser.cs
trunk/Source/StructureMap/Configuration/IGraphBuilder.cs
trunk/Source/StructureMap/Configuration/ProfileAndMachineParser.cs
trunk/Source/StructureMap/Configuration/ProfileBuilder.cs
trunk/Source/StructureMap/Configuration/XmlConstants.cs
trunk/Source/StructureMap/Diagnostics/Tokens.cs
trunk/Source/StructureMap/Emitting/BuildInstanceMethod.cs
trunk/Source/StructureMap/Emitting/ClassBuilder.cs
trunk/Source/StructureMap/Emitting/InstanceBuilderAssembly.cs
trunk/Source/StructureMap/Emitting/Parameters/ChildArrayParameterEmitter.cs
trunk/Source/StructureMap/Emitting/Parameters/ParameterEmitter.cs
trunk/Source/StructureMap/Emitting/Parameters/StringParameterEmitter.cs
trunk/Source/StructureMap/Graph/AssemblyScanner.cs
trunk/Source/StructureMap/Graph/Constructor.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/SetterPropertyCollection.cs
trunk/Source/StructureMap/Graph/TypePath.cs
trunk/Source/StructureMap/Graph/TypeRules.cs
trunk/Source/StructureMap/IInstanceFactory.cs
trunk/Source/StructureMap/IInstanceManager.cs
trunk/Source/StructureMap/InstanceBuilderList.cs
trunk/Source/StructureMap/InstanceFactory.cs
trunk/Source/StructureMap/InstanceFamily.cs
trunk/Source/StructureMap/InstanceManager.cs
trunk/Source/StructureMap/InstanceMemento.cs
trunk/Source/StructureMap/Interceptors/FilteredInstanceInterceptor.cs
trunk/Source/StructureMap/Interceptors/InterceptorLibrary.cs
trunk/Source/StructureMap/Interceptors/Interceptors.cs
trunk/Source/StructureMap/MemoryInstanceMemento.cs
trunk/Source/StructureMap/ObjectFactory.cs
trunk/Source/StructureMap/Pipeline/BuildPolicy.cs
trunk/Source/StructureMap/Pipeline/CacheInterceptor.cs
trunk/Source/StructureMap/Pipeline/ConfiguredInstance.cs
trunk/Source/StructureMap/Pipeline/DefaultInstance.cs
trunk/Source/StructureMap/Pipeline/ExplicitArguments.cs
trunk/Source/StructureMap/Pipeline/HybridBuildPolicy.cs
trunk/Source/StructureMap/Pipeline/IConfiguredInstance.cs
trunk/Source/StructureMap/Pipeline/ILocationPolicy.cs
trunk/Source/StructureMap/Pipeline/InstanceMementoPropertyReader.cs
trunk/Source/StructureMap/Pipeline/LiteralInstance.cs
trunk/Source/StructureMap/Pipeline/Profile.cs
trunk/Source/StructureMap/Pipeline/ProfileManager.cs
trunk/Source/StructureMap/Pipeline/ReferencedInstance.cs
trunk/Source/StructureMap/Pipeline/ThreadLocalStoragePolicy.cs
trunk/Source/StructureMap/Pipeline/UserControlInstance.cs
trunk/Source/StructureMap/PipelineGraph.cs
trunk/Source/StructureMap/PluginGraphBuilder.cs
trunk/Source/StructureMap/Properties/AssemblyInfo.cs
trunk/Source/StructureMap/Source/XmlAttributeInstanceMemento.cs
trunk/Source/StructureMap/Source/XmlNodeInstanceMemento.cs
Modified: trunk/Source/CommonAssemblyInfo.cs
===================================================================
--- trunk/Source/CommonAssemblyInfo.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/CommonAssemblyInfo.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -1,4 +1,3 @@
-using System;
using System.Reflection;
using System.Runtime.InteropServices;
@@ -12,11 +11,10 @@
// </auto-generated>
//------------------------------------------------------------------------------
-[assembly: ComVisibleAttribute(false)]
-[assembly: AssemblyVersionAttribute("2.5.0.0000")]
-[assembly: AssemblyCopyrightAttribute("Copyright (c) 2007, Jeremy D. Miller")]
-[assembly: AssemblyProductAttribute("StructureMap")]
-[assembly: AssemblyCompanyAttribute("")]
-[assembly: AssemblyConfigurationAttribute("release")]
-[assembly: AssemblyInformationalVersionAttribute("2.5.0.0000")]
-
+[assembly : ComVisible(false)]
+[assembly : AssemblyVersion("2.5.0.0000")]
+[assembly : AssemblyCopyrightAttribute("Copyright (c) 2007, Jeremy D. Miller")]
+[assembly : AssemblyProductAttribute("StructureMap")]
+[assembly : AssemblyCompanyAttribute("")]
+[assembly : AssemblyConfigurationAttribute("release")]
+[assembly : AssemblyInformationalVersionAttribute("2.5.0.0000")]
\ No newline at end of file
Modified: trunk/Source/StructureMap/Attributes/PluginFamilyAttribute.cs
===================================================================
--- trunk/Source/StructureMap/Attributes/PluginFamilyAttribute.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Attributes/PluginFamilyAttribute.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -94,7 +94,8 @@
}
catch (Exception ex)
{
- throw new StructureMapException(122, ex, SourceType.FullName, family.PluginType.AssemblyQualifiedName);
+ throw new StructureMapException(122, ex, SourceType.FullName,
+ family.PluginType.AssemblyQualifiedName);
}
}
Modified: trunk/Source/StructureMap/BuildSession.cs
===================================================================
--- trunk/Source/StructureMap/BuildSession.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/BuildSession.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using StructureMap.Interceptors;
using StructureMap.Pipeline;
@@ -8,8 +6,8 @@
{
public class BuildSession : IBuildSession
{
+ private readonly InterceptorLibrary _interceptorLibrary;
private readonly PipelineGraph _pipelineGraph;
- private readonly InterceptorLibrary _interceptorLibrary;
public BuildSession(PipelineGraph pipelineGraph, InterceptorLibrary interceptorLibrary)
{
@@ -17,10 +15,7 @@
_interceptorLibrary = interceptorLibrary;
}
- private IInstanceFactory forType(Type pluginType)
- {
- return _pipelineGraph.ForType(pluginType);
- }
+ #region IBuildSession Members
public object CreateInstance(Type type, string name)
{
@@ -79,5 +74,12 @@
{
return forType(pluginType).FindBuilderByConcreteKey(concreteKey);
}
+
+ #endregion
+
+ private IInstanceFactory forType(Type pluginType)
+ {
+ return _pipelineGraph.ForType(pluginType);
+ }
}
-}
+}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Configuration/ConfigurationParser.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/ConfigurationParser.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Configuration/ConfigurationParser.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -1,5 +1,4 @@
using System;
-using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Xml;
@@ -48,7 +47,7 @@
includedPath = Path.Combine(folder, fileName);
includedDoc.Load(includedPath);
-
+
ConfigurationParser parser = new ConfigurationParser(includedDoc.DocumentElement);
list.Add(parser);
}
@@ -86,7 +85,7 @@
public ConfigurationParser(XmlNode structureMapNode)
{
_structureMapNode = structureMapNode;
-
+
// TODO: 3.5 cleanup with extension method
XmlMementoStyle mementoStyle = XmlMementoStyle.NodeNormalized;
@@ -128,13 +127,9 @@
foreach (XmlElement familyElement in familyNodes)
{
TypePath typePath = TypePath.CreateFromXmlNode(familyElement);
-
- builder.ConfigureFamily(typePath, delegate(PluginFamily family)
- {
- attachInstances(family, familyElement, builder);
- });
-
+ builder.ConfigureFamily(typePath,
+ delegate(PluginFamily family) { attachInstances(family, familyElement, builder); });
}
}
Modified: trunk/Source/StructureMap/Configuration/ConfigurationParserCollection.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/ConfigurationParserCollection.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Configuration/ConfigurationParserCollection.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -11,8 +11,8 @@
public class ConfigurationParserCollection
{
private readonly List<FetchNodeDelegate> _fetchers = new List<FetchNodeDelegate>();
+ private readonly List<string> _otherFiles = new List<string>();
private bool _ignoreDefaultFile = false;
- private readonly List<string> _otherFiles = new List<string>();
private bool _useAndEnforceExistenceOfDefaultFile = false;
public bool UseAndEnforceExistenceOfDefaultFile
@@ -55,7 +55,8 @@
private bool shouldUseStructureMapConfigFile(string pathToStructureMapConfig)
{
- return (_useAndEnforceExistenceOfDefaultFile || File.Exists(pathToStructureMapConfig)) && !_ignoreDefaultFile;
+ return
+ (_useAndEnforceExistenceOfDefaultFile || File.Exists(pathToStructureMapConfig)) && !_ignoreDefaultFile;
}
private static void addParsersFromFile(string filename, List<ConfigurationParser> list)
Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -4,11 +4,9 @@
using StructureMap.Graph;
using StructureMap.Interceptors;
using StructureMap.Pipeline;
-using StructureMap.Source;
namespace StructureMap.Configuration.DSL.Expressions
{
-
/// <summary>
/// Represents the parameters for creating instances of a given Type
/// </summary>
@@ -59,10 +57,7 @@
public CreatePluginFamilyExpression<PLUGINTYPE> AddInstance(Instance instance)
{
// TODO: Validate pluggability
- _alterations.Add(delegate(PluginFamily family)
- {
- family.AddInstance(instance);
- });
+ _alterations.Add(delegate(PluginFamily family) { family.AddInstance(instance); });
return this;
}
@@ -96,10 +91,7 @@
/// <returns></returns>
public CreatePluginFamilyExpression<PLUGINTYPE> CacheBy(InstanceScope scope)
{
- _alterations.Add(delegate(PluginFamily family)
- {
- family.SetScopeTo(scope);
- });
+ _alterations.Add(delegate(PluginFamily family) { family.SetScopeTo(scope); });
return this;
}
@@ -127,7 +119,7 @@
return target;
};
- PluginTypeInterceptor interceptor = new PluginTypeInterceptor(typeof(PLUGINTYPE), function);
+ PluginTypeInterceptor interceptor = new PluginTypeInterceptor(typeof (PLUGINTYPE), function);
graph.InterceptorLibrary.AddInterceptor(interceptor);
});
@@ -138,15 +130,12 @@
{
_children.Add(
delegate(PluginGraph graph)
- {
- InterceptionFunction function = delegate(object target)
- {
- return handler((PLUGINTYPE)target);
- };
+ {
+ InterceptionFunction function = delegate(object target) { return handler((PLUGINTYPE) target); };
- PluginTypeInterceptor interceptor = new PluginTypeInterceptor(typeof(PLUGINTYPE), function);
- graph.InterceptorLibrary.AddInterceptor(interceptor);
- });
+ PluginTypeInterceptor interceptor = new PluginTypeInterceptor(typeof (PLUGINTYPE), function);
+ graph.InterceptorLibrary.AddInterceptor(interceptor);
+ });
return this;
}
@@ -172,29 +161,20 @@
public CreatePluginFamilyExpression<PLUGINTYPE> InterceptConstructionWith(IBuildInterceptor interceptor)
{
- _alterations.Add(delegate(PluginFamily family)
- {
- family.AddInterceptor(interceptor);
- });
+ _alterations.Add(delegate(PluginFamily family) { family.AddInterceptor(interceptor); });
return this;
}
public CreatePluginFamilyExpression<PLUGINTYPE> AddInstancesFrom(MementoSource source)
{
- _alterations.Add(delegate(PluginFamily family)
- {
- family.AddMementoSource(source);
- });
+ _alterations.Add(delegate(PluginFamily family) { family.AddMementoSource(source); });
return this;
}
public CreatePluginFamilyExpression<PLUGINTYPE> AliasConcreteType<PLUGGEDTYPE>(string concreteKey)
{
- _alterations.Add(delegate(PluginFamily family)
- {
- family.AddPlugin(typeof(PLUGGEDTYPE), concreteKey);
- });
+ _alterations.Add(delegate(PluginFamily family) { family.AddPlugin(typeof (PLUGGEDTYPE), concreteKey); });
return this;
}
Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/InstanceDefaultExpression.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/Expressions/InstanceDefaultExpression.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Configuration/DSL/Expressions/InstanceDefaultExpression.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -11,8 +11,8 @@
{
private readonly ProfileExpression _parent;
private readonly Type _pluginType;
+ private Instance _instance;
private string _instanceKey = string.Empty;
- private Instance _instance;
public InstanceDefaultExpression(Type pluginType, ProfileExpression parent)
{
@@ -37,7 +37,7 @@
{
_instanceKey = Profile.InstanceKeyForProfile(profileName);
_instance.Name = _instanceKey;
- pluginGraph.FindFamily(_pluginType).AddInstance(_instance);
+ pluginGraph.FindFamily(_pluginType).AddInstance(_instance);
}
else if (!string.IsNullOrEmpty(_instanceKey))
{
@@ -46,7 +46,7 @@
if (_instance != null)
{
- pluginGraph.ProfileManager.SetDefault(profileName, _pluginType, _instance);
+ pluginGraph.ProfileManager.SetDefault(profileName, _pluginType, _instance);
}
else
{
Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -1,4 +1,3 @@
-using System;
using System.Collections.Generic;
using StructureMap.Graph;
Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/ScanAssembliesExpression.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/Expressions/ScanAssembliesExpression.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Configuration/DSL/Expressions/ScanAssembliesExpression.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -66,7 +66,7 @@
public ScanAssembliesExpression IncludeAssemblyContainingType<T>()
{
- _assemblies.Add(typeof(T).Assembly);
+ _assemblies.Add(typeof (T).Assembly);
return this;
}
Modified: trunk/Source/StructureMap/Configuration/DSL/Registry.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -112,10 +112,8 @@
{
ConfiguredInstance instance = new ConfiguredInstance();
- addExpression(delegate (PluginGraph pluginGraph)
- {
- pluginGraph.FindFamily(typeof(PLUGINTYPE)).AddInstance(instance);
- });
+ addExpression(
+ delegate(PluginGraph pluginGraph) { pluginGraph.FindFamily(typeof (PLUGINTYPE)).AddInstance(instance); });
return instance;
}
@@ -165,7 +163,7 @@
public LiteralInstance AddInstanceOf<PLUGINTYPE>(PLUGINTYPE target)
{
LiteralInstance literal = new LiteralInstance(target);
- _graph.FindFamily(typeof(PLUGINTYPE)).AddInstance(literal);
+ _graph.FindFamily(typeof (PLUGINTYPE)).AddInstance(literal);
return literal;
}
@@ -179,7 +177,7 @@
public PrototypeInstance AddPrototypeInstanceOf<PLUGINTYPE>(PLUGINTYPE prototype)
{
PrototypeInstance expression = new PrototypeInstance((ICloneable) prototype);
- _graph.FindFamily(typeof(PLUGINTYPE)).AddInstance(expression);
+ _graph.FindFamily(typeof (PLUGINTYPE)).AddInstance(expression);
return expression;
}
@@ -235,7 +233,7 @@
PluginFamily family = _graph.FindFamily(typeof (PLUGINTYPE));
family.AddInstance(instance);
-
+
return instance;
}
Modified: trunk/Source/StructureMap/Configuration/FamilyParser.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/FamilyParser.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Configuration/FamilyParser.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -2,7 +2,6 @@
using System.Xml;
using StructureMap.Attributes;
using StructureMap.Graph;
-using StructureMap.Interceptors;
using StructureMap.Pipeline;
using StructureMap.Source;
@@ -68,10 +67,11 @@
public void ParseInstanceElement(XmlElement element)
{
TypePath pluginTypePath = new TypePath(element.GetAttribute(XmlConstants.PLUGIN_TYPE));
-
+
_builder.ConfigureFamily(pluginTypePath, delegate(PluginFamily family)
{
- InstanceMemento memento = _mementoCreator.CreateMemento(element);
+ InstanceMemento memento =
+ _mementoCreator.CreateMemento(element);
family.AddInstance(memento);
});
}
@@ -98,12 +98,8 @@
InstanceMemento sourceMemento = new XmlAttributeInstanceMemento(sourceNode);
string context = "MementoSource for " + TypePath.GetAssemblyQualifiedName(family.PluginType);
- _builder.WithSystemObject<MementoSource>(sourceMemento, context, delegate (MementoSource source)
- {
- family.AddMementoSource(source);
- });
-
-
+ _builder.WithSystemObject<MementoSource>(sourceMemento, context,
+ delegate(MementoSource source) { family.AddMementoSource(source); });
}
}
@@ -122,14 +118,14 @@
Plugin plugin = new Plugin(pluggedType, concreteKey);
family.Plugins.Add(plugin);
- foreach (XmlElement setterElement in pluginElement.ChildNodes)
+ foreach (
+ XmlElement setterElement in pluginElement.ChildNodes)
{
- string setterName = setterElement.GetAttribute("Name");
+ string setterName =
+ setterElement.GetAttribute("Name");
plugin.Setters.Add(setterName);
}
});
-
-
}
}
@@ -142,17 +138,15 @@
return;
}
- string context = "Creating an InstanceInterceptor for " + TypePath.GetAssemblyQualifiedName(family.PluginType);
+ string context = "Creating an InstanceInterceptor for " +
+ TypePath.GetAssemblyQualifiedName(family.PluginType);
foreach (XmlNode interceptorNode in interceptorChainNode.ChildNodes)
{
XmlAttributeInstanceMemento interceptorMemento = new XmlAttributeInstanceMemento(interceptorNode);
- _builder.WithSystemObject<IBuildInterceptor>(interceptorMemento, context, delegate(IBuildInterceptor interceptor)
- {
- family.AddInterceptor(interceptor);
- });
-
+ _builder.WithSystemObject<IBuildInterceptor>(interceptorMemento, context,
+ delegate(IBuildInterceptor interceptor) { family.AddInterceptor(interceptor); });
}
}
}
Modified: trunk/Source/StructureMap/Configuration/IGraphBuilder.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/IGraphBuilder.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Configuration/IGraphBuilder.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -1,5 +1,4 @@
using System;
-using StructureMap.Attributes;
using StructureMap.Graph;
namespace StructureMap.Configuration
@@ -30,5 +29,4 @@
void WithSystemObject<T>(InstanceMemento memento, string context, Action<T> action);
void WithType(TypePath path, string context, Action<Type> action);
}
-
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Configuration/ProfileAndMachineParser.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/ProfileAndMachineParser.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Configuration/ProfileAndMachineParser.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -1,4 +1,3 @@
-using System;
using System.Xml;
using StructureMap.Graph;
using StructureMap.Pipeline;
@@ -9,9 +8,9 @@
// TODO: 3.5 cleanup
public class ProfileAndMachineParser
{
- private readonly IProfileBuilder _profileBuilder;
- private readonly IGraphBuilder _graphBuilder;
private readonly XmlMementoCreator _creator;
+ private readonly IGraphBuilder _graphBuilder;
+ private readonly IProfileBuilder _profileBuilder;
private readonly XmlNode _structureMapNode;
public ProfileAndMachineParser(IGraphBuilder graphBuilder, XmlNode structureMapNode, XmlMementoCreator creator)
@@ -91,9 +90,6 @@
family.AddInstance(memento);
function(fullName, key);
});
-
-
-
}
private XmlNodeList findNodes(string nodeName)
Modified: trunk/Source/StructureMap/Configuration/ProfileBuilder.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/ProfileBuilder.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Configuration/ProfileBuilder.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
using StructureMap.Graph;
using StructureMap.Pipeline;
@@ -8,25 +6,11 @@
{
public class ProfileBuilder : IProfileBuilder
{
- public static string GetMachineName()
- {
- string machineName = string.Empty;
- try
- {
- machineName = Environment.MachineName.ToUpper();
- }
- finally
- {
- }
-
- return machineName;
- }
-
+ private readonly string _machineName;
private readonly PluginGraph _pluginGraph;
- private readonly string _machineName;
+ private readonly ProfileManager _profileManager;
private string _lastProfile;
private bool _useMachineOverrides;
- private readonly ProfileManager _profileManager;
public ProfileBuilder(PluginGraph pluginGraph, string machineName)
@@ -42,6 +26,8 @@
{
}
+ #region IProfileBuilder Members
+
public void AddProfile(string profileName)
{
_lastProfile = profileName;
@@ -81,5 +67,21 @@
{
_profileManager.DefaultProfileName = profileName;
}
+
+ #endregion
+
+ public static string GetMachineName()
+ {
+ string machineName = string.Empty;
+ try
+ {
+ machineName = Environment.MachineName.ToUpper();
+ }
+ finally
+ {
+ }
+
+ return machineName;
+ }
}
-}
+}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Configuration/XmlConstants.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/XmlConstants.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Configuration/XmlConstants.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -1,5 +1,3 @@
-using System;
-
namespace StructureMap.Configuration
{
/// <summary>
Modified: trunk/Source/StructureMap/Diagnostics/Tokens.cs
===================================================================
--- trunk/Source/StructureMap/Diagnostics/Tokens.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Diagnostics/Tokens.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -8,9 +8,9 @@
{
public class GraphLog
{
- private List<Error> _errors = new List<Error>();
private readonly List<Source> _sources = new List<Source>();
private Source _currentSource;
+ private List<Error> _errors = new List<Error>();
public int ErrorCount
{
@@ -245,11 +245,6 @@
}
- public int Code
- {
- get { return _code; }
- }
-
public Error(StructureMapException exception)
{
_code = exception.ErrorCode;
@@ -257,12 +252,12 @@
_stackTrace = exception.StackTrace;
}
- private string getMessage(int errorCode)
+ public int Code
{
- ResourceManager resources = new ResourceManager(typeof(StructureMapException));
- return resources.GetString(errorCode.ToString());
+ get { return _code; }
}
+ #region IEquatable<Error> Members
public bool Equals(Error error)
{
@@ -276,6 +271,14 @@
return true;
}
+ #endregion
+
+ private string getMessage(int errorCode)
+ {
+ ResourceManager resources = new ResourceManager(typeof (StructureMapException));
+ return resources.GetString(errorCode.ToString());
+ }
+
public override bool Equals(object obj)
{
if (ReferenceEquals(this, obj)) return true;
Modified: trunk/Source/StructureMap/Emitting/BuildInstanceMethod.cs
===================================================================
--- trunk/Source/StructureMap/Emitting/BuildInstanceMethod.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Emitting/BuildInstanceMethod.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -1,7 +1,5 @@
using System;
-using System.Reflection;
using System.Reflection.Emit;
-using StructureMap.Emitting.Parameters;
using StructureMap.Graph;
using StructureMap.Pipeline;
@@ -33,7 +31,7 @@
public override Type[] ArgumentList
{
- get { return new Type[] { typeof(IConfiguredInstance), typeof(StructureMap.Pipeline.IBuildSession) }; }
+ get { return new Type[] {typeof (IConfiguredInstance), typeof (IBuildSession)}; }
}
public override string MethodName
Modified: trunk/Source/StructureMap/Emitting/ClassBuilder.cs
===================================================================
--- trunk/Source/StructureMap/Emitting/ClassBuilder.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Emitting/ClassBuilder.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -111,7 +111,7 @@
public void AddPluggedTypeGetter(Type pluggedType)
{
PropertyBuilder prop =
- _newTypeBuilder.DefineProperty("PluggedType", PropertyAttributes.HasDefault, typeof(Type), null);
+ _newTypeBuilder.DefineProperty("PluggedType", PropertyAttributes.HasDefault, typeof (Type), null);
MethodAttributes atts = MethodAttributes.Public | MethodAttributes.Virtual | MethodAttributes.HideBySig |
MethodAttributes.Final | MethodAttributes.SpecialName;
@@ -119,19 +119,19 @@
string getterMethodName = "get_PluggedType";
MethodBuilder methodGet =
- _newTypeBuilder.DefineMethod(getterMethodName, atts, CallingConventions.Standard, typeof(Type), null);
+ _newTypeBuilder.DefineMethod(getterMethodName, atts, CallingConventions.Standard, typeof (Type), null);
ILGenerator gen = methodGet.GetILGenerator();
- LocalBuilder ilReturn = gen.DeclareLocal(typeof(Type));
+ LocalBuilder ilReturn = gen.DeclareLocal(typeof (Type));
gen.Emit(OpCodes.Nop);
gen.Emit(OpCodes.Ldtoken, pluggedType);
- MethodInfo method = typeof(Type).GetMethod("GetTypeFromHandle");
+ 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);
Modified: trunk/Source/StructureMap/Emitting/InstanceBuilderAssembly.cs
===================================================================
--- trunk/Source/StructureMap/Emitting/InstanceBuilderAssembly.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Emitting/InstanceBuilderAssembly.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -10,9 +10,9 @@
/// </summary>
public class InstanceBuilderAssembly
{
+ private readonly List<string> _classNames = new List<string>();
private readonly DynamicAssembly _dynamicAssembly;
private readonly Type _pluginType;
- private readonly List<string> _classNames = new List<string>();
public InstanceBuilderAssembly(Type pluginType, IEnumerable<Plugin> plugins)
{
@@ -86,10 +86,9 @@
{
Assembly assembly = _dynamicAssembly.Compile();
- return _classNames.ConvertAll<InstanceBuilder>(delegate(string typeName)
- {
- return (InstanceBuilder) assembly.CreateInstance(typeName);
- });
+ return
+ _classNames.ConvertAll<InstanceBuilder>(
+ delegate(string typeName) { return (InstanceBuilder) assembly.CreateInstance(typeName); });
}
Modified: trunk/Source/StructureMap/Emitting/Parameters/ChildArrayParameterEmitter.cs
===================================================================
--- trunk/Source/StructureMap/Emitting/Parameters/ChildArrayParameterEmitter.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Emitting/Parameters/ChildArrayParameterEmitter.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -1,6 +1,7 @@
using System;
using System.Reflection;
using System.Reflection.Emit;
+using StructureMap.Pipeline;
namespace StructureMap.Emitting.Parameters
{
@@ -22,18 +23,18 @@
private void putChildArrayFromInstanceMementoOntoStack(ILGenerator ilgen, Type argumentType, string argumentName)
{
ilgen.Emit(OpCodes.Ldarg_2);
-
+
//ilgen.Emit(OpCodes.Ldstr, argumentType.GetElementType().AssemblyQualifiedName);
ilgen.Emit(OpCodes.Ldtoken, argumentType.GetElementType());
- MethodInfo method = typeof(Type).GetMethod("GetTypeFromHandle");
+ MethodInfo method = typeof (Type).GetMethod("GetTypeFromHandle");
ilgen.Emit(OpCodes.Call, method);
-
+
ilgen.Emit(OpCodes.Ldarg_1);
ilgen.Emit(OpCodes.Ldstr, argumentName);
callInstanceMemento(ilgen, "GetChildrenArray");
- MethodInfo methodCreateInstanceArray = (typeof (StructureMap.Pipeline.IBuildSession).GetMethod("CreateInstanceArray"));
+ MethodInfo methodCreateInstanceArray = (typeof (IBuildSession).GetMethod("CreateInstanceArray"));
ilgen.Emit(OpCodes.Callvirt, methodCreateInstanceArray);
cast(ilgen, argumentType);
}
Modified: trunk/Source/StructureMap/Emitting/Parameters/ParameterEmitter.cs
===================================================================
--- trunk/Source/StructureMap/Emitting/Parameters/ParameterEmitter.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Emitting/Parameters/ParameterEmitter.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -1,7 +1,6 @@
using System;
using System.Reflection;
using System.Reflection.Emit;
-using StructureMap.Graph;
using StructureMap.Pipeline;
namespace StructureMap.Emitting.Parameters
@@ -22,6 +21,6 @@
protected void cast(ILGenerator ilgen, Type parameterType)
{
ilgen.Emit(OpCodes.Castclass, parameterType);
- }
+ }
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Emitting/Parameters/StringParameterEmitter.cs
===================================================================
--- trunk/Source/StructureMap/Emitting/Parameters/StringParameterEmitter.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Emitting/Parameters/StringParameterEmitter.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -1,4 +1,3 @@
-using System;
using System.Reflection;
using System.Reflection.Emit;
Modified: trunk/Source/StructureMap/Graph/AssemblyScanner.cs
===================================================================
--- trunk/Source/StructureMap/Graph/AssemblyScanner.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Graph/AssemblyScanner.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.Reflection;
-using System.Text;
using StructureMap.Configuration.DSL;
using StructureMap.Diagnostics;
@@ -13,8 +12,8 @@
// TODO: redo in 3.5 w/ Lambdas
public class AssemblyScanner
{
- private readonly GraphLog _log;
private readonly List<Assembly> _assemblies = new List<Assembly>();
+ private readonly GraphLog _log;
public AssemblyScanner(GraphLog log)
{
@@ -33,7 +32,7 @@
{
if (Registry.IsPublicRegistry(type))
{
- Registry registry = (Registry)Activator.CreateInstance(type);
+ Registry registry = (Registry) Activator.CreateInstance(type);
registry.ConfigurePluginGraph(pluginGraph);
}
});
@@ -45,12 +44,12 @@
private void findFamiliesAndPlugins(PluginGraph pluginGraph)
{
scanTypes(delegate(Type type)
- {
- if (PluginFamilyAttribute.MarkedAsPluginFamily(type))
- {
- pluginGraph.CreateFamily(type);
- }
- });
+ {
+ if (PluginFamilyAttribute.MarkedAsPluginFamily(type))
+ {
+ pluginGraph.CreateFamily(type);
+ }
+ });
scanTypes(delegate(Type type)
{
@@ -69,7 +68,7 @@
private void scanTypes(Action<Type> action)
{
- scanTypes(new Action<Type>[]{action});
+ scanTypes(new Action<Type>[] {action});
}
private void scanTypes(IEnumerable<Action<Type>> actions)
@@ -125,4 +124,4 @@
return false;
}
}
-}
+}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Graph/Constructor.cs
===================================================================
--- trunk/Source/StructureMap/Graph/Constructor.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Graph/Constructor.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -5,6 +5,20 @@
{
public class Constructor : TypeRules
{
+ private readonly Type _pluggedType;
+ private ConstructorInfo _ctor;
+
+ public Constructor(Type pluggedType)
+ {
+ _pluggedType = pluggedType;
+ _ctor = GetConstructor(pluggedType);
+ }
+
+ public ConstructorInfo Ctor
+ {
+ get { return _ctor; }
+ }
+
/// <summary>
/// Returns the System.Reflection.ConstructorInfo for the PluggedType. Uses either
/// the "greediest" constructor with the most arguments or the constructor function
@@ -48,16 +62,6 @@
return returnValue;
}
-
- private readonly Type _pluggedType;
- private ConstructorInfo _ctor;
-
- public Constructor(Type pluggedType)
- {
- _pluggedType = pluggedType;
- _ctor = GetConstructor(pluggedType);
- }
-
public bool CanBeAutoFilled()
{
foreach (ParameterInfo parameter in _ctor.GetParameters())
@@ -75,7 +79,7 @@
{
foreach (ParameterInfo info in _ctor.GetParameters())
{
- if (info.ParameterType.Equals(typeof(T)))
+ if (info.ParameterType.Equals(typeof (T)))
{
return info.Name;
}
@@ -85,11 +89,6 @@
}
- public ConstructorInfo Ctor
- {
- get { return _ctor; }
- }
-
public void Visit(IArgumentVisitor visitor)
{
foreach (ParameterInfo info in _ctor.GetParameters())
@@ -109,4 +108,4 @@
if (IsString(parameterType)) visitor.StringParameter(info);
}
}
-}
+}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs
===================================================================
--- trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -111,7 +111,7 @@
{
if (instance.CanBePartOfPluginFamily(templatedFamily))
{
- templatedFamily.AddInstance((Instance)instance);
+ templatedFamily.AddInstance((Instance) instance);
}
}
@@ -122,7 +122,6 @@
}
-
public static Plugin CreateTemplatedClone(Plugin plugin, params Type[] types)
{
Type templatedType;
Modified: trunk/Source/StructureMap/Graph/IPluginFamily.cs
===================================================================
--- trunk/Source/StructureMap/Graph/IPluginFamily.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Graph/IPluginFamily.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -6,8 +6,6 @@
{
public interface IPluginFamily
{
- void AddMementoSource(MementoSource source);
-
/// <summary>
/// The InstanceKey of the default instance of the PluginFamily
/// </summary>
@@ -16,11 +14,10 @@
/// <summary>
/// The CLR Type that defines the "Plugin" interface for the PluginFamily
/// </summary>
- Type PluginType
- {
- get;
- }
+ Type PluginType { get; }
+ void AddMementoSource(MementoSource source);
+
void SetScopeTo(InstanceScope scope);
void AddInterceptor(IBuildInterceptor interceptor);
}
Modified: trunk/Source/StructureMap/Graph/Plugin.cs
===================================================================
--- trunk/Source/StructureMap/Graph/Plugin.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Graph/Plugin.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -1,6 +1,5 @@
using System;
using System.Reflection;
-using StructureMap.Emitting;
using StructureMap.Pipeline;
namespace StructureMap.Graph
@@ -13,11 +12,11 @@
public class Plugin : TypeRules
{
public static readonly string DEFAULT = "DEFAULT";
+ private readonly Constructor _constructor;
- private string _concreteKey;
private readonly Type _pluggedType;
private readonly SetterPropertyCollection _setters;
- private readonly Constructor _constructor;
+ private string _concreteKey;
#region constructors
@@ -44,7 +43,6 @@
#endregion
-
/// <summary>
/// The ConcreteKey that identifies the Plugin within a PluginFamily
/// </summary>
@@ -68,18 +66,12 @@
/// </summary>
public SetterPropertyCollection Setters
{
- get
- {
- return _setters;
- }
+ get { return _setters; }
}
public bool CanBeAutoFilled
{
- get
- {
- return _constructor.CanBeAutoFilled() && _setters.CanBeAutoFilled();
- }
+ get { return _constructor.CanBeAutoFilled() && _setters.CanBeAutoFilled(); }
}
public override string ToString()
@@ -95,13 +87,13 @@
public string FindFirstConstructorArgumentOfType<T>()
{
- string returnValue =
+ string returnValue =
_constructor.FindFirstConstructorArgumentOfType<T>() ??
_setters.FindFirstConstructorArgumentOfType<T>();
if (returnValue == null)
{
- throw new StructureMapException(302, typeof(T).FullName, _pluggedType.FullName);
+ throw new StructureMapException(302, typeof (T).FullName, _pluggedType.FullName);
}
return returnValue;
@@ -133,5 +125,4 @@
_setters.Visit(arguments);
}
}
-
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Graph/PluginCollection.cs
===================================================================
--- trunk/Source/StructureMap/Graph/PluginCollection.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Graph/PluginCollection.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -40,10 +40,7 @@
/// <returns></returns>
public Plugin this[Type PluggedType]
{
- get
- {
- return _plugins[PluggedType];
- }
+ get { return _plugins[PluggedType]; }
}
/// <summary>
@@ -67,6 +64,20 @@
}
}
+ #region IEnumerable<Plugin> Members
+
+ IEnumerator<Plugin> IEnumerable<Plugin>.GetEnumerator()
+ {
+ return _plugins.Values.GetEnumerator();
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return ((IEnumerable<Plugin>) this).GetEnumerator();
+ }
+
+ #endregion
+
/// <summary>
/// Adds a new Plugin by the PluggedType
/// </summary>
@@ -98,7 +109,8 @@
if (!TypeRules.CanBeCast(_family.PluginType, plugin.PluggedType))
{
// TODO -- get this logged
- throw new StructureMapException(114, plugin.PluggedType.FullName, _family.PluginType.AssemblyQualifiedName);
+ throw new StructureMapException(114, plugin.PluggedType.FullName,
+ _family.PluginType.AssemblyQualifiedName);
}
_plugins.Add(plugin.PluggedType, plugin);
@@ -129,16 +141,6 @@
return plugin;
}
- IEnumerator<Plugin> IEnumerable<Plugin>.GetEnumerator()
- {
- return _plugins.Values.GetEnumerator();
- }
-
- public IEnumerator GetEnumerator()
- {
- return ((IEnumerable<Plugin>) this).GetEnumerator();
- }
-
public List<Plugin> FindAutoFillablePlugins()
{
List<Plugin> list = new List<Plugin>();
Modified: trunk/Source/StructureMap/Graph/PluginFamily.cs
===================================================================
--- trunk/Source/StructureMap/Graph/PluginFamily.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Graph/PluginFamily.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -1,9 +1,6 @@
using System;
-using System.Collections;
using System.Collections.Generic;
-using System.Diagnostics;
using StructureMap.Attributes;
-using StructureMap.Interceptors;
using StructureMap.Pipeline;
namespace StructureMap.Graph
@@ -15,16 +12,15 @@
/// </summary>
public class PluginFamily : TypeRules, IPluginFamily
{
+ private readonly Predicate<Type> _explicitlyMarkedPluginFilter;
+ private readonly Predicate<Type> _implicitPluginFilter;
+ private readonly List<Instance> _instances = new List<Instance>();
private readonly List<InstanceMemento> _mementoList = new List<InstanceMemento>();
private readonly PluginCollection _plugins;
+ private readonly Type _pluginType;
+ private IBuildPolicy _buildPolicy = new BuildPolicy();
private string _defaultKey = string.Empty;
private PluginGraph _parent;
- 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;
@@ -35,8 +31,8 @@
PluginFamilyAttribute.ConfigureFamily(this);
- _explicitlyMarkedPluginFilter = delegate(Type type) { return TypeRules.IsExplicitlyMarkedAsPlugin(PluginType, type); };
- _implicitPluginFilter = delegate(Type type) { return TypeRules.CanBeCast(PluginType, type); };
+ _explicitlyMarkedPluginFilter = delegate(Type type) { return IsExplicitlyMarkedAsPlugin(PluginType, type); };
+ _implicitPluginFilter = delegate(Type type) { return CanBeCast(PluginType, type); };
_pluginFilter = _explicitlyMarkedPluginFilter;
if (IsConcrete(pluginType))
@@ -53,91 +49,69 @@
set { _parent = value; }
}
- public void AddInstance(InstanceMemento memento)
- {
- _mementoList.Add(memento);
- }
+ #region IPluginFamily Members
- public void AddInstance(Instance instance)
- {
- _instances.Add(instance);
- }
-
- // TODO -- eliminate this. Move to GraphBuilder, and wrap error handling around it
public void AddMementoSource(MementoSource source)
{
_mementoList.AddRange(source.GetAllMementos());
}
- // For testing
- public InstanceMemento GetMemento(string instanceKey)
+ public void SetScopeTo(InstanceScope scope)
{
- return _mementoList.Find(delegate(InstanceMemento m) { return m.InstanceKey == instanceKey; });
- }
+ switch (scope)
+ {
+ case InstanceScope.Singleton:
+ AddInterceptor(new SingletonPolicy());
+ break;
+ case InstanceScope.HttpContext:
+ AddInterceptor(new HttpContextBuildPolicy());
+ break;
+ case InstanceScope.ThreadLocal:
+ AddInterceptor(new ThreadLocalStoragePolicy());
+ break;
- #region properties
-
- /// <summary>
- /// The CLR Type that defines the "Plugin" interface for the PluginFamily
- /// </summary>
- public Type PluginType
- {
- get { return _pluginType; }
+ case InstanceScope.Hybrid:
+ AddInterceptor(new HybridBuildPolicy());
+ break;
+ }
}
- /// <summary>
- /// The InstanceKey of the default instance of the PluginFamily
- /// </summary>
- public string DefaultInstanceKey
+ public void AddInterceptor(IBuildInterceptor interceptor)
{
- get { return _defaultKey; }
- set { _defaultKey = value ?? string.Empty; }
+ interceptor.InnerPolicy = _buildPolicy;
+ _buildPolicy = interceptor;
}
- public PluginCollection Plugins
- {
- get { return _plugins; }
- }
+ #endregion
- public bool IsGenericTemplate
+ public void AddInstance(InstanceMemento memento)
{
- get { return _pluginType.IsGenericTypeDefinition; }
+ _mementoList.Add(memento);
}
- public bool SearchForImplicitPlugins
+ public void AddInstance(Instance instance)
{
- get
- {
- return ReferenceEquals(_pluginFilter, _implicitPluginFilter);
- }
- set
- {
- _pluginFilter = value ? _implicitPluginFilter : _explicitlyMarkedPluginFilter;
- }
+ _instances.Add(instance);
}
- public IBuildPolicy Policy
- {
- get { return _buildPolicy; }
- set { _policy = value; }
- }
+ // TODO -- eliminate this. Move to GraphBuilder, and wrap error handling around it
- public int PluginCount
+ // For testing
+ public InstanceMemento GetMemento(string instanceKey)
{
- get { return _plugins.Count; }
+ return _mementoList.Find(delegate(InstanceMemento m) { return m.InstanceKey == instanceKey; });
}
- #endregion
public void Seal()
{
_mementoList.ForEach(delegate(InstanceMemento memento)
- {
- Instance instance = memento.ReadInstance(Parent, _pluginType);
- _instances.Add(instance);
- });
+ {
+ Instance instance = memento.ReadInstance(Parent, _pluginType);
+ _instances.Add(instance);
+ });
discoverImplicitInstances();
@@ -151,13 +125,8 @@
{
// TODO: Apply some 3.5 lambda magic. Maybe move to PluginCollection
List<Plugin> list = _plugins.FindAutoFillablePlugins();
- list.RemoveAll(delegate(Plugin plugin)
- {
- return _instances.Exists(delegate(Instance instance)
- {
- return instance.Matches(plugin);
- });
- });
+ list.RemoveAll(
+ delegate(Plugin plugin) { return _instances.Exists(delegate(Instance instance) { return instance.Matches(plugin); }); });
foreach (Plugin plugin in list)
{
@@ -175,35 +144,7 @@
return _instances.Find(delegate(Instance i) { return i.Name == name; });
}
- 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;
- }
- }
-
- public void AddInterceptor(IBuildInterceptor interceptor)
- {
- interceptor.InnerPolicy = _buildPolicy;
- _buildPolicy = interceptor;
- }
-
-
public void AnalyzeTypeForPlugin(Type pluggedType)
{
if (_pluginFilter(pluggedType))
@@ -246,5 +187,53 @@
{
return string.IsNullOrEmpty(_defaultKey) ? null : GetInstance(_defaultKey);
}
+
+ #region properties
+
+ public PluginCollection Plugins
+ {
+ get { return _plugins; }
+ }
+
+ public bool IsGenericTemplate
+ {
+ get { return _pluginType.IsGenericTypeDefinition; }
+ }
+
+ public bool SearchForImplicitPlugins
+ {
+ get { return ReferenceEquals(_pluginFilter, _implicitPluginFilter); }
+ set { _pluginFilter = value ? _implicitPluginFilter : _explicitlyMarkedPluginFilter; }
+ }
+
+ public IBuildPolicy Policy
+ {
+ get { return _buildPolicy; }
+ set { _policy = value; }
+ }
+
+ public int PluginCount
+ {
+ get { return _plugins.Count; }
+ }
+
+ /// <summary>
+ /// The CLR Type that defines the "Plugin" interface for the PluginFamily
+ /// </summary>
+ public Type PluginType
+ {
+ get { return _pluginType; }
+ }
+
+ /// <summary>
+ /// The InstanceKey of the default instance of the PluginFamily
+ /// </summary>
+ public string DefaultInstanceKey
+ {
+ get { return _defaultKey; }
+ set { _defaultKey = value ?? string.Empty; }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Graph/PluginFamilyCollection.cs
===================================================================
--- trunk/Source/StructureMap/Graph/PluginFamilyCollection.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Graph/PluginFamilyCollection.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -9,8 +9,8 @@
/// </summary>
public class PluginFamilyCollection : IEnumerable<PluginFamily>
{
+ private readonly Dictionary<Type, PluginFamily> _pluginFamilies;
private readonly PluginGraph _pluginGraph;
- private readonly Dictionary<Type, PluginFamily> _pluginFamilies;
public PluginFamilyCollection(PluginGraph pluginGraph)
{
@@ -37,7 +37,20 @@
get { return _pluginFamilies.Count; }
}
+ #region IEnumerable<PluginFamily> Members
+ IEnumerator<PluginFamily> IEnumerable<PluginFamily>.GetEnumerator()
+ {
+ return _pluginFamilies.Values.GetEnumerator();
+ }
+
+ public IEnumerator GetEnumerator()
+ {
+ return ((IEnumerable<PluginFamily>) this).GetEnumerator();
+ }
+
+ #endregion
+
public PluginFamily Add(PluginFamily family)
{
family.Parent = _pluginGraph;
@@ -69,17 +82,5 @@
{
return Contains(typeof (T));
}
-
-
-
- IEnumerator<PluginFamily> IEnumerable<PluginFamily>.GetEnumerator()
- {
- return _pluginFamilies.Values.GetEnumerator();
- }
-
- public IEnumerator GetEnumerator()
- {
- return ((IEnumerable<PluginFamily>) this).GetEnumerator();
- }
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Graph/SetterPropertyCollection.cs
===================================================================
--- trunk/Source/StructureMap/Graph/SetterPropertyCollection.cs 2008-05-15 16:32:20 UTC (rev 96)
+++ trunk/Source/StructureMap/Graph/SetterPropertyCollection.cs 2008-05-15 18:15:44 UTC (rev 97)
@@ -1,7 +1,5 @@
-using System;
using System.Collections;
using System.Collections.Generic;
-using System.Collections.Specialized;
using System.Reflection;
using StructureMap.Attributes;
@@ -34,7 +32,7 @@
{
SetterProperty[] returnValue = new SetterProperty[_properties.Count];
_properties.Values.CopyTo(returnValue, 0);
-
+
...
[truncated message content] |