|
From: <jer...@us...> - 2008-10-05 02:43:43
|
Revision: 171
http://structuremap.svn.sourceforge.net/structuremap/?rev=171&view=rev
Author: jeremydmiller
Date: 2008-10-05 02:43:34 +0000 (Sun, 05 Oct 2008)
Log Message:
-----------
doing some ReSharper clean ups
Modified Paths:
--------------
trunk/Source/StructureMap/Attributes/DefaultConstructorAttribute.cs
trunk/Source/StructureMap/Attributes/PluggableAttribute.cs
trunk/Source/StructureMap/Attributes/PluginFamilyAttribute.cs
trunk/Source/StructureMap/Attributes/SetterPropertyAttribute.cs
trunk/Source/StructureMap/Attributes/ValidationMethodAttribute.cs
trunk/Source/StructureMap/Configuration/ConfigurationParser.cs
trunk/Source/StructureMap/Configuration/ConfigurationParserBuilder.cs
trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs
trunk/Source/StructureMap/Configuration/DSL/Expressions/InstanceExpression.cs
trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs
trunk/Source/StructureMap/Configuration/DSL/Registry.cs
trunk/Source/StructureMap/Configuration/DictionaryReader.cs
trunk/Source/StructureMap/Configuration/FamilyParser.cs
trunk/Source/StructureMap/Configuration/ITypeReader.cs
trunk/Source/StructureMap/Configuration/PrimitiveArrayReader.cs
trunk/Source/StructureMap/Configuration/ProfileAndMachineParser.cs
trunk/Source/StructureMap/Configuration/ProfileBuilder.cs
trunk/Source/StructureMap/Configuration/StructureMapConfigurationSection.cs
trunk/Source/StructureMap/Configuration/TypeReaderFactory.cs
trunk/Source/StructureMap/Configuration/XmlExtensions.cs
trunk/Source/StructureMap/Diagnostics/BuildError.cs
trunk/Source/StructureMap/Diagnostics/CharacterWidth.cs
trunk/Source/StructureMap/Diagnostics/DividerLine.cs
trunk/Source/StructureMap/Diagnostics/Doctor.cs
trunk/Source/StructureMap/Diagnostics/DoctorReport.cs
trunk/Source/StructureMap/Diagnostics/DoctorRunner.cs
trunk/Source/StructureMap/Diagnostics/Error.cs
trunk/Source/StructureMap/Diagnostics/ErrorCollection.cs
trunk/Source/StructureMap/Diagnostics/GraphLog.cs
trunk/Source/StructureMap/Diagnostics/TextLine.cs
trunk/Source/StructureMap/Diagnostics/TextReportWriter.cs
trunk/Source/StructureMap/Diagnostics/ValidationBuildSession.cs
trunk/Source/StructureMap/Diagnostics/ValidationError.cs
trunk/Source/StructureMap/Diagnostics/WhatDoIHaveWriter.cs
trunk/Source/StructureMap/Emitting/ArgumentEmitter.cs
trunk/Source/StructureMap/Emitting/BuildInstanceMethod.cs
trunk/Source/StructureMap/Emitting/DynamicAssembly.cs
trunk/Source/StructureMap/Emitting/InstanceBuilderAssembly.cs
trunk/Source/StructureMap/Emitting/Method.cs
trunk/Source/StructureMap/Emitting/Parameters/ChildArrayParameterEmitter.cs
trunk/Source/StructureMap/Emitting/Parameters/Methods.cs
trunk/Source/StructureMap/Emitting/Parameters/ParameterEmitter.cs
trunk/Source/StructureMap/Emitting/Parameters/PrimitiveParameterEmitter.cs
trunk/Source/StructureMap/Emitting/Parameters/StringParameterEmitter.cs
Modified: trunk/Source/StructureMap/Attributes/DefaultConstructorAttribute.cs
===================================================================
--- trunk/Source/StructureMap/Attributes/DefaultConstructorAttribute.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Attributes/DefaultConstructorAttribute.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -10,10 +10,6 @@
[AttributeUsage(AttributeTargets.Constructor)]
public class DefaultConstructorAttribute : Attribute
{
- public DefaultConstructorAttribute()
- {
- }
-
/// <summary>
/// Examines a System.Type object and determines the ConstructorInfo to use in creating
/// instances of the Type
Modified: trunk/Source/StructureMap/Attributes/PluggableAttribute.cs
===================================================================
--- trunk/Source/StructureMap/Attributes/PluggableAttribute.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Attributes/PluggableAttribute.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -8,22 +8,16 @@
[AttributeUsage(AttributeTargets.Class)]
public class PluggableAttribute : Attribute
{
- private string _concreteKey;
-
public PluggableAttribute(string concreteKey)
{
- _concreteKey = concreteKey;
+ ConcreteKey = concreteKey;
}
/// <summary>
/// The ConcreteKey alias of the Type
/// </summary>
- public string ConcreteKey
- {
- get { return _concreteKey; }
- set { _concreteKey = value; }
- }
+ public string ConcreteKey { get; set; }
/// <summary>
/// Gets an instance of PluggableAttribute from a Type object
Modified: trunk/Source/StructureMap/Attributes/PluginFamilyAttribute.cs
===================================================================
--- trunk/Source/StructureMap/Attributes/PluginFamilyAttribute.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Attributes/PluginFamilyAttribute.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -9,9 +9,8 @@
/// </summary>
public class PluginFamilyAttribute : Attribute
{
- private string _default = string.Empty;
+ private readonly string _default = string.Empty;
private InstanceScope _scope = InstanceScope.PerRequest;
- private Type _source = null;
public PluginFamilyAttribute()
{
@@ -33,11 +32,7 @@
set { _scope = value; }
}
- public Type SourceType
- {
- get { return _source; }
- set { _source = value; }
- }
+ public Type SourceType { get; set; }
/// <summary>
/// InstanceKey of the default instance. Used to implicitly define the default without
@@ -66,14 +61,14 @@
/// <returns></returns>
public static bool MarkedAsPluginFamily(Type objectType)
{
- PluginFamilyAttribute att =
+ var att =
GetCustomAttribute(objectType, typeof (PluginFamilyAttribute), false) as PluginFamilyAttribute;
return (att != null);
}
public static void ConfigureFamily(IPluginFamily family)
{
- PluginFamilyAttribute att =
+ var att =
GetCustomAttribute(family.PluginType, typeof (PluginFamilyAttribute), false)
as PluginFamilyAttribute;
@@ -89,7 +84,7 @@
{
try
{
- MementoSource source = (MementoSource) Activator.CreateInstance(SourceType);
+ var source = (MementoSource) Activator.CreateInstance(SourceType);
family.AddMementoSource(source);
}
catch (Exception ex)
Modified: trunk/Source/StructureMap/Attributes/SetterPropertyAttribute.cs
===================================================================
--- trunk/Source/StructureMap/Attributes/SetterPropertyAttribute.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Attributes/SetterPropertyAttribute.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -19,12 +19,12 @@
return new PropertyInfo[0];
}
- ArrayList list = new ArrayList();
+ var list = new ArrayList();
PropertyInfo[] properties = pluggedType.GetProperties();
foreach (PropertyInfo property in properties)
{
- SetterPropertyAttribute att =
+ var att =
GetCustomAttribute(property, typeof (SetterPropertyAttribute)) as SetterPropertyAttribute;
if (att != null)
@@ -37,9 +37,5 @@
}
#endregion
-
- public SetterPropertyAttribute()
- {
- }
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Attributes/ValidationMethodAttribute.cs
===================================================================
--- trunk/Source/StructureMap/Attributes/ValidationMethodAttribute.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Attributes/ValidationMethodAttribute.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -12,10 +12,6 @@
[AttributeUsage(AttributeTargets.Method)]
public class ValidationMethodAttribute : Attribute
{
- public ValidationMethodAttribute()
- {
- }
-
/// <summary>
/// Returns an array of any MethodInfo's on a Type that are marked as ValidationMethod
/// </summary>
@@ -23,12 +19,12 @@
/// <returns></returns>
public static MethodInfo[] GetValidationMethods(Type objectType)
{
- ArrayList methodList = new ArrayList();
+ var methodList = new ArrayList();
MethodInfo[] methods = objectType.GetMethods();
foreach (MethodInfo method in methods)
{
- ValidationMethodAttribute att =
+ var att =
(ValidationMethodAttribute) GetCustomAttribute(method, typeof (ValidationMethodAttribute));
if (att != null)
@@ -46,7 +42,7 @@
}
}
- MethodInfo[] returnValue = new MethodInfo[methodList.Count];
+ var returnValue = new MethodInfo[methodList.Count];
methodList.CopyTo(returnValue, 0);
return returnValue;
Modified: trunk/Source/StructureMap/Configuration/ConfigurationParser.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/ConfigurationParser.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Configuration/ConfigurationParser.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -2,7 +2,6 @@
using System.IO;
using System.Xml;
using StructureMap.Diagnostics;
-using StructureMap.Graph;
using StructureMap.Source;
namespace StructureMap.Configuration
@@ -40,10 +39,12 @@
_structureMapNode = structureMapNode;
XmlMementoStyle mementoStyle = XmlMementoStyle.NodeNormalized;
- _structureMapNode.ForAttributeValue(MEMENTO_STYLE, style =>
- {
- if (style == ATTRIBUTE_STYLE) mementoStyle = XmlMementoStyle.AttributeNormalized;
- });
+ _structureMapNode.ForAttributeValue(MEMENTO_STYLE,
+ style =>
+ {
+ if (style == ATTRIBUTE_STYLE)
+ mementoStyle = XmlMementoStyle.AttributeNormalized;
+ });
_mementoCreator = new XmlMementoCreator(
mementoStyle,
@@ -114,6 +115,5 @@
ParseProfilesAndMachines(builder);
}
-
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Configuration/ConfigurationParserBuilder.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/ConfigurationParserBuilder.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Configuration/ConfigurationParserBuilder.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -29,6 +29,8 @@
_log = log;
}
+ #region IConfigurationParserBuilder Members
+
public bool UseAndEnforceExistenceOfDefaultFile
{
get { return _useAndEnforceExistenceOfDefaultFile; }
@@ -48,6 +50,22 @@
set { _pullConfigurationFromAppConfig = value; }
}
+ public void IncludeFile(string filename)
+ {
+ _otherFiles.Add(filename);
+ }
+
+
+ public void IncludeNode(XmlNode node, string description)
+ {
+ var parser = new ConfigurationParser(node);
+ parser.Description = description;
+
+ _parsers.Add(parser);
+ }
+
+ #endregion
+
public ConfigurationParser[] GetParsers()
{
var list = new List<ConfigurationParser>();
@@ -126,20 +144,6 @@
}
- public void IncludeFile(string filename)
- {
- _otherFiles.Add(filename);
- }
-
-
- public void IncludeNode(XmlNode node, string description)
- {
- var parser = new ConfigurationParser(node);
- parser.Description = description;
-
- _parsers.Add(parser);
- }
-
public static ConfigurationParser[] GetParsers(XmlNode node, GraphLog log)
{
var builder = new ConfigurationParserBuilder(log);
Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -44,10 +44,7 @@
{
var instance = new ConfiguredInstance(concreteType);
- alterAndContinue(family =>
- {
- family.AddInstance(instance);
- });
+ alterAndContinue(family => { family.AddInstance(instance); });
return instance;
}
@@ -77,7 +74,7 @@
{
_registry.addExpression(graph =>
{
- PluginTypeInterceptor interceptor = new PluginTypeInterceptor(_pluginType, func);
+ var interceptor = new PluginTypeInterceptor(_pluginType, func);
graph.InterceptorLibrary.AddInterceptor(interceptor);
});
Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/InstanceExpression.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/Expressions/InstanceExpression.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Configuration/DSL/Expressions/InstanceExpression.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -1,4 +1,4 @@
-using System;
+using System;
using StructureMap.Pipeline;
namespace StructureMap.Configuration.DSL.Expressions
@@ -38,6 +38,25 @@
_action = action;
}
+ #region IsExpression<T> Members
+
+ InstanceExpression<T> IsExpression<T>.Is
+ {
+ get { return this; }
+ }
+
+ public void IsThis(Instance instance)
+ {
+ returnInstance(instance);
+ }
+
+ public LiteralInstance IsThis(T obj)
+ {
+ return returnInstance(new LiteralInstance(obj));
+ }
+
+ #endregion
+
public void Instance(Instance instance)
{
_action(instance);
@@ -64,21 +83,6 @@
return returnInstance(new LiteralInstance(theObject));
}
- InstanceExpression<T> IsExpression<T>.Is
- {
- get { return this; }
- }
-
- public void IsThis(Instance instance)
- {
- returnInstance(instance);
- }
-
- public LiteralInstance IsThis(T obj)
- {
- return returnInstance(new LiteralInstance(obj));
- }
-
public ReferencedInstance References(string key)
{
return returnInstance(new ReferencedInstance(key));
@@ -114,4 +118,4 @@
return returnInstance(new UserControlInstance(url));
}
}
-}
+}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -1,5 +1,4 @@
using System;
-using StructureMap.Graph;
using StructureMap.Pipeline;
namespace StructureMap.Configuration.DSL.Expressions
@@ -39,6 +38,43 @@
return new GenericDefaultExpression(this, pluginType);
}
+ #region Nested type: GenericDefaultExpression
+
+ public class GenericDefaultExpression
+ {
+ private readonly ProfileExpression _parent;
+ private readonly Type _pluginType;
+ private readonly Registry _registry;
+
+ internal GenericDefaultExpression(ProfileExpression parent, Type pluginType)
+ {
+ _parent = parent;
+ _registry = parent._registry;
+ _pluginType = pluginType;
+ }
+
+ public ProfileExpression UseConcreteType(Type concreteType)
+ {
+ var instance = new ConfiguredInstance(concreteType);
+ return Use(instance);
+ }
+
+ public ProfileExpression Use(Instance instance)
+ {
+ _registry.addExpression(graph => graph.SetDefault(_parent._profileName, _pluginType, instance));
+
+ return _parent;
+ }
+
+ public ProfileExpression UseNamedInstance(string name)
+ {
+ var instance = new ReferencedInstance(name);
+ return Use(instance);
+ }
+ }
+
+ #endregion
+
#region Nested type: InstanceDefaultExpression
public class InstanceDefaultExpression<T>
@@ -61,7 +97,8 @@
/// <returns></returns>
public ProfileExpression UseNamedInstance(string instanceKey)
{
- _registry.addExpression(graph => graph.SetDefault(_profileName, typeof (T), new ReferencedInstance(instanceKey)));
+ _registry.addExpression(
+ graph => graph.SetDefault(_profileName, typeof (T), new ReferencedInstance(instanceKey)));
return _parent;
}
@@ -82,62 +119,29 @@
public ProfileExpression Use(Func<T> func)
{
- ConstructorInstance<T> instance = new ConstructorInstance<T>(func);
+ var instance = new ConstructorInstance<T>(func);
return Use(instance);
}
public ProfileExpression Use(T t)
{
- LiteralInstance instance = new LiteralInstance(t);
+ var instance = new LiteralInstance(t);
return Use(instance);
}
public ProfileExpression UseConcreteType<CONCRETETYPE>()
{
- ConfiguredInstance instance = new ConfiguredInstance(typeof(CONCRETETYPE));
+ var instance = new ConfiguredInstance(typeof (CONCRETETYPE));
return Use(instance);
}
public ProfileExpression UsePrototypeOf(T template)
{
- PrototypeInstance instance = new PrototypeInstance((ICloneable) template);
+ var instance = new PrototypeInstance((ICloneable) template);
return Use(instance);
}
}
#endregion
-
- public class GenericDefaultExpression
- {
- private readonly ProfileExpression _parent;
- private readonly Type _pluginType;
- private readonly Registry _registry;
-
- internal GenericDefaultExpression(ProfileExpression parent, Type pluginType)
- {
- _parent = parent;
- _registry = parent._registry;
- _pluginType = pluginType;
- }
-
- public ProfileExpression UseConcreteType(Type concreteType)
- {
- ConfiguredInstance instance = new ConfiguredInstance(concreteType);
- return Use(instance);
- }
-
- public ProfileExpression Use(Instance instance)
- {
- _registry.addExpression(graph => graph.SetDefault(_parent._profileName, _pluginType, instance));
-
- return _parent;
- }
-
- public ProfileExpression UseNamedInstance(string name)
- {
- ReferencedInstance instance = new ReferencedInstance(name);
- return Use(instance);
- }
- }
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Configuration/DSL/Registry.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -9,8 +9,8 @@
{
public class Registry
{
- private readonly List<Action> _basicActions = new List<Action>();
private readonly List<Action<PluginGraph>> _actions = new List<Action<PluginGraph>>();
+ private readonly List<Action> _basicActions = new List<Action>();
public Registry()
{
@@ -65,27 +65,9 @@
return new GenericFamilyExpression(pluginType, this);
}
- public class BuildWithExpression<T>
- {
- private SmartInstance<T> _instance;
-
- public BuildWithExpression(SmartInstance<T> instance)
- {
- _instance = instance;
- }
-
- public SmartInstance<T> Configure
- {
- get
- {
- return _instance;
- }
- }
- }
-
public BuildWithExpression<T> ForConcreteType<T>()
{
- var instance = ForRequestedType<T>().TheDefault.Is.OfConcreteType<T>();
+ SmartInstance<T> instance = ForRequestedType<T>().TheDefault.Is.OfConcreteType<T>();
return new BuildWithExpression<T>(instance);
}
@@ -104,7 +86,7 @@
public PluginGraph Build()
{
- PluginGraph graph = new PluginGraph();
+ var graph = new PluginGraph();
ConfigurePluginGraph(graph);
graph.Seal();
@@ -122,13 +104,9 @@
public GenericIsExpression InstanceOf(Type pluginType)
{
- return new GenericIsExpression(instance =>
- {
- _actions.Add(graph =>
- {
- graph.FindFamily(pluginType).AddInstance(instance);
- });
- });
+ return
+ new GenericIsExpression(
+ instance => { _actions.Add(graph => { graph.FindFamily(pluginType).AddInstance(instance); }); });
}
/// <summary>
@@ -138,7 +116,7 @@
/// <returns></returns>
public ProfileExpression CreateProfile(string profileName)
{
- ProfileExpression expression = new ProfileExpression(profileName, this);
+ var expression = new ProfileExpression(profileName, this);
return expression;
}
@@ -165,7 +143,7 @@
public MatchedTypeInterceptor IfTypeMatches(Predicate<Type> match)
{
- MatchedTypeInterceptor interceptor = new MatchedTypeInterceptor(match);
+ var interceptor = new MatchedTypeInterceptor(match);
_actions.Add(graph => graph.InterceptorLibrary.AddInterceptor(interceptor));
return interceptor;
@@ -209,10 +187,27 @@
public CreatePluginFamilyExpression<PLUGINTYPE> FillAllPropertiesOfType<PLUGINTYPE>()
{
- PluginCache.AddFilledType(typeof(PLUGINTYPE));
+ PluginCache.AddFilledType(typeof (PLUGINTYPE));
return ForRequestedType<PLUGINTYPE>();
}
+ #region Nested type: BuildWithExpression
+ public class BuildWithExpression<T>
+ {
+ private readonly SmartInstance<T> _instance;
+
+ public BuildWithExpression(SmartInstance<T> instance)
+ {
+ _instance = instance;
+ }
+
+ public SmartInstance<T> Configure
+ {
+ get { return _instance; }
+ }
+ }
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Configuration/DictionaryReader.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DictionaryReader.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Configuration/DictionaryReader.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -8,57 +8,89 @@
{
public class DictionaryReader : ITypeReader
{
+ #region ITypeReader Members
+
public bool CanProcess(Type pluginType)
{
- if (pluginType.Equals(typeof(NameValueCollection))) return true;
+ if (pluginType.Equals(typeof (NameValueCollection))) return true;
if (!pluginType.IsGenericType) return false;
- var definition = pluginType.GetGenericTypeDefinition();
+ Type definition = pluginType.GetGenericTypeDefinition();
if (definition == null) return false;
return definition.Equals(typeof (IDictionary<,>)) || definition.Equals(typeof (Dictionary<,>));
}
+ public Instance Read(XmlNode node, Type pluginType)
+ {
+ IBuilder builder = findBuilder(pluginType);
+ node.ForEachChild("Pair").Do(
+ element => builder.Read(element.GetAttribute("Key"), element.GetAttribute("Value")));
+
+ return new SerializedInstance(builder.Object);
+ }
+
+ #endregion
+
private static IBuilder findBuilder(Type pluginType)
{
- if (pluginType.Equals(typeof(NameValueCollection))) return new NameValueCollectionBuilder();
+ if (pluginType.Equals(typeof (NameValueCollection))) return new NameValueCollectionBuilder();
- var definition = pluginType.GetGenericTypeDefinition();
- if (definition.Equals(typeof(IDictionary<,>)) || definition.Equals(typeof(Dictionary<,>)))
+ Type definition = pluginType.GetGenericTypeDefinition();
+ if (definition.Equals(typeof (IDictionary<,>)) || definition.Equals(typeof (Dictionary<,>)))
{
- var arguments = pluginType.GetGenericArguments();
- var builderType = typeof (DictionaryBuilder<,>).MakeGenericType(arguments);
+ Type[] arguments = pluginType.GetGenericArguments();
+ Type builderType = typeof (DictionaryBuilder<,>).MakeGenericType(arguments);
return (IBuilder) Activator.CreateInstance(builderType);
}
return null;
}
- public Instance Read(XmlNode node, Type pluginType)
+ #region Nested type: DictionaryBuilder
+
+ internal class DictionaryBuilder<KEY, VALUE> : IBuilder
{
- var builder = findBuilder(pluginType);
- node.ForEachChild("Pair").Do(element => builder.Read(element.GetAttribute("Key"), element.GetAttribute("Value")));
+ private readonly Dictionary<KEY, VALUE> _dictionary = new Dictionary<KEY, VALUE>();
- return new SerializedInstance(builder.Object);
- }
+ #region IBuilder Members
-
+ public void Read(string name, string value)
+ {
+ var key = (KEY) Convert.ChangeType(name, typeof (KEY));
+ var theValue = (VALUE) Convert.ChangeType(value, typeof (VALUE));
+ _dictionary.Add(key, theValue);
+ }
+ public object Object
+ {
+ get { return _dictionary; }
+ }
+ #endregion
+ }
+ #endregion
+ #region Nested type: IBuilder
internal interface IBuilder
{
+ object Object { get; }
void Read(string name, string value);
- object Object { get; }
}
+ #endregion
+
+ #region Nested type: NameValueCollectionBuilder
+
internal class NameValueCollectionBuilder : IBuilder
{
private readonly NameValueCollection _collection = new NameValueCollection();
+ #region IBuilder Members
+
public void Read(string name, string value)
{
_collection.Add(name, value);
@@ -68,24 +100,10 @@
{
get { return _collection; }
}
+
+ #endregion
}
- internal class DictionaryBuilder<KEY, VALUE> : IBuilder
- {
- private Dictionary<KEY, VALUE> _dictionary = new Dictionary<KEY, VALUE>();
-
- public void Read(string name, string value)
- {
- KEY key = (KEY) Convert.ChangeType(name, typeof (KEY));
- VALUE theValue = (VALUE) Convert.ChangeType(value, typeof (VALUE));
-
- _dictionary.Add(key, theValue);
- }
-
- public object Object
- {
- get { return _dictionary; }
- }
- }
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Configuration/FamilyParser.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/FamilyParser.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Configuration/FamilyParser.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -52,7 +52,7 @@
public void ParseDefaultElement(XmlElement element)
{
- TypePath pluginTypePath = new TypePath(element.GetAttribute(PLUGIN_TYPE));
+ var pluginTypePath = new TypePath(element.GetAttribute(PLUGIN_TYPE));
_builder.ConfigureFamily(pluginTypePath, family =>
@@ -67,7 +67,7 @@
public void ParseInstanceElement(XmlElement element)
{
- TypePath pluginTypePath = new TypePath(element.GetAttribute(PLUGIN_TYPE));
+ var pluginTypePath = new TypePath(element.GetAttribute(PLUGIN_TYPE));
_builder.ConfigureFamily(pluginTypePath, family =>
{
@@ -81,10 +81,8 @@
{
InstanceScope returnValue = InstanceScope.PerRequest;
- familyElement.ForAttributeValue(SCOPE, scope =>
- {
- returnValue = (InstanceScope)Enum.Parse(typeof(InstanceScope), scope);
- });
+ familyElement.ForAttributeValue(SCOPE,
+ scope => { returnValue = (InstanceScope) Enum.Parse(typeof (InstanceScope), scope); });
return returnValue;
}
@@ -95,7 +93,8 @@
{
InstanceMemento sourceMemento = new XmlAttributeInstanceMemento(node);
- string context = string.Format("MementoSource for {0}\n{1}", TypePath.GetAssemblyQualifiedName(family.PluginType), node.OuterXml);
+ string context = string.Format("MementoSource for {0}\n{1}",
+ TypePath.GetAssemblyQualifiedName(family.PluginType), node.OuterXml);
_builder.WithSystemObject<MementoSource>(sourceMemento, context,
source => family.AddMementoSource(source));
});
@@ -122,13 +121,14 @@
private void attachInterceptors(PluginFamily family, XmlElement familyElement)
{
- string contextBase = string.Format("creating an InstanceInterceptor for {0}\n", TypePath.GetAssemblyQualifiedName(family.PluginType));
+ string contextBase = string.Format("creating an InstanceInterceptor for {0}\n",
+ TypePath.GetAssemblyQualifiedName(family.PluginType));
familyElement.ForEachChild("*/Interceptor").Do(element =>
{
var interceptorMemento = new XmlAttributeInstanceMemento(element);
string context = contextBase + element.OuterXml;
_builder.WithSystemObject<IBuildInterceptor>(
- interceptorMemento,
+ interceptorMemento,
context,
interceptor => family.AddInterceptor(interceptor));
});
Modified: trunk/Source/StructureMap/Configuration/ITypeReader.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/ITypeReader.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Configuration/ITypeReader.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -1,6 +1,4 @@
-using System;
-using System.Linq;
-using System.Text;
+using System;
using System.Xml;
using StructureMap.Pipeline;
@@ -11,4 +9,4 @@
bool CanProcess(Type pluginType);
Instance Read(XmlNode node, Type pluginType);
}
-}
+}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Configuration/PrimitiveArrayReader.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/PrimitiveArrayReader.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Configuration/PrimitiveArrayReader.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Xml;
using StructureMap.Graph;
using StructureMap.Pipeline;
@@ -19,11 +19,11 @@
Type elementType = pluginType.GetElementType();
char Delimiter = node.GetAttribute("Delimiter", ",").ToCharArray()[0];
- var valueString = node.GetAttribute("Values", string.Empty);
- string[] rawValues = valueString.Split(new[]{Delimiter}, StringSplitOptions.RemoveEmptyEntries);
+ string valueString = node.GetAttribute("Values", string.Empty);
+ string[] rawValues = valueString.Split(new[] {Delimiter}, StringSplitOptions.RemoveEmptyEntries);
- var array = Array.CreateInstance(elementType, rawValues.Length);
+ Array array = Array.CreateInstance(elementType, rawValues.Length);
for (int i = 0; i < rawValues.Length; i++)
{
object convertedType = Convert.ChangeType(rawValues[i].Trim(), elementType);
Modified: trunk/Source/StructureMap/Configuration/ProfileAndMachineParser.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/ProfileAndMachineParser.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Configuration/ProfileAndMachineParser.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -1,4 +1,3 @@
-using System;
using System.Xml;
using StructureMap.Graph;
using StructureMap.Pipeline;
@@ -23,7 +22,8 @@
public void Parse()
{
- _structureMapNode.ForAttributeValue(DEFAULT_PROFILE, profileName => _profileBuilder.SetDefaultProfileName(profileName));
+ _structureMapNode.ForAttributeValue(DEFAULT_PROFILE,
+ profileName => _profileBuilder.SetDefaultProfileName(profileName));
forEachNode(PROFILE_NODE).Do(element =>
{
@@ -31,7 +31,8 @@
_profileBuilder.AddProfile(profileName);
writeOverrides(element,
- (fullName, defaultKey) => _profileBuilder.OverrideProfile(new TypePath(fullName), defaultKey), profileName);
+ (fullName, defaultKey) =>
+ _profileBuilder.OverrideProfile(new TypePath(fullName), defaultKey), profileName);
});
@@ -43,7 +44,8 @@
_profileBuilder.AddMachine(machineName, profileName);
writeOverrides(element,
- (fullName, defaultKey) => _profileBuilder.OverrideMachine(new TypePath(fullName), defaultKey), machineName);
+ (fullName, defaultKey) =>
+ _profileBuilder.OverrideMachine(new TypePath(fullName), defaultKey), machineName);
});
}
@@ -73,7 +75,7 @@
InstanceMemento memento = _creator.CreateMemento(instanceElement);
memento.InstanceKey = key;
- TypePath familyPath = new TypePath(fullName);
+ var familyPath = new TypePath(fullName);
_graphBuilder.ConfigureFamily(familyPath, family =>
{
Modified: trunk/Source/StructureMap/Configuration/ProfileBuilder.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/ProfileBuilder.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Configuration/ProfileBuilder.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -8,16 +8,6 @@
{
private static string _overriden_machine_name;
- public static void OverrideMachineName(string machineName)
- {
- _overriden_machine_name = machineName;
- }
-
- public static void ResetMachineName()
- {
- _overriden_machine_name = string.Empty;
- }
-
private readonly string _machineName;
private readonly PluginGraph _pluginGraph;
private readonly ProfileManager _profileManager;
@@ -49,7 +39,7 @@
{
_pluginGraph.Log.WithType(typePath, "while trying to add an override for a Profile", pluginType =>
{
- ReferencedInstance instance = new ReferencedInstance(instanceKey);
+ var instance = new ReferencedInstance(instanceKey);
_pluginGraph.SetDefault(_lastProfile, pluginType, instance);
});
}
@@ -71,11 +61,11 @@
return;
}
- _pluginGraph.Log.WithType(typePath,
- "trying to configure a Machine Override",
+ _pluginGraph.Log.WithType(typePath,
+ "trying to configure a Machine Override",
pluginType =>
{
- ReferencedInstance instance = new ReferencedInstance(instanceKey);
+ var instance = new ReferencedInstance(instanceKey);
_profileManager.SetMachineDefault(pluginType, instance);
});
}
@@ -87,6 +77,16 @@
#endregion
+ public static void OverrideMachineName(string machineName)
+ {
+ _overriden_machine_name = machineName;
+ }
+
+ public static void ResetMachineName()
+ {
+ _overriden_machine_name = string.Empty;
+ }
+
public static string GetMachineName()
{
if (!string.IsNullOrEmpty(_overriden_machine_name))
Modified: trunk/Source/StructureMap/Configuration/StructureMapConfigurationSection.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/StructureMapConfigurationSection.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Configuration/StructureMapConfigurationSection.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -10,7 +10,7 @@
public object Create(object parent, object configContext, XmlNode section)
{
- IList<XmlNode> allNodes = parent as IList<XmlNode>;
+ var allNodes = parent as IList<XmlNode>;
if (allNodes == null)
{
allNodes = new List<XmlNode>();
@@ -23,7 +23,7 @@
public static IList<XmlNode> GetStructureMapConfiguration()
{
- IList<XmlNode> nodes = ConfigurationSettings.GetConfig(XmlConstants.STRUCTUREMAP) as IList<XmlNode>;
+ var nodes = ConfigurationSettings.GetConfig(XmlConstants.STRUCTUREMAP) as IList<XmlNode>;
if (nodes == null)
{
throw new StructureMapException(105, XmlConstants.STRUCTUREMAP);
Modified: trunk/Source/StructureMap/Configuration/TypeReaderFactory.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/TypeReaderFactory.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Configuration/TypeReaderFactory.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -5,7 +5,7 @@
{
public static class TypeReaderFactory
{
- private static List<ITypeReader> _readers = new List<ITypeReader>();
+ private static readonly List<ITypeReader> _readers = new List<ITypeReader>();
static TypeReaderFactory()
{
@@ -15,7 +15,7 @@
public static ITypeReader GetReader(Type pluginType)
{
- foreach (var reader in _readers)
+ foreach (ITypeReader reader in _readers)
{
if (reader.CanProcess(pluginType))
{
Modified: trunk/Source/StructureMap/Configuration/XmlExtensions.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/XmlExtensions.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Configuration/XmlExtensions.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -7,7 +7,7 @@
{
public static string GetAttribute(this XmlNode node, string attributeName, string defaultValue)
{
- var attribute = node.Attributes.GetNamedItem(attributeName);
+ XmlNode attribute = node.Attributes.GetNamedItem(attributeName);
return attribute == null ? defaultValue : attribute.InnerText;
}
@@ -35,13 +35,15 @@
return new HasXmlElementExpression(node, xpath);
}
+ #region Nested type: HasXmlElementExpression
+
public class HasXmlElementExpression
{
- private XmlElement _element;
+ private readonly XmlElement _element;
internal HasXmlElementExpression(XmlNode parent, string xpath)
{
- _element = (XmlElement)parent.SelectSingleNode(xpath);
+ _element = (XmlElement) parent.SelectSingleNode(xpath);
}
public HasXmlElementExpression Do(Action<XmlElement> action)
@@ -63,10 +65,13 @@
}
}
+ #endregion
+ #region Nested type: XmlNodeExpression
+
public class XmlNodeExpression
{
- private XmlNodeList _list;
+ private readonly XmlNodeList _list;
internal XmlNodeExpression(XmlNode parent, string xpath)
{
@@ -79,11 +84,15 @@
foreach (XmlNode node in _list)
{
- action((XmlElement)node);
+ action((XmlElement) node);
}
}
}
+ #endregion
+
+ #region Nested type: XmlTextExpression
+
public class XmlTextExpression
{
private readonly XmlNodeList _list;
@@ -104,6 +113,6 @@
}
}
-
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Diagnostics/BuildError.cs
===================================================================
--- trunk/Source/StructureMap/Diagnostics/BuildError.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Diagnostics/BuildError.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -1,7 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
-using StructureMap.Graph;
using StructureMap.Pipeline;
namespace StructureMap.Diagnostics
@@ -18,6 +17,7 @@
PluginType = pluginType;
}
+ #region IEquatable<BuildDependency> Members
public bool Equals(BuildDependency buildDependency)
{
@@ -25,6 +25,8 @@
return Equals(Instance, buildDependency.Instance) && Equals(PluginType, buildDependency.PluginType);
}
+ #endregion
+
public override bool Equals(object obj)
{
if (ReferenceEquals(this, obj)) return true;
@@ -33,16 +35,16 @@
public override int GetHashCode()
{
- return (Instance != null ? Instance.GetHashCode() : 0) + 29*(PluginType != null ? PluginType.GetHashCode() : 0);
+ return (Instance != null ? Instance.GetHashCode() : 0) +
+ 29*(PluginType != null ? PluginType.GetHashCode() : 0);
}
}
public class BuildError
{
+ private readonly List<BuildDependency> _dependencies = new List<BuildDependency>();
private readonly Instance _instance;
private readonly Type _pluginType;
- private StructureMapException _exception;
- private readonly List<BuildDependency> _dependencies = new List<BuildDependency>();
public BuildError(Type pluginType, Instance instance)
{
@@ -50,14 +52,6 @@
_pluginType = pluginType;
}
- public void AddDependency(BuildDependency dependency)
- {
- if (!_dependencies.Contains(dependency))
- {
- _dependencies.Add(dependency);
- }
- }
-
public List<BuildDependency> Dependencies
{
get { return _dependencies; }
@@ -73,21 +67,27 @@
get { return _pluginType; }
}
- public StructureMapException Exception
+ public StructureMapException Exception { get; set; }
+
+ public void AddDependency(BuildDependency dependency)
{
- get { return _exception; }
- set { _exception = value; }
+ if (!_dependencies.Contains(dependency))
+ {
+ _dependencies.Add(dependency);
+ }
}
public void Write(StringWriter writer)
{
- string description = ((IDiagnosticInstance)Instance).CreateToken().Description;
+ string description = ((IDiagnosticInstance) Instance).CreateToken().Description;
writer.WriteLine();
- writer.WriteLine("-----------------------------------------------------------------------------------------------------");
- writer.WriteLine("Build Error on Instance '{0}' ({1})\n for PluginType {2}", Instance.Name, description, PluginType.AssemblyQualifiedName);
+ writer.WriteLine(
+ "-----------------------------------------------------------------------------------------------------");
+ writer.WriteLine("Build Error on Instance '{0}' ({1})\n for PluginType {2}", Instance.Name, description,
+ PluginType.AssemblyQualifiedName);
writer.WriteLine();
-
+
if (Exception != null) writer.WriteLine(Exception.ToString());
writer.WriteLine();
}
Modified: trunk/Source/StructureMap/Diagnostics/CharacterWidth.cs
===================================================================
--- trunk/Source/StructureMap/Diagnostics/CharacterWidth.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Diagnostics/CharacterWidth.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -2,9 +2,16 @@
{
internal class CharacterWidth
{
+ private int _width;
+
+ internal int Width
+ {
+ get { return _width; }
+ }
+
internal static CharacterWidth[] For(int count)
{
- CharacterWidth[] widths = new CharacterWidth[count];
+ var widths = new CharacterWidth[count];
for (int i = 0; i < widths.Length; i++)
{
widths[i] = new CharacterWidth();
@@ -13,8 +20,6 @@
return widths;
}
- private int _width = 0;
-
internal void SetWidth(int width)
{
if (width > _width)
@@ -27,13 +32,5 @@
{
_width += add;
}
-
- internal int Width
- {
- get
- {
- return _width;
- }
- }
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Diagnostics/DividerLine.cs
===================================================================
--- trunk/Source/StructureMap/Diagnostics/DividerLine.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Diagnostics/DividerLine.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -10,7 +10,9 @@
{
_character = character;
}
-
+
+ #region Line Members
+
public void OverwriteCounts(CharacterWidth[] widths)
{
// no-op
@@ -23,5 +25,7 @@
writer.Write(string.Empty.PadRight(width.Width, _character));
}
}
+
+ #endregion
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Diagnostics/Doctor.cs
===================================================================
--- trunk/Source/StructureMap/Diagnostics/Doctor.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Diagnostics/Doctor.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -1,37 +1,37 @@
using System;
-using System.Collections.Generic;
-using System.Diagnostics;
using System.IO;
-using System.Text;
namespace StructureMap.Diagnostics
{
public class Doctor
{
+ public Doctor()
+ {
+ BinaryPath = AppDomain.CurrentDomain.BaseDirectory;
+ }
+
public string ConfigFile { get; set; }
public string BootstrapperType { get; set; }
public string BinaryPath { get; set; }
public string OutputFile { get; set; }
- public Doctor()
- {
- BinaryPath = AppDomain.CurrentDomain.BaseDirectory;
- }
-
public DoctorReport RunReport()
{
AppDomain domain = null;
try
{
- var setup = new AppDomainSetup() { ApplicationBase = BinaryPath, ConfigurationFile = ConfigFile };
+ var setup = new AppDomainSetup {ApplicationBase = BinaryPath, ConfigurationFile = ConfigFile};
if (BinaryPath != null) setup.PrivateBinPath = BinaryPath;
domain = AppDomain.CreateDomain("StructureMap-Diagnostics", null, setup);
- var doctor = (DoctorRunner)domain.CreateInstanceAndUnwrap(typeof(DoctorRunner).Assembly.FullName, typeof(DoctorRunner).FullName);
+ var doctor =
+ (DoctorRunner)
+ domain.CreateInstanceAndUnwrap(typeof (DoctorRunner).Assembly.FullName,
+ typeof (DoctorRunner).FullName);
DoctorReport report = doctor.RunReport(BootstrapperType);
writeReport(report);
- writeResults(System.Console.Out, report);
+ writeResults(Console.Out, report);
return report;
}
@@ -48,7 +48,7 @@
return;
}
- using (StreamWriter writer = new StreamWriter(OutputFile))
+ using (var writer = new StreamWriter(OutputFile))
{
writeResults(writer, report);
}
@@ -56,28 +56,32 @@
private void writeResults(TextWriter writer, DoctorReport report)
{
- writer.WriteLine("StructureMap Configuration Report written at " + DateTime.Now.ToString());
- writer.WriteLine("Result: " + report.Result.ToString());
+ writer.WriteLine("StructureMap Configuration Report written at " + DateTime.Now);
+ writer.WriteLine("Result: " + report.Result);
writer.WriteLine();
writer.WriteLine("BootStrapper: " + BootstrapperType);
writer.WriteLine("ConfigFile: " + ConfigFile);
writer.WriteLine("BinaryPath: " + BinaryPath);
- writer.WriteLine("====================================================================================================");
-
+ writer.WriteLine(
+ "====================================================================================================");
+
writer.WriteLine();
writer.WriteLine();
if (!string.IsNullOrEmpty(report.ErrorMessages))
{
- writer.WriteLine("====================================================================================================");
- writer.WriteLine("= Error Messages =");
- writer.WriteLine("====================================================================================================");
+ writer.WriteLine(
+ "====================================================================================================");
+ writer.WriteLine(
+ "= Error Messages =");
+ writer.WriteLine(
+ "====================================================================================================");
writer.WriteLine(report.ErrorMessages);
writer.WriteLine();
writer.WriteLine();
}
- if (!string.IsNullOrEmpty(report.WhatDoIHave))
+ if (!string.IsNullOrEmpty(report.WhatDoIHave))
{
writer.WriteLine(report.WhatDoIHave);
writer.WriteLine();
@@ -85,4 +89,4 @@
}
}
}
-}
+}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Diagnostics/DoctorReport.cs
===================================================================
--- trunk/Source/StructureMap/Diagnostics/DoctorReport.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Diagnostics/DoctorReport.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -5,8 +5,8 @@
[Serializable]
public class DoctorReport
{
+ public string ErrorMessages;
+ public DoctorResult Result;
public string WhatDoIHave = string.Empty;
- public DoctorResult Result;
- public string ErrorMessages;
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Diagnostics/DoctorRunner.cs
===================================================================
--- trunk/Source/StructureMap/Diagnostics/DoctorRunner.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Diagnostics/DoctorRunner.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -64,8 +64,6 @@
return report;
}
-
-
}
private void writeConfigurationAndValidate(DoctorReport report, PluginGraph graph)
Modified: trunk/Source/StructureMap/Diagnostics/Error.cs
===================================================================
--- trunk/Source/StructureMap/Diagnostics/Error.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Diagnostics/Error.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -1,6 +1,5 @@
using System;
using System.IO;
-using System.Resources;
namespace StructureMap.Diagnostics
{
@@ -28,7 +27,7 @@
public Error(int errorCode, Exception ex, params object[] args) : this(errorCode, args)
{
_message += "\n\n" + ex.Message;
-
+
writeStackTrace(ex);
}
@@ -41,19 +40,7 @@
writeStackTrace(exception);
}
- private void writeStackTrace(Exception exception)
- {
- _stackTrace = string.Empty;
- Exception ex = exception;
- while (ex != null)
- {
- _stackTrace += exception.ToString();
- _stackTrace += "\n\n";
- ex = ex.InnerException;
- }
- }
-
public int Code
{
get { return _code; }
@@ -73,6 +60,17 @@
#endregion
+ private void writeStackTrace(Exception exception)
+ {
+ _stackTrace = string.Empty;
+ Exception ex = exception;
+ while (ex != null)
+ {
+ _stackTrace += exception.ToString();
+ _stackTrace += "\n\n";
+ ex = ex.InnerException;
+ }
+ }
public override bool Equals(object obj)
{
@@ -105,9 +103,9 @@
writer.WriteLine("Error: " + Code);
if (Instance != null) writer.WriteLine(Instance.ToString());
writer.WriteLine("Source: " + Source);
-
+
if (!string.IsNullOrEmpty(_message)) writer.WriteLine(_message);
- if (!string.IsNullOrEmpty(_stackTrace)) writer.WriteLine(_stackTrace);
+ if (!string.IsNullOrEmpty(_stackTrace)) writer.WriteLine(_stackTrace);
}
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Diagnostics/ErrorCollection.cs
===================================================================
--- trunk/Source/StructureMap/Diagnostics/ErrorCollection.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Diagnostics/ErrorCollection.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -6,14 +6,25 @@
{
public class ErrorCollection
{
+ private readonly List<Instance> _brokenInstances = new List<Instance>();
private readonly Dictionary<Instance, BuildError> _buildErrors = new Dictionary<Instance, BuildError>();
- private readonly List<Instance> _brokenInstances = new List<Instance>();
+ public BuildError[] BuildErrors
+ {
+ get
+ {
+ var errors = new BuildError[_buildErrors.Count];
+ _buildErrors.Values.CopyTo(errors, 0);
+ return errors;
+ }
+ }
+
+
public void LogError(
- Instance instance,
- Type pluginType,
- StructureMapException ex,
+ Instance instance,
+ Type pluginType,
+ StructureMapException ex,
IEnumerable<BuildDependency> dependencies)
{
if (_buildErrors.ContainsKey(instance))
@@ -27,8 +38,8 @@
return;
}
- InstanceToken token = ((IDiagnosticInstance)instance).CreateToken();
- BuildError error = new BuildError(pluginType, instance);
+ InstanceToken token = ((IDiagnosticInstance) instance).CreateToken();
+ var error = new BuildError(pluginType, instance);
error.Exception = ex;
_buildErrors.Add(instance, error);
@@ -36,7 +47,8 @@
addDependenciesToError(instance, dependencies, error);
}
- private void addDependenciesToError(Instance instance, IEnumerable<BuildDependency> dependencies, BuildError error)
+ private void addDependenciesToError(Instance instance, IEnumerable<BuildDependency> dependencies,
+ BuildError error)
{
foreach (BuildDependency dependency in dependencies)
{
@@ -50,20 +62,9 @@
}
}
- public BuildError[] BuildErrors
- {
- get
- {
- BuildError[] errors = new BuildError[_buildErrors.Count];
- _buildErrors.Values.CopyTo(errors, 0);
-
- return errors;
- }
- }
-
public BuildError Find(Type pluginType, string name)
{
- foreach (KeyValuePair<Instance, BuildError> pair in _buildErrors)
+ foreach (var pair in _buildErrors)
{
BuildError error = pair.Value;
if (error.PluginType == pluginType && error.Instance.Name == name)
@@ -82,6 +83,5 @@
action(pair.Value);
}
}
-
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Diagnostics/GraphLog.cs
===================================================================
--- trunk/Source/StructureMap/Diagnostics/GraphLog.cs 2008-10-05 02:35:54 UTC (rev 170)
+++ trunk/Source/StructureMap/Diagnostics/GraphLog.cs 2008-10-05 02:43:34 UTC (rev 171)
@@ -1,5 +1,4 @@
using System;
-using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
@@ -11,9 +10,9 @@
{
public class GraphLog
{
+ private readonly List<Error> _errors = new List<Error>();
+ private readonly List<string...
[truncated message content] |