|
From: <jer...@us...> - 2008-06-15 01:49:36
|
Revision: 121
http://structuremap.svn.sourceforge.net/structuremap/?rev=121&view=rev
Author: jeremydmiller
Date: 2008-06-14 18:49:31 -0700 (Sat, 14 Jun 2008)
Log Message:
-----------
VS2008 cutover
Modified Paths:
--------------
trunk/Source/CommonAssemblyInfo.cs
trunk/Source/StructureMap/BuildSession.cs
trunk/Source/StructureMap/Configuration/ConfigurationParser.cs
trunk/Source/StructureMap/Configuration/ConfigurationParserBuilder.cs
trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs
trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs
trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs
trunk/Source/StructureMap/Configuration/DSL/Expressions/ScanAssembliesExpression.cs
trunk/Source/StructureMap/Configuration/DSL/Registry.cs
trunk/Source/StructureMap/Configuration/DSL/RegistryExpressions.cs
trunk/Source/StructureMap/Configuration/FamilyParser.cs
trunk/Source/StructureMap/Configuration/ProfileAndMachineParser.cs
trunk/Source/StructureMap/Configuration/ProfileBuilder.cs
trunk/Source/StructureMap/Configuration/XmlConstants.cs
trunk/Source/StructureMap/Diagnostics/BuildError.cs
trunk/Source/StructureMap/Diagnostics/Doctor.cs
trunk/Source/StructureMap/Diagnostics/ErrorCollection.cs
trunk/Source/StructureMap/Diagnostics/ValidationBuildSession.cs
trunk/Source/StructureMap/Emitting/InstanceBuilderAssembly.cs
trunk/Source/StructureMap/Graph/AssemblyScanner.cs
trunk/Source/StructureMap/Graph/GenericsPluginGraph.cs
trunk/Source/StructureMap/Graph/ITypeScanner.cs
trunk/Source/StructureMap/Graph/PluginCollection.cs
trunk/Source/StructureMap/Graph/PluginFamily.cs
trunk/Source/StructureMap/InstanceFactory.cs
trunk/Source/StructureMap/InstanceMemento.cs
trunk/Source/StructureMap/Interceptors/InterceptorLibrary.cs
trunk/Source/StructureMap/PipelineGraph.cs
trunk/Source/StructureMap/PluginGraphBuilder.cs
trunk/Source/StructureMap/Source/XmlMementoCreator.cs
trunk/Source/StructureMap/StructureMap.csproj
trunk/Source/StructureMap/StructureMapConfiguration.cs
trunk/Source/StructureMap/Util/Cache.cs
trunk/Source/StructureMap.AutoMocking/StructureMap.AutoMocking.csproj
trunk/Source/StructureMap.DataAccess/StructureMap.DataAccess.csproj
trunk/Source/StructureMap.DeploymentTasks/StructureMap.DeploymentTasks.csproj
trunk/Source/StructureMap.Testing/BuildSessionTester.cs
trunk/Source/StructureMap.Testing/Configuration/ConfigurationParserBuilderTester.cs
trunk/Source/StructureMap.Testing/Configuration/DSL/AddInstanceTester.cs
trunk/Source/StructureMap.Testing/Configuration/DSL/AddTypesTester.cs
trunk/Source/StructureMap.Testing/Configuration/DSL/ConstructorExpressionTester.cs
trunk/Source/StructureMap.Testing/Configuration/DSL/CreatePluginFamilyTester.cs
trunk/Source/StructureMap.Testing/Configuration/DSL/DeepInstanceTester.cs
trunk/Source/StructureMap.Testing/Configuration/DSL/GenericFamilyExpressionTester.cs
trunk/Source/StructureMap.Testing/Configuration/DSL/InjectArrayTester.cs
trunk/Source/StructureMap.Testing/Configuration/DSL/InterceptAllInstancesOfPluginTypeTester.cs
trunk/Source/StructureMap.Testing/Configuration/DSL/InterceptorTesting.cs
trunk/Source/StructureMap.Testing/Configuration/DSL/ProfileExpressionTester.cs
trunk/Source/StructureMap.Testing/Configuration/DSL/RegistryIntegratedTester.cs
trunk/Source/StructureMap.Testing/Configuration/FamilyParserTester.cs
trunk/Source/StructureMap.Testing/Configuration/NormalGraphBuilderTester.cs
trunk/Source/StructureMap.Testing/Diagnostics/ValidationBuildSessionTester.cs
trunk/Source/StructureMap.Testing/GenericsAcceptanceTester.cs
trunk/Source/StructureMap.Testing/Graph/ContainerTester.cs
trunk/Source/StructureMap.Testing/Graph/DefaultConventionScanningTester.cs
trunk/Source/StructureMap.Testing/Graph/DynamicInjectionTester.cs
trunk/Source/StructureMap.Testing/Graph/EnumerationTester.cs
trunk/Source/StructureMap.Testing/Graph/ExceptionHandling/StructureMapExceptionTester.cs
trunk/Source/StructureMap.Testing/Graph/ExplicitArgumentTester.cs
trunk/Source/StructureMap.Testing/Graph/FullStackFacadeTester.cs
trunk/Source/StructureMap.Testing/Graph/InstanceFactoryTester.cs
trunk/Source/StructureMap.Testing/Graph/Interceptors/TypeInterceptionTester.cs
trunk/Source/StructureMap.Testing/Graph/PluginFamilyTester.cs
trunk/Source/StructureMap.Testing/Graph/PluginGraphBuilderTester.cs
trunk/Source/StructureMap.Testing/Graph/TypeFindingTester.cs
trunk/Source/StructureMap.Testing/Pipeline/ProfileTester.cs
trunk/Source/StructureMap.Testing/PipelineGraphTester.cs
trunk/Source/StructureMap.Testing/StructureMap.Testing.csproj
trunk/Source/StructureMap.Testing/TestUtility.cs
trunk/Source/StructureMap.Testing.GenericWidgets/StructureMap.Testing.GenericWidgets.csproj
trunk/Source/StructureMap.Testing.Widget/StructureMap.Testing.Widget.csproj
trunk/Source/StructureMap.Testing.Widget2/StructureMap.Testing.Widget2.csproj
trunk/Source/StructureMap.Testing.Widget3/StructureMap.Testing.Widget3.csproj
trunk/Source/StructureMap.Testing.Widget4/StructureMap.Testing.Widget4.csproj
trunk/Source/StructureMap.Testing.Widget5/StructureMap.Testing.Widget5.csproj
trunk/Source/StructureMap.sln
Added Paths:
-----------
trunk/Source/StructureMap/Configuration/XmlExtensions.cs
trunk/Source/StructureMap/Diagnostics/DoctorReport.cs
trunk/Source/StructureMap/Diagnostics/DoctorResult.cs
trunk/Source/StructureMap/Diagnostics/DoctorRunner.cs
trunk/Source/StructureMap/Diagnostics/ValidationError.cs
trunk/Source/StructureMap/Pipeline/SerializedInstance.cs
trunk/Source/StructureMap.AutoMocking/StructureMap.AutoMocking.csproj.user
trunk/Source/StructureMap.Testing/Diagnostics/DoctorTester.cs
trunk/Source/StructureMap.Testing/Diagnostics/WriterExtensions.cs
trunk/Source/StructureMap.Testing/Pipeline/SerializedInstanceTester.cs
trunk/Source/StructureMap.Testing/SpecificationExtensions.cs
trunk/Source/StructureMap.lnk
trunk/Source/StructureMapDoctor/
trunk/Source/StructureMapDoctor/Program.cs
trunk/Source/StructureMapDoctor/Properties/
trunk/Source/StructureMapDoctor/Properties/AssemblyInfo.cs
trunk/Source/StructureMapDoctor/StructureMapDoctor.csproj
Modified: trunk/Source/CommonAssemblyInfo.cs
===================================================================
--- trunk/Source/CommonAssemblyInfo.cs 2008-06-07 22:48:46 UTC (rev 120)
+++ trunk/Source/CommonAssemblyInfo.cs 2008-06-15 01:49:31 UTC (rev 121)
@@ -5,7 +5,7 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
-// Runtime Version:2.0.50727.1433
+// Runtime Version:2.0.50727.1434
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
Modified: trunk/Source/StructureMap/BuildSession.cs
===================================================================
--- trunk/Source/StructureMap/BuildSession.cs 2008-06-07 22:48:46 UTC (rev 120)
+++ trunk/Source/StructureMap/BuildSession.cs 2008-06-15 01:49:31 UTC (rev 121)
@@ -72,7 +72,6 @@
}
else
{
- // TODO: 3.5, move this to an extension method of Array?
array = Array.CreateInstance(pluginType, instances.Length);
for (int i = 0; i < instances.Length; i++)
{
Modified: trunk/Source/StructureMap/Configuration/ConfigurationParser.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/ConfigurationParser.cs 2008-06-07 22:48:46 UTC (rev 120)
+++ trunk/Source/StructureMap/Configuration/ConfigurationParser.cs 2008-06-15 01:49:31 UTC (rev 121)
@@ -1,5 +1,4 @@
using System;
-using System.Collections.Generic;
using System.IO;
using System.Xml;
using StructureMap.Diagnostics;
@@ -8,89 +7,50 @@
namespace StructureMap.Configuration
{
- public class ConfigurationParser
+ public class ConfigurationParser : XmlConstants
{
#region statics
public static ConfigurationParser FromFile(string filename)
{
- XmlDocument document = new XmlDocument();
+ var document = new XmlDocument();
document.Load(filename);
- XmlNode structureMapNode = document.SelectSingleNode("//" + XmlConstants.STRUCTUREMAP);
+ XmlNode structureMapNode = document.SelectSingleNode("//" + STRUCTUREMAP);
if (structureMapNode == null)
{
throw new StructureMapException(155, filename);
}
- ConfigurationParser parser = new ConfigurationParser(structureMapNode);
+ var parser = new ConfigurationParser(structureMapNode);
parser.FilePath = filename;
-
+
return parser;
}
#endregion
- public string Description = string.Empty;
-
private readonly XmlMementoCreator _mementoCreator;
private readonly XmlNode _structureMapNode;
private string _filePath = string.Empty;
+ public string Description = string.Empty;
public ConfigurationParser(XmlNode structureMapNode)
{
_structureMapNode = structureMapNode;
- // TODO: 3.5 cleanup with extension method
XmlMementoStyle mementoStyle = XmlMementoStyle.NodeNormalized;
-
-
- XmlAttribute att = _structureMapNode.Attributes[XmlConstants.MEMENTO_STYLE];
- if (att != null)
+ _structureMapNode.ForAttributeValue(MEMENTO_STYLE, style =>
{
- if (att.Value == XmlConstants.ATTRIBUTE_STYLE)
- {
- mementoStyle = XmlMementoStyle.AttributeNormalized;
- }
- }
+ if (style == ATTRIBUTE_STYLE) mementoStyle = XmlMementoStyle.AttributeNormalized;
+ });
-
_mementoCreator = new XmlMementoCreator(
mementoStyle,
- XmlConstants.TYPE_ATTRIBUTE,
- XmlConstants.KEY_ATTRIBUTE);
+ TYPE_ATTRIBUTE,
+ KEY_ATTRIBUTE);
}
- public void ForEachFile(GraphLog log, Action<string> action)
- {
- // TODO: Clean up with 3.5
- string includePath = getIncludePath();
- XmlNodeList includeNodes = _structureMapNode.SelectNodes(XmlConstants.INCLUDE_NODE);
- foreach (XmlElement includeElement in includeNodes)
- {
- string fileName = includeElement.GetAttribute("File");
- if (string.IsNullOrEmpty(fileName))
- {
- log.RegisterError(156, _filePath);
- }
- else
- {
- string includedFile = Path.Combine(includePath, fileName);
- action(includedFile);
- }
- }
- }
-
- private string getIncludePath()
- {
- if (string.IsNullOrEmpty(_filePath))
- {
- return string.Empty;
- }
-
- return Path.GetDirectoryName(_filePath);
- }
-
public string Id
{
get
@@ -107,83 +67,53 @@
set { _filePath = value; }
}
- public void ParseAssemblies(IGraphBuilder builder)
+ public void ForEachFile(GraphLog log, Action<string> action)
{
- parseAssemblies(builder);
- }
-
-
- public void ParseInstances(IGraphBuilder builder)
- {
- XmlNodeList familyNodes = findNodes(XmlConstants.PLUGIN_FAMILY_NODE);
- foreach (XmlElement familyElement in familyNodes)
+ string includePath = getIncludePath();
+ _structureMapNode.ForTextInChild("Include/@File").Do(fileName =>
{
- TypePath typePath = TypePath.CreateFromXmlNode(familyElement);
-
- builder.ConfigureFamily(typePath,
- delegate(PluginFamily family) { attachInstances(family, familyElement, builder); });
- }
+ string includedFile = Path.Combine(includePath, fileName);
+ action(includedFile);
+ });
}
- private void parseAssemblies(IGraphBuilder builder)
+ private string getIncludePath()
{
- XmlNodeList assemblyNodes = findNodes(XmlConstants.ASSEMBLY);
- foreach (XmlNode assemblyNode in assemblyNodes)
+ if (string.IsNullOrEmpty(_filePath))
{
- string assemblyName = assemblyNode.Attributes[XmlConstants.NAME].Value;
-
- builder.AddAssembly(assemblyName);
+ return string.Empty;
}
- }
- private XmlNodeList findNodes(string nodeName)
- {
- return _structureMapNode.SelectNodes(nodeName);
+ return Path.GetDirectoryName(_filePath);
}
-
- public void ParseFamilies(IGraphBuilder builder)
+ public void ParseAssemblies(IGraphBuilder builder)
{
- FamilyParser familyParser = new FamilyParser(builder, _mementoCreator);
-
- XmlNodeList familyNodes = findNodes(XmlConstants.PLUGIN_FAMILY_NODE);
- foreach (XmlElement familyElement in familyNodes)
- {
- familyParser.ParseFamily(familyElement);
- }
-
- XmlNodeList defaultNodes = findNodes(XmlConstants.DEFAULT_INSTANCE);
- foreach (XmlElement element in defaultNodes)
- {
- familyParser.ParseDefaultElement(element);
- }
-
- XmlNodeList instanceNodes = findNodes(XmlConstants.ADD_INSTANCE_NODE);
- foreach (XmlElement element in instanceNodes)
- {
- familyParser.ParseInstanceElement(element);
- }
+ _structureMapNode.ForTextInChild("Assembly/@Name").Do(name => builder.AddAssembly(name));
}
- private void attachInstances(PluginFamily family, XmlElement familyElement, IGraphBuilder builder)
+ private XmlExtensions.XmlNodeExpression forEachNode(string xpath)
{
- foreach (XmlNode instanceNode in familyElement.ChildNodes)
- {
- if (instanceNode.Name != XmlConstants.INSTANCE_NODE)
- {
- continue;
- }
-
- InstanceMemento memento = _mementoCreator.CreateMemento(instanceNode);
- family.AddInstance(memento);
- }
+ return _structureMapNode.ForEachChild(xpath);
}
public void ParseProfilesAndMachines(IGraphBuilder builder)
{
- ProfileAndMachineParser parser = new ProfileAndMachineParser(builder, _structureMapNode, _mementoCreator);
+ var parser = new ProfileAndMachineParser(builder, _structureMapNode, _mementoCreator);
parser.Parse();
}
+
+ public void Parse(IGraphBuilder builder)
+ {
+ var familyParser = new FamilyParser(builder, _mementoCreator);
+
+ forEachNode(PLUGIN_FAMILY_NODE).Do(familyParser.ParseFamily);
+ forEachNode(DEFAULT_INSTANCE).Do(familyParser.ParseDefaultElement);
+ forEachNode(ADD_INSTANCE_NODE).Do(familyParser.ParseInstanceElement);
+
+ ParseProfilesAndMachines(builder);
+ }
+
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Configuration/ConfigurationParserBuilder.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/ConfigurationParserBuilder.cs 2008-06-07 22:48:46 UTC (rev 120)
+++ trunk/Source/StructureMap/Configuration/ConfigurationParserBuilder.cs 2008-06-15 01:49:31 UTC (rev 121)
@@ -8,11 +8,11 @@
public class ConfigurationParserBuilder
{
private readonly GraphLog _log;
+ private readonly List<string> _otherFiles = new List<string>();
private readonly List<ConfigurationParser> _parsers = new List<ConfigurationParser>();
- private readonly List<string> _otherFiles = new List<string>();
- private bool _ignoreDefaultFile = false;
+ private bool _ignoreDefaultFile;
private bool _pullConfigurationFromAppConfig;
- private bool _useAndEnforceExistenceOfDefaultFile = false;
+ private bool _useAndEnforceExistenceOfDefaultFile;
public ConfigurationParserBuilder(GraphLog log)
@@ -39,35 +39,39 @@
set { _pullConfigurationFromAppConfig = value; }
}
- // TODO: Clean up with 3.5
public ConfigurationParser[] GetParsers()
{
- List<ConfigurationParser> list = new List<ConfigurationParser>();
+ var list = new List<ConfigurationParser>();
- // Pick up the configuration in the default StructureMap.config
- string pathToStructureMapConfig = StructureMapConfiguration.GetStructureMapConfigurationPath();
- if (shouldUseStructureMapConfigFileAt(pathToStructureMapConfig))
- {
- _log.Try(delegate()
- {
- ConfigurationParser parser = ConfigurationParser.FromFile(pathToStructureMapConfig);
- list.Add(parser);
- }).AndReportErrorAs(100, pathToStructureMapConfig);
- }
+ addConfigurationFromStructureMapConfig(list);
+ addConfigurationFromExplicitlyAddedFiles(list);
+ addConfigurationFromApplicationConfigFile();
- foreach (string filename in _otherFiles)
+ list.AddRange(_parsers);
+
+ addConfigurationFromIncludeNodes(list);
+
+ return list.ToArray();
+ }
+
+ private void addConfigurationFromIncludeNodes(List<ConfigurationParser> list)
+ {
+ foreach (ConfigurationParser parser in list.ToArray())
{
- _log.Try(delegate()
- {
- ConfigurationParser parser = ConfigurationParser.FromFile(filename);
- parser.Description = filename;
- list.Add(parser);
- }).AndReportErrorAs(160, filename);
+ parser.ForEachFile(_log,
+ filename => _log.Try(() =>
+ {
+ ConfigurationParser childParser = ConfigurationParser.FromFile(filename);
+ list.Add(childParser);
+ }).AndReportErrorAs(150, filename));
}
+ }
+ private void addConfigurationFromApplicationConfigFile()
+ {
if (_pullConfigurationFromAppConfig)
{
- _log.Try(delegate()
+ _log.Try(() =>
{
IList<XmlNode> appConfigNodes = StructureMapConfigurationSection.GetStructureMapConfiguration();
foreach (XmlNode appConfigNode in appConfigNodes)
@@ -76,24 +80,33 @@
}
}).AndLogAnyErrors();
}
+ }
- list.AddRange(_parsers);
+ private void addConfigurationFromExplicitlyAddedFiles(List<ConfigurationParser> list)
+ {
+ foreach (string filename in _otherFiles)
+ {
+ _log.Try(() =>
+ {
+ ConfigurationParser parser = ConfigurationParser.FromFile(filename);
+ parser.Description = filename;
+ list.Add(parser);
+ }).AndReportErrorAs(160, filename);
+ }
+ }
- foreach (ConfigurationParser parser in list.ToArray())
+ private void addConfigurationFromStructureMapConfig(List<ConfigurationParser> list)
+ {
+// Pick up the configuration in the default StructureMap.config
+ string pathToStructureMapConfig = StructureMapConfiguration.GetStructureMapConfigurationPath();
+ if (shouldUseStructureMapConfigFileAt(pathToStructureMapConfig))
{
- parser.ForEachFile(_log,
- delegate(string filename)
- {
- _log.Try(delegate()
- {
- ConfigurationParser childParser = ConfigurationParser.FromFile(filename);
- list.Add(childParser);
- }).AndReportErrorAs(150, filename);
- });
+ _log.Try(() =>
+ {
+ ConfigurationParser parser = ConfigurationParser.FromFile(pathToStructureMapConfig);
+ list.Add(parser);
+ }).AndReportErrorAs(100, pathToStructureMapConfig);
}
-
-
- return list.ToArray();
}
private bool shouldUseStructureMapConfigFileAt(string pathToStructureMapConfig)
@@ -112,7 +125,7 @@
public void IncludeNode(XmlNode node, string description)
{
- ConfigurationParser parser = new ConfigurationParser(node);
+ var parser = new ConfigurationParser(node);
parser.Description = description;
_parsers.Add(parser);
@@ -120,7 +133,7 @@
public static ConfigurationParser[] GetParsers(XmlNode node, GraphLog log)
{
- ConfigurationParserBuilder builder = new ConfigurationParserBuilder(log);
+ var builder = new ConfigurationParserBuilder(log);
builder.IncludeNode(node, string.Empty);
builder.IgnoreDefaultFile = true;
Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2008-06-07 22:48:46 UTC (rev 120)
+++ trunk/Source/StructureMap/Configuration/DSL/Expressions/CreatePluginFamilyExpression.cs 2008-06-15 01:49:31 UTC (rev 121)
@@ -21,20 +21,19 @@
{
_pluginType = typeof (PLUGINTYPE);
- registry.addExpression(delegate(PluginGraph graph)
+ registry.addExpression(graph =>
{
PluginFamily family = graph.FindFamily(_pluginType);
family.SetScopeTo(_scope);
- // TODO: clean up with 3.5
- _children.ForEach(delegate(Action<PluginGraph> action) { action(graph); });
- _alterations.ForEach(delegate(Action<PluginFamily> action) { action(family); });
+ _children.ForEach(action => action(graph));
+ _alterations.ForEach(action => action(family));
});
}
public CreatePluginFamilyExpression<PLUGINTYPE> AddInstances(params Instance[] instances)
{
- return alterAndContinue(delegate(PluginFamily family)
+ return alterAndContinue(family =>
{
foreach (Instance instance in instances)
{
@@ -44,7 +43,6 @@
}
- // TODO: 3.5, Try alterAndContinue(f => {});
private CreatePluginFamilyExpression<PLUGINTYPE> alterAndContinue(Action<PluginFamily> action)
{
_alterations.Add(action);
@@ -58,7 +56,7 @@
/// <returns></returns>
public CreatePluginFamilyExpression<PLUGINTYPE> TheDefaultIs(Instance instance)
{
- return alterAndContinue(delegate(PluginFamily family)
+ return alterAndContinue(family =>
{
family.AddInstance(instance);
family.DefaultInstanceKey = instance.Name;
@@ -67,8 +65,7 @@
public CreatePluginFamilyExpression<PLUGINTYPE> AddInstance(Instance instance)
{
- return alterAndContinue(
- delegate(PluginFamily family) { family.AddInstance(instance); });
+ return alterAndContinue(family => family.AddInstance(instance));
}
/// <summary>
@@ -83,7 +80,7 @@
{
ExpressionValidator.ValidatePluggabilityOf(typeof (CONCRETETYPE)).IntoPluginType(_pluginType);
- return alterAndContinue(delegate(PluginFamily family)
+ return alterAndContinue(family =>
{
Plugin plugin = family.Plugins.FindOrCreate(typeof (CONCRETETYPE), true);
family.DefaultInstanceKey = plugin.ConcreteKey;
@@ -100,7 +97,7 @@
/// <returns></returns>
public CreatePluginFamilyExpression<PLUGINTYPE> CacheBy(InstanceScope scope)
{
- return alterAndContinue(delegate(PluginFamily family) { family.SetScopeTo(scope); });
+ return alterAndContinue(family => family.SetScopeTo(scope));
}
/// <summary>
@@ -109,8 +106,7 @@
/// <returns></returns>
public CreatePluginFamilyExpression<PLUGINTYPE> AsSingletons()
{
- _alterations.Add(
- delegate(PluginFamily family) { family.SetScopeTo(InstanceScope.Singleton); });
+ _alterations.Add(family => family.SetScopeTo(InstanceScope.Singleton));
return this;
}
@@ -118,9 +114,9 @@
public CreatePluginFamilyExpression<PLUGINTYPE> OnCreation(Action<PLUGINTYPE> handler)
{
_children.Add(
- delegate(PluginGraph graph)
+ graph =>
{
- Func<object, object> function = delegate(object target)
+ Func<object, object> function = target =>
{
handler((PLUGINTYPE) target);
return target;
@@ -136,9 +132,9 @@
public CreatePluginFamilyExpression<PLUGINTYPE> EnrichWith(EnrichmentHandler<PLUGINTYPE> handler)
{
_children.Add(
- delegate(PluginGraph graph)
+ graph =>
{
- Func<object, object> function = delegate(object target) { return handler((PLUGINTYPE) target); };
+ Func<object, object> function = target => handler((PLUGINTYPE) target);
PluginTypeInterceptor interceptor = new PluginTypeInterceptor(typeof (PLUGINTYPE), function);
graph.InterceptorLibrary.AddInterceptor(interceptor);
@@ -157,7 +153,7 @@
ExpressionValidator.ValidatePluggabilityOf(typeof (CONCRETETYPE)).IntoPluginType(typeof (PLUGINTYPE));
_alterations.Add(
- delegate(PluginFamily family)
+ family =>
{
Plugin plugin = new Plugin(typeof (CONCRETETYPE));
plugin.ConcreteKey = instanceName;
@@ -170,13 +166,13 @@
public CreatePluginFamilyExpression<PLUGINTYPE> InterceptConstructionWith(IBuildInterceptor interceptor)
{
- _alterations.Add(delegate(PluginFamily family) { family.AddInterceptor(interceptor); });
+ _alterations.Add(family => family.AddInterceptor(interceptor));
return this;
}
public CreatePluginFamilyExpression<PLUGINTYPE> AddInstancesFrom(MementoSource source)
{
- _alterations.Add(delegate(PluginFamily family) { family.AddMementoSource(source); });
+ _alterations.Add(family => family.AddMementoSource(source));
return this;
}
@@ -185,7 +181,7 @@
{
ExpressionValidator.ValidatePluggabilityOf(typeof (PLUGGEDTYPE)).IntoPluginType(typeof (PLUGINTYPE));
- _alterations.Add(delegate(PluginFamily family) { family.AddPlugin(typeof (PLUGGEDTYPE), concreteKey); });
+ _alterations.Add(family => family.AddPlugin(typeof (PLUGGEDTYPE), concreteKey));
return this;
}
@@ -197,7 +193,7 @@
public CreatePluginFamilyExpression<PLUGINTYPE> TheDefaultIs(Func<PLUGINTYPE> func)
{
- ConstructorInstance instance = new ConstructorInstance(delegate() { return func(); });
+ ConstructorInstance instance = new ConstructorInstance(() => func());
return TheDefaultIs(instance);
}
@@ -209,7 +205,7 @@
public CreatePluginFamilyExpression<PLUGINTYPE> AddInstance(Func<PLUGINTYPE> func)
{
- ConstructorInstance instance = new ConstructorInstance(delegate(){ return func();});
+ ConstructorInstance instance = new ConstructorInstance(() => func());
return AddInstance(instance);
}
Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs 2008-06-07 22:48:46 UTC (rev 120)
+++ trunk/Source/StructureMap/Configuration/DSL/Expressions/GenericFamilyExpression.cs 2008-06-15 01:49:31 UTC (rev 121)
@@ -19,7 +19,7 @@
private GenericFamilyExpression alterAndContinue(Action<PluginFamily> action)
{
- _registry.addExpression(delegate(PluginGraph graph)
+ _registry.addExpression(graph =>
{
PluginFamily family = graph.FindFamily(_pluginType);
action(family);
@@ -36,7 +36,7 @@
public GenericFamilyExpression TheDefaultIs(Instance instance)
{
- return alterAndContinue(delegate(PluginFamily family)
+ return alterAndContinue(family =>
{
family.AddInstance(instance);
family.DefaultInstanceKey = instance.Name;
@@ -51,17 +51,17 @@
public GenericFamilyExpression AddInstance(Instance instance)
{
- return alterAndContinue(delegate(PluginFamily family) { family.AddInstance(instance); });
+ return alterAndContinue(family => family.AddInstance(instance));
}
public GenericFamilyExpression CacheBy(InstanceScope scope)
{
- return alterAndContinue(delegate(PluginFamily family) { family.SetScopeTo(scope); });
+ return alterAndContinue(family => family.SetScopeTo(scope));
}
public GenericFamilyExpression OnCreation(Action<object> action)
{
- Func<object, object> func = delegate(object raw)
+ Func<object, object> func = raw =>
{
action(raw);
return raw;
@@ -71,7 +71,7 @@
public GenericFamilyExpression EnrichWith(Func<object, object> func)
{
- _registry.addExpression(delegate(PluginGraph graph)
+ _registry.addExpression(graph =>
{
PluginTypeInterceptor interceptor = new PluginTypeInterceptor(_pluginType, func);
graph.InterceptorLibrary.AddInterceptor(interceptor);
@@ -83,10 +83,7 @@
public GenericFamilyExpression InterceptConstructionWith(IBuildInterceptor interceptor)
{
- return alterAndContinue(delegate(PluginFamily family)
- {
- family.AddInterceptor(interceptor);
- });
+ return alterAndContinue(family => family.AddInterceptor(interceptor));
}
public GenericFamilyExpression AddConcreteType(Type concreteType)
Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs 2008-06-07 22:48:46 UTC (rev 120)
+++ trunk/Source/StructureMap/Configuration/DSL/Expressions/ProfileExpression.cs 2008-06-15 01:49:31 UTC (rev 121)
@@ -61,10 +61,7 @@
/// <returns></returns>
public ProfileExpression UseNamedInstance(string instanceKey)
{
- _registry.addExpression(delegate(PluginGraph graph)
- {
- graph.SetDefault(_profileName, typeof(T), new ReferencedInstance(instanceKey));
- });
+ _registry.addExpression(graph => graph.SetDefault(_profileName, typeof (T), new ReferencedInstance(instanceKey)));
return _parent;
}
@@ -78,10 +75,7 @@
{
instance.Name = "Default Instance for Profile " + _profileName;
- _registry.addExpression(delegate (PluginGraph graph)
- {
- graph.SetDefault(_profileName, typeof(T), instance);
- });
+ _registry.addExpression(graph => graph.SetDefault(_profileName, typeof (T), instance));
return _parent;
}
@@ -134,10 +128,7 @@
public ProfileExpression Use(Instance instance)
{
- _registry.addExpression(delegate(PluginGraph graph)
- {
- graph.SetDefault(_parent._profileName, _pluginType, instance);
- });
+ _registry.addExpression(graph => graph.SetDefault(_parent._profileName, _pluginType, instance));
return _parent;
}
Modified: trunk/Source/StructureMap/Configuration/DSL/Expressions/ScanAssembliesExpression.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/Expressions/ScanAssembliesExpression.cs 2008-06-07 22:48:46 UTC (rev 120)
+++ trunk/Source/StructureMap/Configuration/DSL/Expressions/ScanAssembliesExpression.cs 2008-06-15 01:49:31 UTC (rev 121)
@@ -19,7 +19,7 @@
public ScanAssembliesExpression(Registry registry)
{
_registry = registry;
- _registry.addExpression(delegate(PluginGraph graph)
+ _registry.addExpression(graph =>
{
foreach (Assembly assembly in _assemblies)
{
@@ -68,7 +68,7 @@
public ScanAssembliesExpression AddAllTypesOf<PLUGINTYPE>()
{
- _registry.addExpression(delegate(PluginGraph pluginGraph)
+ _registry.addExpression(pluginGraph =>
{
PluginFamily family =
pluginGraph.FindFamily(typeof (PLUGINTYPE));
@@ -88,10 +88,7 @@
public ScanAssembliesExpression With(ITypeScanner scanner)
{
- _registry.addExpression(delegate(PluginGraph graph)
- {
- graph.Assemblies.AddScanner(scanner);
- });
+ _registry.addExpression(graph => graph.Assemblies.AddScanner(scanner));
return this;
Modified: trunk/Source/StructureMap/Configuration/DSL/Registry.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2008-06-07 22:48:46 UTC (rev 120)
+++ trunk/Source/StructureMap/Configuration/DSL/Registry.cs 2008-06-15 01:49:31 UTC (rev 121)
@@ -89,7 +89,7 @@
ConfiguredInstance instance = new ConfiguredInstance();
addExpression(
- delegate(PluginGraph pluginGraph) { pluginGraph.FindFamily(typeof (PLUGINTYPE)).AddInstance(instance); });
+ pluginGraph => pluginGraph.FindFamily(typeof (PLUGINTYPE)).AddInstance(instance));
return instance;
}
@@ -104,7 +104,7 @@
public LiteralInstance AddInstanceOf<PLUGINTYPE>(PLUGINTYPE target)
{
LiteralInstance literal = new LiteralInstance(target);
- _actions.Add(delegate(PluginGraph graph) { graph.FindFamily(typeof (PLUGINTYPE)).AddInstance(literal); });
+ _actions.Add(graph => graph.FindFamily(typeof (PLUGINTYPE)).AddInstance(literal));
return literal;
}
@@ -118,10 +118,7 @@
public PrototypeInstance AddPrototypeInstanceOf<PLUGINTYPE>(PLUGINTYPE prototype)
{
PrototypeInstance instance = new PrototypeInstance((ICloneable) prototype);
- _actions.Add(delegate(PluginGraph graph)
- {
- graph.FindFamily(typeof (PLUGINTYPE)).AddInstance(instance);
- });
+ _actions.Add(graph => graph.FindFamily(typeof (PLUGINTYPE)).AddInstance(instance));
return instance;
}
@@ -129,7 +126,6 @@
/// <summary>
/// convenience method for a UserControl
/// </summary>
- /// <typeparam name="PLUGINTYPE"></typeparam>
/// <param name="url"></param>
/// <returns></returns>
public static UserControlInstance LoadUserControlFrom(string url)
@@ -166,14 +162,13 @@
public void RegisterInterceptor(TypeInterceptor interceptor)
{
- addExpression(
- delegate(PluginGraph pluginGraph) { pluginGraph.InterceptorLibrary.AddInterceptor(interceptor); });
+ addExpression(pluginGraph => pluginGraph.InterceptorLibrary.AddInterceptor(interceptor));
}
public MatchedTypeInterceptor IfTypeMatches(Predicate<Type> match)
{
MatchedTypeInterceptor interceptor = new MatchedTypeInterceptor(match);
- _actions.Add(delegate(PluginGraph graph) { graph.InterceptorLibrary.AddInterceptor(interceptor); });
+ _actions.Add(graph => graph.InterceptorLibrary.AddInterceptor(interceptor));
return interceptor;
}
@@ -191,12 +186,12 @@
public void AddInstanceOf(Type pluginType, Instance instance)
{
- _actions.Add(delegate(PluginGraph graph) { graph.FindFamily(pluginType).AddInstance(instance); });
+ _actions.Add(graph => graph.FindFamily(pluginType).AddInstance(instance));
}
public void AddInstanceOf<PLUGINTYPE>(Instance instance)
{
- _actions.Add(delegate(PluginGraph graph) { graph.FindFamily(typeof (PLUGINTYPE)).AddInstance(instance); });
+ _actions.Add(graph => graph.FindFamily(typeof (PLUGINTYPE)).AddInstance(instance));
}
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Configuration/DSL/RegistryExpressions.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/DSL/RegistryExpressions.cs 2008-06-07 22:48:46 UTC (rev 120)
+++ trunk/Source/StructureMap/Configuration/DSL/RegistryExpressions.cs 2008-06-15 01:49:31 UTC (rev 121)
@@ -53,7 +53,7 @@
public static ConstructorInstance ConstructedBy<PLUGINTYPE>
(Func<PLUGINTYPE> builder)
{
- return new ConstructorInstance(delegate() { return builder(); });
+ return new ConstructorInstance(() => builder());
}
public static ReferencedInstance Instance(string referencedKey)
Modified: trunk/Source/StructureMap/Configuration/FamilyParser.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/FamilyParser.cs 2008-06-07 22:48:46 UTC (rev 120)
+++ trunk/Source/StructureMap/Configuration/FamilyParser.cs 2008-06-15 01:49:31 UTC (rev 121)
@@ -7,7 +7,7 @@
namespace StructureMap.Configuration
{
- public class FamilyParser
+ public class FamilyParser : XmlConstants
{
private readonly IGraphBuilder _builder;
private readonly XmlMementoCreator _mementoCreator;
@@ -21,26 +21,36 @@
public void ParseFamily(XmlElement familyElement)
{
TypePath typePath = TypePath.CreateFromXmlNode(familyElement);
- _builder.ConfigureFamily(typePath, delegate(PluginFamily family)
+ _builder.ConfigureFamily(typePath, family =>
{
family.DefaultInstanceKey =
- familyElement.GetAttribute(XmlConstants.DEFAULT_KEY_ATTRIBUTE);
+ familyElement.GetAttribute(DEFAULT_KEY_ATTRIBUTE);
InstanceScope scope = findScope(familyElement);
family.SetScopeTo(scope);
attachMementoSource(family, familyElement);
- attachPlugins(family, familyElement);
+ familyElement.ForEachChild(PLUGIN_NODE).Do(element => attachPlugin(element, family));
attachInterceptors(family, familyElement);
+ attachInstances(family, familyElement, _builder);
});
}
+ private void attachInstances(PluginFamily family, XmlElement familyElement, IGraphBuilder builder)
+ {
+ familyElement.ForEachChild(INSTANCE_NODE).Do(element =>
+ {
+ InstanceMemento memento = _mementoCreator.CreateMemento(element);
+ family.AddInstance(memento);
+ });
+ }
+
public void ParseDefaultElement(XmlElement element)
{
- TypePath pluginTypePath = new TypePath(element.GetAttribute(XmlConstants.PLUGIN_TYPE));
+ TypePath pluginTypePath = new TypePath(element.GetAttribute(PLUGIN_TYPE));
- _builder.ConfigureFamily(pluginTypePath, delegate(PluginFamily family)
+ _builder.ConfigureFamily(pluginTypePath, family =>
{
InstanceScope scope = findScope(element);
family.SetScopeTo(scope);
@@ -52,9 +62,9 @@
public void ParseInstanceElement(XmlElement element)
{
- TypePath pluginTypePath = new TypePath(element.GetAttribute(XmlConstants.PLUGIN_TYPE));
+ TypePath pluginTypePath = new TypePath(element.GetAttribute(PLUGIN_TYPE));
- _builder.ConfigureFamily(pluginTypePath, delegate(PluginFamily family)
+ _builder.ConfigureFamily(pluginTypePath, family =>
{
InstanceMemento memento =
_mementoCreator.CreateMemento(element);
@@ -66,79 +76,52 @@
{
InstanceScope returnValue = InstanceScope.PerRequest;
- string scopeString = familyElement.GetAttribute(XmlConstants.SCOPE_ATTRIBUTE);
- if (!string.IsNullOrEmpty(scopeString))
+ familyElement.ForAttributeValue(SCOPE, scope =>
{
- returnValue = (InstanceScope) Enum.Parse(typeof (InstanceScope), scopeString);
- }
+ returnValue = (InstanceScope)Enum.Parse(typeof(InstanceScope), scope);
+ });
return returnValue;
}
private void attachMementoSource(PluginFamily family, XmlElement familyElement)
{
- XmlNode sourceNode = familyElement[XmlConstants.MEMENTO_SOURCE_NODE];
- if (sourceNode != null)
+ familyElement.IfHasNode(MEMENTO_SOURCE_NODE).Do(node =>
{
- InstanceMemento sourceMemento = new XmlAttributeInstanceMemento(sourceNode);
+ InstanceMemento sourceMemento = new XmlAttributeInstanceMemento(node);
- string context = "MementoSource for " + TypePath.GetAssemblyQualifiedName(family.PluginType) + "\n" +
- sourceNode.OuterXml;
+ string context = string.Format("MementoSource for {0}\n{1}", TypePath.GetAssemblyQualifiedName(family.PluginType), node.OuterXml);
_builder.WithSystemObject<MementoSource>(sourceMemento, context,
- delegate(MementoSource source) { family.AddMementoSource(source); });
- }
+ source => family.AddMementoSource(source));
+ });
}
- private void attachPlugins(PluginFamily family, XmlElement familyElement)
- {
- // TODO: 3.5 lambda cleanup
- XmlNodeList pluginNodes = familyElement.SelectNodes(XmlConstants.PLUGIN_NODE);
- foreach (XmlElement pluginElement in pluginNodes)
- {
- attachPlugin(pluginElement, family);
- }
- }
-
private void attachPlugin(XmlElement pluginElement, PluginFamily family)
{
TypePath pluginPath = TypePath.CreateFromXmlNode(pluginElement);
- string concreteKey = pluginElement.GetAttribute(XmlConstants.CONCRETE_KEY_ATTRIBUTE);
+ string concreteKey = pluginElement.GetAttribute(CONCRETE_KEY_ATTRIBUTE);
string context = "creating a Plugin for " + family.PluginType.AssemblyQualifiedName;
- _builder.WithType(pluginPath, context, delegate(Type pluggedType)
+ _builder.WithType(pluginPath, context, pluggedType =>
{
Plugin plugin = new Plugin(pluggedType, concreteKey);
family.AddPlugin(plugin);
- foreach (
- XmlElement setterElement in pluginElement.ChildNodes)
- {
- string setterName =
- setterElement.GetAttribute("Name");
- plugin.Setters.Add(setterName);
- }
+ pluginElement.ForTextInChild("Setter/@Name").Do(prop => plugin.Setters.Add(prop));
+
});
}
- // TODO: 3.5 lambda cleanup
private void attachInterceptors(PluginFamily family, XmlElement familyElement)
{
- XmlNode interceptorChainNode = familyElement[XmlConstants.INTERCEPTORS_NODE];
- if (interceptorChainNode == null)
+ string contextBase = string.Format("creating an InstanceInterceptor for {0}\n", TypePath.GetAssemblyQualifiedName(family.PluginType));
+ familyElement.ForEachChild("*/Interceptor").Do(element =>
{
- return;
- }
-
- string contextBase = "creating an InstanceInterceptor for " +
- TypePath.GetAssemblyQualifiedName(family.PluginType) + "\n";
- foreach (XmlNode interceptorNode in interceptorChainNode.ChildNodes)
- {
- XmlAttributeInstanceMemento interceptorMemento = new XmlAttributeInstanceMemento(interceptorNode);
-
- string context = contextBase + interceptorNode.OuterXml;
+ var interceptorMemento = new XmlAttributeInstanceMemento(element);
+ string context = contextBase + element.OuterXml;
_builder.WithSystemObject<IBuildInterceptor>(interceptorMemento, context,
- delegate(IBuildInterceptor interceptor) { family.AddInterceptor(interceptor); });
- }
+ interceptor => family.AddInterceptor(interceptor));
+ });
}
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Configuration/ProfileAndMachineParser.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/ProfileAndMachineParser.cs 2008-06-07 22:48:46 UTC (rev 120)
+++ trunk/Source/StructureMap/Configuration/ProfileAndMachineParser.cs 2008-06-15 01:49:31 UTC (rev 121)
@@ -1,3 +1,4 @@
+using System;
using System.Xml;
using StructureMap.Graph;
using StructureMap.Pipeline;
@@ -5,8 +6,7 @@
namespace StructureMap.Configuration
{
- // TODO: 3.5 cleanup
- public class ProfileAndMachineParser
+ public class ProfileAndMachineParser : XmlConstants
{
private readonly XmlMementoCreator _creator;
private readonly IGraphBuilder _graphBuilder;
@@ -23,57 +23,47 @@
public void Parse()
{
- // TODO: 3.5 cleanup
- XmlNode defaultProfileNode = _structureMapNode.Attributes.GetNamedItem(XmlConstants.DEFAULT_PROFILE);
- if (defaultProfileNode != null)
- {
- _profileBuilder.SetDefaultProfileName(defaultProfileNode.InnerText);
- }
+ _structureMapNode.ForAttributeValue(DEFAULT_PROFILE, profileName => _profileBuilder.SetDefaultProfileName(profileName));
- foreach (XmlElement profileElement in findNodes(XmlConstants.PROFILE_NODE))
+ forEachNode(PROFILE_NODE).Do(element =>
{
- string profileName = profileElement.GetAttribute(XmlConstants.NAME);
+ string profileName = element.GetAttribute(NAME);
_profileBuilder.AddProfile(profileName);
- writeOverrides(profileElement,
- delegate(string fullName, string defaultKey) { _profileBuilder.OverrideProfile(new TypePath(fullName), defaultKey); }, profileName);
- }
+ writeOverrides(element,
+ (fullName, defaultKey) => _profileBuilder.OverrideProfile(new TypePath(fullName), defaultKey), profileName);
+ });
- foreach (XmlElement machineElement in findNodes(XmlConstants.MACHINE_NODE))
+
+ forEachNode(MACHINE_NODE).Do(element =>
{
- string machineName = machineElement.GetAttribute(XmlConstants.NAME);
- string profileName = machineElement.GetAttribute(XmlConstants.PROFILE_NODE);
+ string machineName = element.GetAttribute(NAME);
+ string profileName = element.GetAttribute(PROFILE_NODE);
_profileBuilder.AddMachine(machineName, profileName);
- writeOverrides(machineElement,
- delegate(string fullName, string defaultKey) { _profileBuilder.OverrideMachine(new TypePath(fullName), defaultKey); }, machineName);
- }
+ writeOverrides(element,
+ (fullName, defaultKey) => _profileBuilder.OverrideMachine(new TypePath(fullName), defaultKey), machineName);
+ });
}
private void writeOverrides(XmlElement parentElement, WriteOverride function, string profileName)
{
- foreach (XmlElement overrideElement in parentElement.SelectNodes(XmlConstants.OVERRIDE))
- {
- processOverrideElement(function, overrideElement, profileName);
- }
+ parentElement.ForEachChild(OVERRIDE).Do(element => processOverrideElement(function, element, profileName));
}
private void processOverrideElement(WriteOverride function, XmlElement overrideElement, string profileName)
{
- string fullName = overrideElement.GetAttribute(XmlConstants.TYPE_ATTRIBUTE);
+ string fullName = overrideElement.GetAttribute(TYPE_ATTRIBUTE);
- XmlElement instanceElement = (XmlElement) overrideElement.SelectSingleNode(XmlConstants.INSTANCE_NODE);
- if (instanceElement == null)
- {
- string defaultKey = overrideElement.GetAttribute(XmlConstants.DEFAULT_KEY_ATTRIBUTE);
- function(fullName, defaultKey);
- }
- else
- {
- createOverrideInstance(fullName, instanceElement, function, profileName);
- }
+ overrideElement.IfHasNode(INSTANCE_NODE)
+ .Do(element => createOverrideInstance(fullName, element, function, profileName))
+ .Else(() =>
+ {
+ string defaultKey = overrideElement.GetAttribute(DEFAULT_KEY_ATTRIBUTE);
+ function(fullName, defaultKey);
+ });
}
private void createOverrideInstance(string fullName, XmlElement instanceElement, WriteOverride function,
@@ -85,16 +75,16 @@
TypePath familyPath = new TypePath(fullName);
- _graphBuilder.ConfigureFamily(familyPath, delegate(PluginFamily family)
- {
- family.AddInstance(memento);
- function(fullName, key);
- });
+ _graphBuilder.ConfigureFamily(familyPath, family =>
+ {
+ family.AddInstance(memento);
+ function(fullName, key);
+ });
}
- private XmlNodeList findNodes(string nodeName)
+ private XmlExtensions.XmlNodeExpression forEachNode(string xpath)
{
- return _structureMapNode.SelectNodes(nodeName);
+ return _structureMapNode.ForEachChild(xpath);
}
#region Nested type: WriteOverride
Modified: trunk/Source/StructureMap/Configuration/ProfileBuilder.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/ProfileBuilder.cs 2008-06-07 22:48:46 UTC (rev 120)
+++ trunk/Source/StructureMap/Configuration/ProfileBuilder.cs 2008-06-15 01:49:31 UTC (rev 121)
@@ -47,10 +47,10 @@
public void OverrideProfile(TypePath typePath, string instanceKey)
{
- _pluginGraph.Log.WithType(typePath, "while trying to add an override for a Profile", delegate(Type pluginType)
+ _pluginGraph.Log.WithType(typePath, "while trying to add an override for a Profile", pluginType =>
{
ReferencedInstance instance = new ReferencedInstance(instanceKey);
- _pluginGraph.SetDefault(_lastProfile, pluginType, instance);
+ _pluginGraph.SetDefault(_lastProfile, pluginType, instance);
});
}
@@ -72,12 +72,12 @@
}
_pluginGraph.Log.WithType(typePath,
- "trying to configure a Machine Override",
- delegate(Type pluginType)
- {
- ReferencedInstance instance = new ReferencedInstance(instanceKey);
- _profileManager.SetMachineDefault(pluginType, instance);
- });
+ "trying to configure a Machine Override",
+ pluginType =>
+ {
+ ReferencedInstance instance = new ReferencedInstance(instanceKey);
+ _profileManager.SetMachineDefault(pluginType, instance);
+ });
}
public void SetDefaultProfileName(string profileName)
Modified: trunk/Source/StructureMap/Configuration/XmlConstants.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/XmlConstants.cs 2008-06-07 22:48:46 UTC (rev 120)
+++ trunk/Source/StructureMap/Configuration/XmlConstants.cs 2008-06-15 01:49:31 UTC (rev 121)
@@ -29,13 +29,8 @@
public const string PLUGIN_NODE = "Plugin";
public const string PLUGIN_TYPE = "PluginType";
public const string PROFILE_NODE = "Profile";
- public const string SCOPE_ATTRIBUTE = "Scope";
+ public const string SCOPE = "Scope";
public const string STRUCTUREMAP = "StructureMap";
public const string TYPE_ATTRIBUTE = "Type";
-
-
- private XmlConstants()
- {
- }
}
}
\ No newline at end of file
Added: trunk/Source/StructureMap/Configuration/XmlExtensions.cs
===================================================================
--- trunk/Source/StructureMap/Configuration/XmlExtensions.cs (rev 0)
+++ trunk/Source/StructureMap/Configuration/XmlExtensions.cs 2008-06-15 01:49:31 UTC (rev 121)
@@ -0,0 +1,103 @@
+using System;
+using System.Xml;
+
+namespace StructureMap.Configuration
+{
+ public static class XmlExtensions
+ {
+ public static XmlTextExpression ForTextInChild(this XmlNode node, string xpath)
+ {
+ return new XmlTextExpression(node, xpath);
+ }
+
+ public static XmlNodeExpression ForEachChild(this XmlNode node, string xpath)
+ {
+ return new XmlNodeExpression(node, xpath);
+ }
+
+ public static void ForAttributeValue(this XmlNode node, string attributeName, Action<string> action)
+ {
+ XmlNode attNode = node.Attributes.GetNamedItem(attributeName);
+ if (attNode != null)
+ {
+ action(attNode.InnerText);
+ }
+ }
+
+ public static HasXmlElementExpression IfHasNode(this XmlNode node, string xpath)
+ {
+ return new HasXmlElementExpression(node, xpath);
+ }
+
+ public class HasXmlElementExpression
+ {
+ private XmlElement _element;
+
+ internal HasXmlElementExpression(XmlNode parent, string xpath)
+ {
+ _element = (XmlElement)parent.SelectSingleNode(xpath);
+ }
+
+ public HasXmlElementExpression Do(Action<XmlElement> action)
+ {
+ if (_element != null)
+ {
+ action(_element);
+ }
+
+ return this;
+ }
+
+ public void Else(Action action)
+ {
+ if (_element == null)
+ {
+ action();
+ }
+ }
+ }
+
+
+ public class XmlNodeExpression
+ {
+ private XmlNodeList _list;
+
+ internal XmlNodeExpression(XmlNode parent, string xpath)
+ {
+ _list = parent.SelectNodes(xpath);
+ }
+
+ public void Do(Action<XmlElement> action)
+ {
+ if (_list == null) return;
+
+ foreach (XmlNode node in _list)
+ {
+ action((XmlElement)node);
+ }
+ }
+ }
+
+ public class XmlTextExpression
+ {
+ private readonly XmlNodeList _list;
+
+ internal XmlTextExpression(XmlNode parent, string attributePath)
+ {
+ _list = parent.SelectNodes(attributePath);
+ }
+
+ public void Do(Action<string> action)
+ {
+ if (_list == null) return;
+
+ foreach (XmlNode node in _list)
+ {
+ action(node.InnerText);
+ }
+ }
+ }
+
+
+ }
+}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Diagnostics/BuildError.cs
===================================================================
--- trunk/Source/StructureMap/Diagnostics/BuildError.cs 2008-06-07 22:48:46 UTC (rev 120)
+++ trunk/Source/StructureMap/Diagnostics/BuildError.cs 2008-06-15 01:49:31 UTC (rev 121)
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
+using System.IO;
+using StructureMap.Graph;
using StructureMap.Pipeline;
namespace StructureMap.Diagnostics
@@ -76,5 +78,16 @@
get { return _exception; }
set { _exception = value; }
}
+
+ public void Write(StringWriter writer)
+ {
+ string description = ((IDiagnosticInstance)Instance).CreateToken().Description;
+
+ writer.WriteLine();
+ writer.WriteLine("-----------------------------------------------------------------------------------------------------");
+ writer.WriteLine("Build Error on Instance '{0}' ({1}) in PluginType {2}", Instance.Name, description, TypePath.GetAssemblyQualifiedName(PluginType));
+ if (Exception != null) writer.WriteLine(Exception.ToString());
+ writer.WriteLine();
+ }
}
}
\ No newline at end of file
Modified: trunk/Source/StructureMap/Diagnostics/Doctor.cs
===================================================================
--- trunk/Source/StructureMap/Diagnostics/Doctor.cs 2008-06-07 22:48:46 UTC (rev 120)
+++ trunk/Source/StructureMap/Diagnostics/Doctor.cs 2008-06-15 01:49:31 UTC (rev 121)
@@ -1,48 +1,88 @@
using System;
using System.Collections.Generic;
+using System.Diagnostics;
+using System.IO;
using System.Text;
-using StructureMap.Graph;
namespace StructureMap.Diagnostics
{
-
-
- public class DoctorReport
+ public class...
[truncated message content] |