|
From: <jer...@us...> - 2008-10-05 02:51:23
|
Revision: 172
http://structuremap.svn.sourceforge.net/structuremap/?rev=172&view=rev
Author: jeremydmiller
Date: 2008-10-05 02:50:36 +0000 (Sun, 05 Oct 2008)
Log Message:
-----------
More cleanup
Modified Paths:
--------------
trunk/Source/StructureMap/Exceptions/MissingPluginFamilyException.cs
trunk/Source/StructureMap/Exceptions/StructureMapConfigurationException.cs
trunk/Source/StructureMap/Exceptions/StructureMapException.cs
trunk/Source/StructureMap/Graph/AssemblyScanner.cs
trunk/Source/StructureMap/Graph/Constructor.cs
trunk/Source/StructureMap/Graph/FamilyAttributeScanner.cs
trunk/Source/StructureMap/Graph/FindAllTypesFilter.cs
trunk/Source/StructureMap/Graph/FindRegistriesScanner.cs
trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs
trunk/Source/StructureMap/Graph/ITypeScanner.cs
trunk/Source/StructureMap/Graph/PluggableAttributeScanner.cs
trunk/Source/StructureMap/Graph/Plugin.cs
trunk/Source/StructureMap/Graph/PluginCache.cs
trunk/Source/StructureMap/Graph/PluginFamily.cs
trunk/Source/StructureMap/Graph/PluginFamilyCollection.cs
trunk/Source/StructureMap/Graph/PluginGraph.cs
trunk/Source/StructureMap/Graph/SetterProperty.cs
trunk/Source/StructureMap/Graph/SetterPropertyCollection.cs
trunk/Source/StructureMap/Graph/TypePath.cs
trunk/Source/StructureMap/Graph/TypeRules.cs
trunk/Source/StructureMap/Interceptors/CompoundInterceptor.cs
trunk/Source/StructureMap/Interceptors/MatchedTypeInterceptor.cs
trunk/Source/StructureMap/Pipeline/BuildFrame.cs
trunk/Source/StructureMap/Pipeline/BuildStack.cs
trunk/Source/StructureMap/Pipeline/CacheInterceptor.cs
trunk/Source/StructureMap/Pipeline/ConfiguredInstance.Expressions.cs
trunk/Source/StructureMap/Pipeline/ConfiguredInstance.cs
trunk/Source/StructureMap/Pipeline/ConfiguredInstanceBase.cs
trunk/Source/StructureMap/Pipeline/ConstructorInstance.cs
trunk/Source/StructureMap/Pipeline/DefaultInstance.cs
trunk/Source/StructureMap/Pipeline/ExplicitArguments.cs
trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs
trunk/Source/StructureMap/Pipeline/HybridBuildPolicy.cs
trunk/Source/StructureMap/Pipeline/IConfiguredInstance.cs
trunk/Source/StructureMap/Pipeline/Instance.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/PrototypeInstance.cs
trunk/Source/StructureMap/Pipeline/ReferencedInstance.cs
trunk/Source/StructureMap/Pipeline/SerializedInstance.cs
trunk/Source/StructureMap/Pipeline/SmartInstance.cs
trunk/Source/StructureMap/Pipeline/ThreadLocalStoragePolicy.cs
trunk/Source/StructureMap/Source/DirectoryXmlMementoSource.cs
trunk/Source/StructureMap/Source/EmbeddedFolderXmlMementoSource.cs
trunk/Source/StructureMap/Source/MemoryMementoSource.cs
trunk/Source/StructureMap/Source/SingleEmbeddedXmlMementoSource.cs
trunk/Source/StructureMap/Source/TemplatedMementoSource.cs
trunk/Source/StructureMap/Source/XmlAttributeInstanceMemento.cs
trunk/Source/StructureMap/Source/XmlFileMementoSource.cs
trunk/Source/StructureMap/Source/XmlMementoCreator.cs
trunk/Source/StructureMap/Source/XmlMementoSource.cs
trunk/Source/StructureMap/Source/XmlNodeInstanceMemento.cs
trunk/Source/StructureMap/Source/XmlTemplater.cs
trunk/Source/StructureMap/Util/Cache.cs
Modified: trunk/Source/StructureMap/Exceptions/MissingPluginFamilyException.cs
===================================================================
--- trunk/Source/StructureMap/Exceptions/MissingPluginFamilyException.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Exceptions/MissingPluginFamilyException.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -6,27 +6,27 @@
[Serializable]
public class MissingPluginFamilyException : ApplicationException
{
- private string _message;
+ private readonly string _message;
- public MissingPluginFamilyException(string pluginTypeName) : base()
+ public MissingPluginFamilyException(string pluginTypeName)
{
_message = string.Format("Type {0} is not a configured PluginFamily", pluginTypeName);
}
- public override string Message
- {
- get { return _message; }
- }
-
protected MissingPluginFamilyException(SerializationInfo info, StreamingContext context) :
base(info, context)
{
_message = info.GetString("message");
}
+ public override string Message
+ {
+ get { return _message; }
+ }
+
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
- info.AddValue("message", _message, typeof(string));
+ info.AddValue("message", _message, typeof (string));
base.GetObjectData(info, context);
}
Modified: trunk/Source/StructureMap/Exceptions/StructureMapConfigurationException.cs
===================================================================
--- trunk/Source/StructureMap/Exceptions/StructureMapConfigurationException.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Exceptions/StructureMapConfigurationException.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -16,4 +16,4 @@
{
}
}
-}
+}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Exceptions/StructureMapException.cs
===================================================================
--- trunk/Source/StructureMap/Exceptions/StructureMapException.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Exceptions/StructureMapException.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -1,5 +1,4 @@
using System;
-using System.Resources;
using System.Runtime.Serialization;
namespace StructureMap
@@ -11,8 +10,8 @@
[Serializable]
public class StructureMapException : ApplicationException
{
- private int _errorCode;
- private string _msg;
+ private readonly int _errorCode;
+ private readonly string _msg;
protected StructureMapException(SerializationInfo info, StreamingContext context) :
@@ -23,7 +22,7 @@
}
- public StructureMapException(int ErrorCode, params object[] args) : base()
+ public StructureMapException(int ErrorCode, params object[] args)
{
_errorCode = ErrorCode;
_msg = string.Format("StructureMap Exception Code: {0}\n", _errorCode);
@@ -49,7 +48,6 @@
}
-
public override void GetObjectData(SerializationInfo info, StreamingContext context)
{
info.AddValue("errorCode", _errorCode, typeof (int));
Modified: trunk/Source/StructureMap/Graph/AssemblyScanner.cs
===================================================================
--- trunk/Source/StructureMap/Graph/AssemblyScanner.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Graph/AssemblyScanner.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -4,7 +4,6 @@
using System.Linq;
using System.Reflection;
using System.Threading;
-using StructureMap.Diagnostics;
namespace StructureMap.Graph
{
@@ -19,9 +18,9 @@
public class AssemblyScanner
{
private readonly List<Assembly> _assemblies = new List<Assembly>();
- private readonly List<ITypeScanner> _scanners = new List<ITypeScanner>();
- private readonly List<Predicate<Type>> _includes = new List<Predicate<Type>>();
private readonly List<Predicate<Type>> _excludes = new List<Predicate<Type>>();
+ private readonly List<Predicate<Type>> _includes = new List<Predicate<Type>>();
+ private readonly List<ITypeScanner> _scanners = new List<ITypeScanner>();
public AssemblyScanner()
{
@@ -35,7 +34,6 @@
}
-
public void ScanForAll(PluginGraph pluginGraph)
{
_assemblies.ForEach(assem => scanTypesInAssembly(assem, pluginGraph));
@@ -151,7 +149,7 @@
private static Assembly findTheCallingAssembly()
{
- StackTrace trace = new StackTrace(Thread.CurrentThread, false);
+ var trace = new StackTrace(Thread.CurrentThread, false);
Assembly thisAssembly = System.Reflection.Assembly.GetExecutingAssembly();
Assembly callingAssembly = null;
@@ -170,7 +168,7 @@
public void AssemblyContainingType<T>()
{
- _assemblies.Add(typeof(T).Assembly);
+ _assemblies.Add(typeof (T).Assembly);
}
public void AssemblyContainingType(Type type)
@@ -180,7 +178,7 @@
public void AddAllTypesOf<PLUGINTYPE>()
{
- AddAllTypesOf(typeof(PLUGINTYPE));
+ AddAllTypesOf(typeof (PLUGINTYPE));
}
public void AddAllTypesOf(Type pluginType)
@@ -207,7 +205,7 @@
public void ExcludeNamespaceContainingType<T>()
{
- ExcludeNamespace(typeof(T).Namespace);
+ ExcludeNamespace(typeof (T).Namespace);
}
public void Include(Predicate<Type> predicate)
Modified: trunk/Source/StructureMap/Graph/Constructor.cs
===================================================================
--- trunk/Source/StructureMap/Graph/Constructor.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Graph/Constructor.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -5,8 +5,8 @@
{
public class Constructor : TypeRules
{
+ private readonly ConstructorInfo _ctor;
private readonly Type _pluggedType;
- private ConstructorInfo _ctor;
public Constructor(Type pluggedType)
{
Modified: trunk/Source/StructureMap/Graph/FamilyAttributeScanner.cs
===================================================================
--- trunk/Source/StructureMap/Graph/FamilyAttributeScanner.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Graph/FamilyAttributeScanner.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -4,6 +4,8 @@
{
public class FamilyAttributeScanner : ITypeScanner
{
+ #region ITypeScanner Members
+
public void Process(Type type, PluginGraph graph)
{
if (PluginFamilyAttribute.MarkedAsPluginFamily(type))
@@ -11,5 +13,7 @@
graph.CreateFamily(type);
}
}
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Graph/FindAllTypesFilter.cs
===================================================================
--- trunk/Source/StructureMap/Graph/FindAllTypesFilter.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Graph/FindAllTypesFilter.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -11,6 +11,8 @@
_pluginType = pluginType;
}
+ #region ITypeScanner Members
+
public void Process(Type type, PluginGraph graph)
{
if (CanBeCast(_pluginType, type))
@@ -18,5 +20,7 @@
graph.AddType(_pluginType, type);
}
}
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Graph/FindRegistriesScanner.cs
===================================================================
--- trunk/Source/StructureMap/Graph/FindRegistriesScanner.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Graph/FindRegistriesScanner.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -5,11 +5,13 @@
{
public class FindRegistriesScanner : ITypeScanner
{
+ #region ITypeScanner Members
+
public void Process(Type type, PluginGraph graph)
{
if (!Registry.IsPublicRegistry(type)) return;
- foreach (var previous in graph.Registries)
+ foreach (Registry previous in graph.Registries)
{
if (previous.GetType().Equals(type))
{
@@ -17,8 +19,10 @@
}
}
- Registry registry = (Registry)Activator.CreateInstance(type);
+ var registry = (Registry) Activator.CreateInstance(type);
registry.ConfigurePluginGraph(graph);
}
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs
===================================================================
--- trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -1,5 +1,4 @@
using System;
-using System.Collections;
using System.Collections.Generic;
using StructureMap.Pipeline;
using StructureMap.Util;
@@ -24,7 +23,7 @@
{
get
{
- foreach (var family in _families)
+ foreach (PluginFamily family in _families)
{
yield return family.GetConfiguration();
}
@@ -95,7 +94,6 @@
PluginFamily basicFamily = _families.Retrieve(basicType);
Type[] templatedParameterTypes = templatedType.GetGenericArguments();
-
PluginFamily family = CreateTemplatedClone(basicFamily, templatedParameterTypes);
profileManager.CopyDefaults(basicType, templatedType, family);
@@ -111,13 +109,11 @@
// TODO: This code sucks. What's going on here?
public static PluginFamily CreateTemplatedClone(PluginFamily baseFamily, params Type[] templateTypes)
{
-
PluginFamily templatedFamily = baseFamily.CreateTemplatedClone(templateTypes);
return templatedFamily;
}
-
public static bool CanBePluggedIntoGenericType(Type pluginType, Type pluggedType, params Type[] templateTypes)
{
bool isValid = true;
Modified: trunk/Source/StructureMap/Graph/ITypeScanner.cs
===================================================================
--- trunk/Source/StructureMap/Graph/ITypeScanner.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Graph/ITypeScanner.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
namespace StructureMap.Graph
{
Modified: trunk/Source/StructureMap/Graph/PluggableAttributeScanner.cs
===================================================================
--- trunk/Source/StructureMap/Graph/PluggableAttributeScanner.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Graph/PluggableAttributeScanner.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -4,6 +4,8 @@
{
public class PluggableAttributeScanner : ITypeScanner
{
+ #region ITypeScanner Members
+
public void Process(Type type, PluginGraph graph)
{
if (PluggableAttribute.MarkedAsPluggable(type))
@@ -11,5 +13,7 @@
graph.AddType(type);
}
}
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Graph/Plugin.cs
===================================================================
--- trunk/Source/StructureMap/Graph/Plugin.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Graph/Plugin.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -144,8 +144,8 @@
{
Type templatedType = _pluggedType.IsGenericType ? _pluggedType.MakeGenericType(types) : _pluggedType;
- Plugin templatedPlugin = new Plugin(templatedType, ConcreteKey);
-
+ var templatedPlugin = new Plugin(templatedType, ConcreteKey);
+
foreach (SetterProperty setter in Setters)
{
templatedPlugin.Setters.MarkSetterAsMandatory(setter.Name);
Modified: trunk/Source/StructureMap/Graph/PluginCache.cs
===================================================================
--- trunk/Source/StructureMap/Graph/PluginCache.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Graph/PluginCache.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Linq;
using StructureMap.Emitting;
@@ -9,8 +9,8 @@
public static class PluginCache
{
private static readonly Cache<Type, InstanceBuilder> _builders;
+ private static readonly List<Type> _filledTypes = new List<Type>();
private static readonly Cache<Type, Plugin> _plugins;
- private static List<Type> _filledTypes = new List<Type>();
static PluginCache()
{
@@ -37,7 +37,8 @@
{
lock (typeof (PluginCache))
{
- IEnumerable<Plugin> plugins = _plugins.Where(plugin => pluginHasNoBuilder(plugin) && plugin.CanBeCreated());
+ IEnumerable<Plugin> plugins =
+ _plugins.Where(plugin => pluginHasNoBuilder(plugin) && plugin.CanBeCreated());
createAndStoreBuilders(plugins);
}
}
@@ -65,7 +66,7 @@
internal static void ResetAll()
{
- lock (typeof(PluginCache))
+ lock (typeof (PluginCache))
{
_builders.Clear();
_plugins.Clear();
Modified: trunk/Source/StructureMap/Graph/PluginFamily.cs
===================================================================
--- trunk/Source/StructureMap/Graph/PluginFamily.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Graph/PluginFamily.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -152,7 +152,7 @@
{
if (plugin.CanBeAutoFilled && !hasInstanceWithPluggedType(plugin))
{
- var instance = new ConfiguredInstance(plugin.PluggedType).WithName(key);
+ ConfiguredInstance instance = new ConfiguredInstance(plugin.PluggedType).WithName(key);
AddInstance(instance);
}
});
@@ -216,54 +216,6 @@
return string.IsNullOrEmpty(_defaultKey) ? null : GetInstance(_defaultKey);
}
- #region properties
-
-
- public bool IsGenericTemplate
- {
- get { return _pluginType.IsGenericTypeDefinition || _pluginType.ContainsGenericParameters; }
- }
-
- public IBuildPolicy Policy
- {
- get { return _buildPolicy; }
- set { _policy = value; }
- }
-
- public int PluginCount
- {
- get { return _pluggedTypes.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; }
- }
-
- public int InstanceCount
- {
- get { return _instances.Count; }
- }
-
- public IEnumerable<IInstance> Instances
- {
- get { return _instances.GetAll(); }
- }
-
- #endregion
-
public Plugin FindPlugin(Type pluggedType)
{
return _pluggedTypes.Find(p => p.PluggedType == pluggedType);
@@ -325,16 +277,13 @@
public PluginFamily CreateTemplatedClone(Type[] templateTypes)
{
Type templatedType = _pluginType.MakeGenericType(templateTypes);
- PluginFamily templatedFamily = new PluginFamily(templatedType, Parent);
+ var templatedFamily = new PluginFamily(templatedType, Parent);
templatedFamily.DefaultInstanceKey = DefaultInstanceKey;
templatedFamily.Policy = Policy.Clone();
// TODO -- Got a big problem here. Intances need to be copied over
- EachInstance(i =>
- {
- ((IDiagnosticInstance)i).AddTemplatedInstanceTo(templatedFamily, templateTypes);
- });
+ EachInstance(i => { ((IDiagnosticInstance) i).AddTemplatedInstanceTo(templatedFamily, templateTypes); });
// Need to attach the new PluginFamily to the old PluginGraph
Parent.PluginFamilies.Add(templatedFamily);
@@ -364,13 +313,60 @@
public PluginTypeConfiguration GetConfiguration()
{
- return new PluginTypeConfiguration()
- {
- Default = GetDefaultInstance(),
- PluginType = PluginType,
- Policy = _buildPolicy,
- Instances = Instances
- };
+ return new PluginTypeConfiguration
+ {
+ Default = GetDefaultInstance(),
+ PluginType = PluginType,
+ Policy = _buildPolicy,
+ Instances = Instances
+ };
}
+
+ #region properties
+
+ public bool IsGenericTemplate
+ {
+ get { return _pluginType.IsGenericTypeDefinition || _pluginType.ContainsGenericParameters; }
+ }
+
+ public IBuildPolicy Policy
+ {
+ get { return _buildPolicy; }
+ set { _policy = value; }
+ }
+
+ public int PluginCount
+ {
+ get { return _pluggedTypes.Count; }
+ }
+
+ public int InstanceCount
+ {
+ get { return _instances.Count; }
+ }
+
+ public IEnumerable<IInstance> Instances
+ {
+ get { return _instances.GetAll(); }
+ }
+
+ /// <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-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Graph/PluginFamilyCollection.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -24,7 +24,7 @@
{
if (!_pluginFamilies.ContainsKey(pluginType))
{
- PluginFamily family = new PluginFamily(pluginType, _pluginGraph);
+ var family = new PluginFamily(pluginType, _pluginGraph);
Add(family);
}
@@ -41,7 +41,7 @@
{
get
{
- PluginFamily[] families = new PluginFamily[_pluginFamilies.Count];
+ var families = new PluginFamily[_pluginFamilies.Count];
_pluginFamilies.Values.CopyTo(families, 0);
return families;
}
@@ -95,7 +95,7 @@
public void Each(Action<PluginFamily> action)
{
- foreach (var family in All)
+ foreach (PluginFamily family in All)
{
action(family);
}
Modified: trunk/Source/StructureMap/Graph/PluginGraph.cs
===================================================================
--- trunk/Source/StructureMap/Graph/PluginGraph.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Graph/PluginGraph.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -40,19 +40,6 @@
_scanners.Add(assemblies);
}
- public void Scan(Action<AssemblyScanner> action)
- {
- var scanner = new AssemblyScanner();
- action(scanner);
-
- AddScanner(scanner);
- }
-
- public void ScanThisAssembly()
- {
- Scan(x => x.TheCallingAssembly());
- }
-
public List<Registry> Registries
{
get { return _registries; }
@@ -114,6 +101,19 @@
#endregion
+ public void Scan(Action<AssemblyScanner> action)
+ {
+ var scanner = new AssemblyScanner();
+ action(scanner);
+
+ AddScanner(scanner);
+ }
+
+ public void ScanThisAssembly()
+ {
+ Scan(x => x.TheCallingAssembly());
+ }
+
public void AddScanner(AssemblyScanner scanner)
{
_scanners.Add(scanner);
Modified: trunk/Source/StructureMap/Graph/SetterProperty.cs
===================================================================
--- trunk/Source/StructureMap/Graph/SetterProperty.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Graph/SetterProperty.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -12,10 +12,10 @@
private readonly PropertyInfo _property;
- public SetterProperty(PropertyInfo property) : base()
+ public SetterProperty(PropertyInfo property)
{
_property = property;
- var att = Attribute.GetCustomAttribute(property, typeof (SetterPropertyAttribute));
+ Attribute att = Attribute.GetCustomAttribute(property, typeof (SetterPropertyAttribute));
IsMandatory = att != null;
}
Modified: trunk/Source/StructureMap/Graph/SetterPropertyCollection.cs
===================================================================
--- trunk/Source/StructureMap/Graph/SetterPropertyCollection.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Graph/SetterPropertyCollection.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -2,7 +2,6 @@
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
-using StructureMap.Attributes;
namespace StructureMap.Graph
{
@@ -12,7 +11,7 @@
public class SetterPropertyCollection : IEnumerable<SetterProperty>
{
private readonly Plugin _plugin;
- private List<SetterProperty> _properties;
+ private readonly List<SetterProperty> _properties;
public SetterPropertyCollection(Plugin plugin)
{
@@ -20,12 +19,11 @@
_plugin = plugin;
-
foreach (PropertyInfo property in plugin.PluggedType.GetProperties())
{
if (property.CanWrite && property.GetSetMethod(false) != null)
{
- SetterProperty setter = new SetterProperty(property);
+ var setter = new SetterProperty(property);
_properties.Add(setter);
}
}
@@ -57,7 +55,7 @@
public SetterProperty MarkSetterAsMandatory(string propertyName)
{
- var setter = _properties.Find(p => p.Property.Name == propertyName);
+ SetterProperty setter = _properties.Find(p => p.Property.Name == propertyName);
if (setter == null)
{
throw new StructureMapException(240, propertyName, _plugin.PluggedType);
Modified: trunk/Source/StructureMap/Graph/TypePath.cs
===================================================================
--- trunk/Source/StructureMap/Graph/TypePath.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Graph/TypePath.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -65,7 +65,7 @@
public static string GetAssemblyQualifiedName(Type type)
{
- TypePath path = new TypePath(type);
+ var path = new TypePath(type);
return path.AssemblyQualifiedName;
}
@@ -84,7 +84,7 @@
public override bool Equals(object obj)
{
- TypePath peer = obj as TypePath;
+ var peer = obj as TypePath;
if (peer == null)
{
return false;
Modified: trunk/Source/StructureMap/Graph/TypeRules.cs
===================================================================
--- trunk/Source/StructureMap/Graph/TypeRules.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Graph/TypeRules.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -62,7 +62,7 @@
protected bool IsPrimitive(Type type)
{
- return type.IsPrimitive && !IsString(type) && type != typeof(IntPtr);
+ return type.IsPrimitive && !IsString(type) && type != typeof (IntPtr);
}
protected bool IsSimple(Type type)
Modified: trunk/Source/StructureMap/Interceptors/CompoundInterceptor.cs
===================================================================
--- trunk/Source/StructureMap/Interceptors/CompoundInterceptor.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Interceptors/CompoundInterceptor.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -32,7 +32,7 @@
public InstanceInterceptor Merge(InstanceInterceptor interceptor)
{
- InstanceInterceptor[] interceptors = new InstanceInterceptor[_interceptors.Length + 1];
+ var interceptors = new InstanceInterceptor[_interceptors.Length + 1];
_interceptors.CopyTo(interceptors, 0);
interceptors[interceptors.Length - 1] = interceptor;
Modified: trunk/Source/StructureMap/Interceptors/MatchedTypeInterceptor.cs
===================================================================
--- trunk/Source/StructureMap/Interceptors/MatchedTypeInterceptor.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Interceptors/MatchedTypeInterceptor.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using System.Text;
namespace StructureMap.Interceptors
{
@@ -33,4 +31,4 @@
_interception = interception;
}
}
-}
+}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Pipeline/BuildFrame.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/BuildFrame.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Pipeline/BuildFrame.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -4,9 +4,11 @@
{
public class BuildFrame
{
- private readonly Type _requestedType;
- private readonly string _name;
private readonly Type _concreteType;
+ private readonly string _name;
+ private readonly Type _requestedType;
+ private BuildFrame _next;
+ private BuildFrame _parent;
public BuildFrame(Type requestedType, string name, Type concreteType)
{
@@ -30,8 +32,10 @@
get { return _concreteType; }
}
- private BuildFrame _parent;
- private BuildFrame _next;
+ internal BuildFrame Parent
+ {
+ get { return _parent; }
+ }
internal void Attach(BuildFrame next)
{
@@ -45,24 +49,18 @@
return _parent;
}
- internal BuildFrame Parent
- {
- get
- {
- return _parent;
- }
- }
-
public override string ToString()
{
- return string.Format("RequestedType: {0}, Name: {1}, ConcreteType: {2}", _requestedType, _name, _concreteType);
+ return string.Format("RequestedType: {0}, Name: {1}, ConcreteType: {2}", _requestedType, _name,
+ _concreteType);
}
public bool Equals(BuildFrame obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
- return Equals(obj._requestedType, _requestedType) && Equals(obj._name, _name) && Equals(obj._concreteType, _concreteType);
+ return Equals(obj._requestedType, _requestedType) && Equals(obj._name, _name) &&
+ Equals(obj._concreteType, _concreteType);
}
public override bool Equals(object obj)
Modified: trunk/Source/StructureMap/Pipeline/BuildStack.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/BuildStack.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Pipeline/BuildStack.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -1,15 +1,12 @@
-using System.Collections.Generic;
-
namespace StructureMap.Pipeline
{
public class BuildStack
{
- private BuildFrame _root;
private BuildFrame _current;
+ private BuildFrame _root;
internal BuildStack()
{
-
}
public BuildFrame Root
@@ -24,10 +21,7 @@
public BuildFrame Parent
{
- get
- {
- return _current.Parent;
- }
+ get { return _current.Parent; }
}
internal void Push(BuildFrame frame)
Modified: trunk/Source/StructureMap/Pipeline/CacheInterceptor.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/CacheInterceptor.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Pipeline/CacheInterceptor.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -51,7 +51,7 @@
public override string ToString()
{
- return GetType().FullName + " / " + _innerPolicy.ToString();
+ return GetType().FullName + " / " + _innerPolicy;
}
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Pipeline/ConfiguredInstance.Expressions.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/ConfiguredInstance.Expressions.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Pipeline/ConfiguredInstance.Expressions.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -1,6 +1,5 @@
using System;
using StructureMap.Configuration.DSL;
-using StructureMap.Graph;
using StructureMap.Interceptors;
namespace StructureMap.Pipeline
@@ -15,7 +14,7 @@
public ConfiguredInstance OnCreation<TYPE>(Action<TYPE> handler)
{
- StartupInterceptor<TYPE> interceptor = new StartupInterceptor<TYPE>(handler);
+ var interceptor = new StartupInterceptor<TYPE>(handler);
Interceptor = interceptor;
return this;
@@ -23,7 +22,7 @@
public ConfiguredInstance EnrichWith<TYPE>(EnrichmentHandler<TYPE> handler)
{
- EnrichmentInterceptor<TYPE> interceptor = new EnrichmentInterceptor<TYPE>(handler);
+ var interceptor = new EnrichmentInterceptor<TYPE>(handler);
Interceptor = interceptor;
return this;
@@ -34,7 +33,7 @@
{
validateTypeIsArray<PLUGINTYPE>();
- ChildArrayExpression expression =
+ var expression =
new ChildArrayExpression(this, propertyName);
return expression;
@@ -84,7 +83,7 @@
/// <returns></returns>
public ChildInstanceExpression Child<CONSTRUCTORARGUMENTTYPE>(string propertyName)
{
- ChildInstanceExpression child = new ChildInstanceExpression(this, propertyName);
+ var child = new ChildInstanceExpression(this, propertyName);
child.ChildType = typeof (CONSTRUCTORARGUMENTTYPE);
return child;
@@ -161,7 +160,7 @@
/// <returns></returns>
public ConfiguredInstance IsNamedInstance(string instanceKey)
{
- ReferencedInstance instance = new ReferencedInstance(instanceKey);
+ var instance = new ReferencedInstance(instanceKey);
_instance.setChild(_propertyName, instance);
return _instance;
@@ -177,7 +176,7 @@
Type pluggedType = typeof (T);
ExpressionValidator.ValidatePluggabilityOf(pluggedType).IntoPluginType(_childType);
- ConfiguredInstance childInstance = new ConfiguredInstance(pluggedType);
+ var childInstance = new ConfiguredInstance(pluggedType);
_instance.setChild(_propertyName, childInstance);
return _instance;
@@ -198,21 +197,17 @@
public ConfiguredInstance Is(object value)
{
- LiteralInstance instance = new LiteralInstance(value);
+ var instance = new LiteralInstance(value);
return Is(instance);
}
public ConfiguredInstance IsAutoFilled()
{
- DefaultInstance instance = new DefaultInstance();
+ var instance = new DefaultInstance();
return Is(instance);
}
}
#endregion
-
- #region Nested type: PropertyExpression
-
- #endregion
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Pipeline/ConfiguredInstance.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/ConfiguredInstance.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Pipeline/ConfiguredInstance.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -1,20 +1,15 @@
using System;
-using System.Collections.Generic;
using StructureMap.Graph;
namespace StructureMap.Pipeline
{
public partial class ConfiguredInstance : ConfiguredInstanceBase<ConfiguredInstance>
{
- public static Type GetGenericType(Type templateType, params Type[] types)
+ public ConfiguredInstance(InstanceMemento memento, PluginGraph graph, Type pluginType)
+ : base(memento, graph, pluginType)
{
- return templateType.MakeGenericType(types);
}
- public ConfiguredInstance(InstanceMemento memento, PluginGraph graph, Type pluginType) : base(memento, graph, pluginType)
- {
- }
-
public ConfiguredInstance(Type pluggedType, string name) : base(pluggedType, name)
{
}
@@ -26,13 +21,13 @@
public ConfiguredInstance(Type templateType, params Type[] types) : base(GetGenericType(templateType, types))
{
-
}
- #region IStructuredInstance Members
+ public static Type GetGenericType(Type templateType, params Type[] types)
+ {
+ return templateType.MakeGenericType(types);
+ }
- #endregion
-
protected void setPluggedType(Type pluggedType)
{
_pluggedType = pluggedType;
@@ -41,13 +36,12 @@
protected override void preprocess(PluginFamily family)
{
-
}
protected override string getDescription()
{
string typeName = _pluggedType.AssemblyQualifiedName;
- Constructor ctor = new Constructor(_pluggedType);
+ var ctor = new Constructor(_pluggedType);
if (ctor.HasArguments())
{
return "Configured " + typeName;
@@ -60,10 +54,12 @@
protected override void addTemplatedInstanceTo(PluginFamily family, Type[] templateTypes)
{
- Type specificType = _pluggedType.IsGenericTypeDefinition ? _pluggedType.MakeGenericType(templateTypes) : _pluggedType;
+ Type specificType = _pluggedType.IsGenericTypeDefinition
+ ? _pluggedType.MakeGenericType(templateTypes)
+ : _pluggedType;
if (TypeRules.CanBeCast(family.PluginType, specificType))
{
- ConfiguredInstance instance = new ConfiguredInstance(specificType);
+ var instance = new ConfiguredInstance(specificType);
instance._arrays = _arrays;
instance._children = _children;
instance._properties = _properties;
Modified: trunk/Source/StructureMap/Pipeline/ConfiguredInstanceBase.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/ConfiguredInstanceBase.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Pipeline/ConfiguredInstanceBase.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -1,5 +1,4 @@
using System;
-using System.Collections;
using System.Collections.Generic;
using StructureMap.Graph;
@@ -16,10 +15,10 @@
public abstract class ConfiguredInstanceBase<T> : Instance, IConfiguredInstance, IStructuredInstance, Copyable
{
+ protected Dictionary<string, Instance[]> _arrays = new Dictionary<string, Instance[]>();
protected Dictionary<string, Instance> _children = new Dictionary<string, Instance>();
+ protected Type _pluggedType;
protected Dictionary<string, string> _properties = new Dictionary<string, string>();
- protected Dictionary<string, Instance[]> _arrays = new Dictionary<string, Instance[]>();
- protected Type _pluggedType;
protected ConfiguredInstanceBase(InstanceMemento memento, PluginGraph graph, Type pluginType)
{
@@ -41,14 +40,109 @@
}
}
+ #region Copyable Members
+ Type Copyable.PluggedType
+ {
+ get { return _pluggedType; }
+ }
+
+ Dictionary<string, string> Copyable.Properties
+ {
+ get { return _properties; }
+ }
+
+ Dictionary<string, Instance> Copyable.Children
+ {
+ get { return _children; }
+ }
+
+ Dictionary<string, Instance[]> Copyable.Arrays
+ {
+ get { return _arrays; }
+ }
+
+ #endregion
+
+ #region IConfiguredInstance Members
+
Type IConfiguredInstance.PluggedType
{
get { return _pluggedType; }
}
+ Instance[] IConfiguredInstance.GetChildrenArray(string propertyName)
+ {
+ return _arrays.ContainsKey(propertyName) ? _arrays[propertyName] : null;
+ }
+ string IConfiguredInstance.GetProperty(string propertyName)
+ {
+ if (!_properties.ContainsKey(propertyName))
+ {
+ throw new StructureMapException(205, propertyName, Name);
+ }
+ return _properties[propertyName];
+ }
+
+ object IConfiguredInstance.GetChild(string propertyName, Type pluginType, BuildSession buildSession)
+ {
+ return getChild(propertyName, pluginType, buildSession);
+ }
+
+ object IConfiguredInstance.Build(Type pluginType, BuildSession session, InstanceBuilder builder)
+ {
+ if (builder == null)
+ {
+ throw new StructureMapException(
+ 201, _pluggedType.FullName, Name, pluginType);
+ }
+
+
+ try
+ {
+ return builder.BuildInstance(this, session);
+ }
+ catch (StructureMapException)
+ {
+ throw;
+ }
+ catch (InvalidCastException ex)
+ {
+ throw new StructureMapException(206, ex, Name);
+ }
+ catch (Exception ex)
+ {
+ throw new StructureMapException(207, ex, Name, pluginType.FullName);
+ }
+ }
+
+ bool IConfiguredInstance.HasProperty(string propertyName)
+ {
+ return _properties.ContainsKey(propertyName) || _children.ContainsKey(propertyName) ||
+ _arrays.ContainsKey(propertyName);
+ }
+
+ void IConfiguredInstance.SetProperty(string propertyName, string propertyValue)
+ {
+ setProperty(propertyName, propertyValue);
+ }
+
+ void IConfiguredInstance.SetChild(string name, Instance instance)
+ {
+ setChild(name, instance);
+ }
+
+ void IConfiguredInstance.SetChildArray(string name, Type type, Instance[] children)
+ {
+ setChildArray(name, children);
+ }
+
+ #endregion
+
+ #region IStructuredInstance Members
+
Instance IStructuredInstance.GetChild(string name)
{
return _children[name];
@@ -64,6 +158,8 @@
_properties.Remove(name);
}
+ #endregion
+
protected override object build(Type pluginType, BuildSession session)
{
InstanceBuilder builder = PluginCache.FindBuilder(_pluggedType);
@@ -97,7 +193,7 @@
_pluggedType = plugin.PluggedType;
- InstanceMementoPropertyReader reader = new InstanceMementoPropertyReader(this, memento, graph, pluginType);
+ var reader = new InstanceMementoPropertyReader(this, memento, graph, pluginType);
plugin.VisitArguments(reader);
}
@@ -113,58 +209,6 @@
_arrays.Add(name, array);
}
- Instance[] IConfiguredInstance.GetChildrenArray(string propertyName)
- {
- return _arrays.ContainsKey(propertyName) ? _arrays[propertyName] : null;
- }
-
- string IConfiguredInstance.GetProperty(string propertyName)
- {
- if (!_properties.ContainsKey(propertyName))
- {
- throw new StructureMapException(205, propertyName, Name);
- }
-
- return _properties[propertyName];
- }
-
- object IConfiguredInstance.GetChild(string propertyName, Type pluginType, BuildSession buildSession)
- {
- return getChild(propertyName, pluginType, buildSession);
- }
-
- object IConfiguredInstance.Build(Type pluginType, BuildSession session, InstanceBuilder builder)
- {
- if (builder == null)
- {
- throw new StructureMapException(
- 201, _pluggedType.FullName, Name, pluginType);
- }
-
-
- try
- {
- return builder.BuildInstance(this, session);
- }
- catch (StructureMapException)
- {
- throw;
- }
- catch (InvalidCastException ex)
- {
- throw new StructureMapException(206, ex, Name);
- }
- catch (Exception ex)
- {
- throw new StructureMapException(207, ex, Name, pluginType.FullName);
- }
- }
-
- bool IConfiguredInstance.HasProperty(string propertyName)
- {
- return _properties.ContainsKey(propertyName) || _children.ContainsKey(propertyName) || _arrays.ContainsKey(propertyName);
- }
-
protected override Type getConcreteType(Type pluginType)
{
return _pluggedType;
@@ -172,7 +216,7 @@
protected string findPropertyName<T>()
{
- Plugin plugin = new Plugin(_pluggedType);
+ var plugin = new Plugin(_pluggedType);
string propertyName = plugin.FindArgumentNameForType<T>();
if (string.IsNullOrEmpty(propertyName))
@@ -191,32 +235,17 @@
}
}
- void IConfiguredInstance.SetProperty(string propertyName, string propertyValue)
- {
- setProperty(propertyName, propertyValue);
- }
-
protected void setProperty(string propertyName, string propertyValue)
{
if (string.IsNullOrEmpty(propertyValue)) return;
_properties[propertyName] = propertyValue;
}
- void IConfiguredInstance.SetChild(string name, Instance instance)
- {
- setChild(name, instance);
- }
-
- void IConfiguredInstance.SetChildArray(string name, Type type, Instance[] children)
- {
- setChildArray(name, children);
- }
-
protected void mergeIntoThis(Copyable instance)
{
_pluggedType = instance.PluggedType;
- foreach (KeyValuePair<string, string> pair in instance.Properties)
+ foreach (var pair in instance.Properties)
{
if (!_properties.ContainsKey(pair.Key))
{
@@ -224,7 +253,7 @@
}
}
- foreach (KeyValuePair<string, Instance> pair in instance.Children)
+ foreach (var pair in instance.Children)
{
if (!_children.ContainsKey(pair.Key))
{
@@ -234,25 +263,5 @@
_arrays = instance.Arrays;
}
-
- Type Copyable.PluggedType
- {
- get { return _pluggedType; }
- }
-
- Dictionary<string, string> Copyable.Properties
- {
- get { return _properties; }
- }
-
- Dictionary<string, Instance> Copyable.Children
- {
- get { return _children; }
- }
-
- Dictionary<string, Instance[]> Copyable.Arrays
- {
- get { return _arrays; }
- }
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Pipeline/ConstructorInstance.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/ConstructorInstance.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Pipeline/ConstructorInstance.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -2,8 +2,6 @@
namespace StructureMap.Pipeline
{
-
-
public class ConstructorInstance<T> : ExpressedInstance<ConstructorInstance<T>>
{
private readonly Func<IContext, T> _builder;
@@ -37,7 +35,7 @@
protected override string getDescription()
{
- return "Instance is created by Func<object> function: " + _builder.ToString();
+ return "Instance is created by Func<object> function: " + _builder;
}
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Pipeline/DefaultInstance.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/DefaultInstance.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Pipeline/DefaultInstance.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -9,6 +9,11 @@
int x = 1;
}
+ protected override bool doesRecordOnTheStack
+ {
+ get { return false; }
+ }
+
protected override object build(Type pluginType, BuildSession session)
{
return session.CreateInstance(pluginType);
@@ -18,10 +23,5 @@
{
return "Default";
}
-
- protected override bool doesRecordOnTheStack
- {
- get { return false; }
- }
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Pipeline/ExplicitArguments.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/ExplicitArguments.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Pipeline/ExplicitArguments.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -44,7 +44,7 @@
public void Configure(IConfiguredInstance instance)
{
- foreach (KeyValuePair<string, object> arg in _args)
+ foreach (var arg in _args)
{
if (arg.Value == null) continue;
@@ -81,7 +81,7 @@
args.Configure(this);
_args = args;
- Copyable defaultConfiguration = defaultInstance as Copyable;
+ var defaultConfiguration = defaultInstance as Copyable;
if (defaultConfiguration != null)
{
mergeIntoThis(defaultConfiguration);
Modified: trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Pipeline/HttpContextBuildPolicy.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -5,7 +5,7 @@
{
public class HttpContextBuildPolicy : CacheInterceptor
{
- private string _prefix = Guid.NewGuid().ToString();
+ private readonly string _prefix = Guid.NewGuid().ToString();
public static bool HasContext()
{
Modified: trunk/Source/StructureMap/Pipeline/HybridBuildPolicy.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/HybridBuildPolicy.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Pipeline/HybridBuildPolicy.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -29,7 +29,7 @@
public IBuildPolicy Clone()
{
- HybridBuildPolicy policy = new HybridBuildPolicy();
+ var policy = new HybridBuildPolicy();
policy.InnerPolicy = InnerPolicy.Clone();
return policy;
Modified: trunk/Source/StructureMap/Pipeline/IConfiguredInstance.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/IConfiguredInstance.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Pipeline/IConfiguredInstance.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -15,6 +15,4 @@
void SetChild(string name, Instance instance);
void SetChildArray(string name, Type type, Instance[] children);
}
-
-
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Pipeline/Instance.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/Instance.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Pipeline/Instance.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -1,6 +1,4 @@
using System;
-using System.Collections.Generic;
-using StructureMap.Configuration.DSL;
using StructureMap.Diagnostics;
using StructureMap.Graph;
using StructureMap.Interceptors;
@@ -13,7 +11,7 @@
{
string key = PluginCache.GetPlugin(type).ConcreteKey;
return new ReferencedInstance(key);
- }
+ }
}
public interface IInstance
@@ -44,69 +42,25 @@
_originalName = _name;
}
- public string Name
- {
- get { return _name; }
- set { _name = value; }
- }
-
- public virtual object Build(Type pluginType, BuildSession session)
- {
- markBuildStackStart(session, pluginType);
-
- object rawValue = createRawObject(pluginType, session);
- var finalValue = applyInterception(rawValue, pluginType);
-
- markBuildStackFinish(session);
-
- return finalValue;
- }
-
- protected virtual void markBuildStackFinish(BuildSession session)
- {
- if (!doesRecordOnTheStack) return;
-
- session.BuildStack.Pop();
- }
-
- protected virtual void markBuildStackStart(BuildSession session, Type pluginType)
- {
- if (!doesRecordOnTheStack) return;
-
- session.BuildStack.Push(new BuildFrame(pluginType, Name, getConcreteType(pluginType)));
- }
-
protected virtual bool doesRecordOnTheStack
{
get { return true; }
}
- private object createRawObject(Type pluginType, BuildSession session)
- {
- try
- {
- return build(pluginType, session);
- }
- catch (StructureMapException ex)
- {
- throw;
- }
- catch (Exception ex)
- {
- throw new StructureMapException(400, ex);
- }
- }
-
public InstanceInterceptor Interceptor
{
get { return _interceptor; }
set { _interceptor = value; }
}
-
-
#region IDiagnosticInstance Members
+ public string Name
+ {
+ get { return _name; }
+ set { _name = value; }
+ }
+
bool IDiagnosticInstance.CanBePartOfPluginFamily(PluginFamily family)
{
return canBePartOfPluginFamily(family);
@@ -142,6 +96,50 @@
get { return getDescription(); }
}
+ #endregion
+
+ public virtual object Build(Type pluginType, BuildSession session)
+ {
+ markBuildStackStart(session, pluginType);
+
+ object rawValue = createRawObject(pluginType, session);
+ object finalValue = applyInterception(rawValue, pluginType);
+
+ markBuildStackFinish(session);
+
+ return finalValue;
+ }
+
+ protected virtual void markBuildStackFinish(BuildSession session)
+ {
+ if (!doesRecordOnTheStack) return;
+
+ session.BuildStack.Pop();
+ }
+
+ protected virtual void markBuildStackStart(BuildSession session, Type pluginType)
+ {
+ if (!doesRecordOnTheStack) return;
+
+ session.BuildStack.Push(new BuildFrame(pluginType, Name, getConcreteType(pluginType)));
+ }
+
+ private object createRawObject(Type pluginType, BuildSession session)
+ {
+ try
+ {
+ return build(pluginType, session);
+ }
+ catch (StructureMapException ex)
+ {
+ throw;
+ }
+ catch (Exception ex)
+ {
+ throw new StructureMapException(400, ex);
+ }
+ }
+
protected virtual Type getConcreteType(Type pluginType)
{
return pluginType;
@@ -162,8 +160,6 @@
protected abstract string getDescription();
- #endregion
-
protected void replaceNameIfNotAlreadySet(string name)
{
if (_name == _originalName)
@@ -173,7 +169,6 @@
}
-
private object applyInterception(object rawValue, Type pluginType)
{
try
@@ -200,7 +195,6 @@
}
-
internal virtual bool Matches(Plugin plugin)
{
return false;
@@ -219,7 +213,7 @@
public T OnCreation<TYPE>(Action<TYPE> handler)
{
- StartupInterceptor<TYPE> interceptor = new StartupInterceptor<TYPE>(handler);
+ var interceptor = new StartupInterceptor<TYPE>(handler);
Interceptor = interceptor;
return thisInstance;
@@ -227,11 +221,10 @@
public T EnrichWith<TYPE>(EnrichmentHandler<TYPE> handler)
{
- EnrichmentInterceptor<TYPE> interceptor = new EnrichmentInterceptor<TYPE>(handler);
+ var interceptor = new EnrichmentInterceptor<TYPE>(handler);
Interceptor = interceptor;
return thisInstance;
}
}
-
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Pipeline/InstanceMementoPropertyReader.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/InstanceMementoPropertyReader.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Pipeline/InstanceMementoPropertyReader.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -82,7 +82,7 @@
{
throw new StructureMapException(205, name, _memento.InstanceKey);
}
-
+
_instance.SetProperty(name, propertyValue);
}
@@ -97,7 +97,7 @@
{
InstanceMemento[] mementoes = _memento.GetChildrenArray(name) ?? new InstanceMemento[0];
- Instance[] children = new Instance[mementoes.Length];
+ var children = new Instance[mementoes.Length];
for (int i = 0; i < mementoes.Length; i++)
{
InstanceMemento memento = mementoes[i];
Modified: trunk/Source/StructureMap/Pipeline/LiteralInstance.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/LiteralInstance.cs 2008-10-05 02:43:34 UTC (rev 171)
+++ trunk/Source/StructureMap/Pipeline/LiteralInstance.cs 2008-10-05 02:50:36 UTC (rev 172)
@@ -41,7 +41,7 @@
protected override string getDescription()
{
- return "Object: " + _object.ToString();
+ return "Object: " + _object;
}
public override string ToString()
Modified: trunk/Source/StructureMap/Pipeline/Profile.cs
===================================================================
--- trunk/Source/StructureMap/Pipeline/Profile.cs 2008-10-05 02...
[truncated message content] |